@@ -2919,6 +2919,15 @@ pub enum Set {
29192919 /// MySQL-style
29202920 /// SET a = 1, b = 2, ..;
29212921 MultipleAssignments { assignments : Vec < SetAssignment > } ,
2922+ /// Session authorization for Postgres/Redshift
2923+ ///
2924+ /// ```sql
2925+ /// SET SESSION AUTHORIZATION { user_name | DEFAULT }
2926+ /// ```
2927+ ///
2928+ /// See <https://www.postgresql.org/docs/current/sql-set-session-authorization.html>
2929+ /// See <https://docs.aws.amazon.com/redshift/latest/dg/r_SET_SESSION_AUTHORIZATION.html>
2930+ SetSessionAuthorization ( SetSessionAuthorizationParam ) ,
29222931 /// MS-SQL session
29232932 ///
29242933 /// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
@@ -2993,6 +3002,7 @@ impl Display for Set {
29933002 modifier = context_modifier. map( |m| format!( "{m}" ) ) . unwrap_or_default( )
29943003 )
29953004 }
3005+ Self :: SetSessionAuthorization ( kind) => write ! ( f, "SET SESSION AUTHORIZATION {kind}" ) ,
29963006 Self :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
29973007 Self :: SetTransaction {
29983008 modes,
@@ -9822,6 +9832,42 @@ impl fmt::Display for TableObject {
98229832 }
98239833}
98249834
9835+ /// Represents a SET SESSION AUTHORIZATION statement
9836+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9837+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9838+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9839+ pub struct SetSessionAuthorizationParam {
9840+ pub scope : ContextModifier ,
9841+ pub kind : SetSessionAuthorizationParamKind ,
9842+ }
9843+
9844+ impl fmt:: Display for SetSessionAuthorizationParam {
9845+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9846+ write ! ( f, "{}" , self . kind)
9847+ }
9848+ }
9849+
9850+ /// Represents the parameter kind for SET SESSION AUTHORIZATION
9851+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9852+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9853+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9854+ pub enum SetSessionAuthorizationParamKind {
9855+ /// Default authorization
9856+ Default ,
9857+
9858+ /// User name
9859+ User ( Ident ) ,
9860+ }
9861+
9862+ impl fmt:: Display for SetSessionAuthorizationParamKind {
9863+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9864+ match self {
9865+ SetSessionAuthorizationParamKind :: Default => write ! ( f, "DEFAULT" ) ,
9866+ SetSessionAuthorizationParamKind :: User ( name) => write ! ( f, "{}" , name) ,
9867+ }
9868+ }
9869+ }
9870+
98259871#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
98269872#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
98279873#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
0 commit comments