@@ -2924,6 +2924,15 @@ pub enum Set {
29242924 /// MySQL-style
29252925 /// SET a = 1, b = 2, ..;
29262926 MultipleAssignments { assignments : Vec < SetAssignment > } ,
2927+ /// Session authorization for Postgres/Redshift
2928+ ///
2929+ /// ```sql
2930+ /// SET SESSION AUTHORIZATION { user_name | DEFAULT }
2931+ /// ```
2932+ ///
2933+ /// See <https://www.postgresql.org/docs/current/sql-set-session-authorization.html>
2934+ /// See <https://docs.aws.amazon.com/redshift/latest/dg/r_SET_SESSION_AUTHORIZATION.html>
2935+ SetSessionAuthorization ( SetSessionAuthorizationParam ) ,
29272936 /// MS-SQL session
29282937 ///
29292938 /// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
@@ -2998,6 +3007,7 @@ impl Display for Set {
29983007 modifier = context_modifier. map( |m| format!( "{m}" ) ) . unwrap_or_default( )
29993008 )
30003009 }
3010+ Self :: SetSessionAuthorization ( kind) => write ! ( f, "SET SESSION AUTHORIZATION {kind}" ) ,
30013011 Self :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
30023012 Self :: SetTransaction {
30033013 modes,
@@ -9818,6 +9828,42 @@ impl fmt::Display for TableObject {
98189828 }
98199829}
98209830
9831+ /// Represents a SET SESSION AUTHORIZATION statement
9832+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9833+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9834+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9835+ pub struct SetSessionAuthorizationParam {
9836+ pub scope : ContextModifier ,
9837+ pub kind : SetSessionAuthorizationParamKind ,
9838+ }
9839+
9840+ impl fmt:: Display for SetSessionAuthorizationParam {
9841+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9842+ write ! ( f, "{}" , self . kind)
9843+ }
9844+ }
9845+
9846+ /// Represents the parameter kind for SET SESSION AUTHORIZATION
9847+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9848+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9849+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9850+ pub enum SetSessionAuthorizationParamKind {
9851+ /// Default authorization
9852+ Default ,
9853+
9854+ /// User name
9855+ User ( Ident ) ,
9856+ }
9857+
9858+ impl fmt:: Display for SetSessionAuthorizationParamKind {
9859+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9860+ match self {
9861+ SetSessionAuthorizationParamKind :: Default => write ! ( f, "DEFAULT" ) ,
9862+ SetSessionAuthorizationParamKind :: User ( name) => write ! ( f, "{}" , name) ,
9863+ }
9864+ }
9865+ }
9866+
98219867#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
98229868#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
98239869#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
0 commit comments