@@ -2953,6 +2953,15 @@ pub enum Set {
29532953 /// MySQL-style
29542954 /// SET a = 1, b = 2, ..;
29552955 MultipleAssignments { assignments : Vec < SetAssignment > } ,
2956+ /// Session authorization for Postgres/Redshift
2957+ ///
2958+ /// ```sql
2959+ /// SET SESSION AUTHORIZATION { user_name | DEFAULT }
2960+ /// ```
2961+ ///
2962+ /// See <https://www.postgresql.org/docs/current/sql-set-session-authorization.html>
2963+ /// See <https://docs.aws.amazon.com/redshift/latest/dg/r_SET_SESSION_AUTHORIZATION.html>
2964+ SetSessionAuthorization ( SetSessionAuthorizationParam ) ,
29562965 /// MS-SQL session
29572966 ///
29582967 /// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
@@ -3027,6 +3036,7 @@ impl Display for Set {
30273036 modifier = context_modifier. map( |m| format!( "{m}" ) ) . unwrap_or_default( )
30283037 )
30293038 }
3039+ Self :: SetSessionAuthorization ( kind) => write ! ( f, "SET SESSION AUTHORIZATION {kind}" ) ,
30303040 Self :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
30313041 Self :: SetTransaction {
30323042 modes,
@@ -9856,6 +9866,42 @@ impl fmt::Display for TableObject {
98569866 }
98579867}
98589868
9869+ /// Represents a SET SESSION AUTHORIZATION statement
9870+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9871+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9872+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9873+ pub struct SetSessionAuthorizationParam {
9874+ pub scope : ContextModifier ,
9875+ pub kind : SetSessionAuthorizationParamKind ,
9876+ }
9877+
9878+ impl fmt:: Display for SetSessionAuthorizationParam {
9879+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9880+ write ! ( f, "{}" , self . kind)
9881+ }
9882+ }
9883+
9884+ /// Represents the parameter kind for SET SESSION AUTHORIZATION
9885+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9886+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9887+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9888+ pub enum SetSessionAuthorizationParamKind {
9889+ /// Default authorization
9890+ Default ,
9891+
9892+ /// User name
9893+ User ( Ident ) ,
9894+ }
9895+
9896+ impl fmt:: Display for SetSessionAuthorizationParamKind {
9897+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9898+ match self {
9899+ SetSessionAuthorizationParamKind :: Default => write ! ( f, "DEFAULT" ) ,
9900+ SetSessionAuthorizationParamKind :: User ( name) => write ! ( f, "{}" , name) ,
9901+ }
9902+ }
9903+ }
9904+
98599905#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
98609906#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
98619907#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
0 commit comments