@@ -59,9 +59,9 @@ pub use self::dcl::{
5959 AlterRoleOperation , CreateRole , ResetConfig , RoleOption , SecondaryRoles , SetConfigValue , Use ,
6060} ;
6161pub use self :: ddl:: {
62- Alignment , AlterColumnOperation , AlterConnectorOwner , AlterIndexOperation ,
63- AlterPolicyOperation , AlterSchema , AlterSchemaOperation , AlterTable , AlterTableAlgorithm ,
64- AlterTableLock , AlterTableOperation , AlterType , AlterTypeAddValue , AlterTypeAddValuePosition ,
62+ Alignment , AlterColumnOperation , AlterConnectorOwner , AlterIndexOperation , AlterPolicyOperation ,
63+ AlterSchema , AlterSchemaOperation , AlterTable , AlterTableAlgorithm , AlterTableLock ,
64+ AlterTableOperation , AlterTableType , AlterType , AlterTypeAddValue , AlterTypeAddValuePosition ,
6565 AlterTypeOperation , AlterTypeRename , AlterTypeRenameValue , ClusteredBy , ColumnDef ,
6666 ColumnOption , ColumnOptionDef , ColumnOptions , ColumnPolicy , ColumnPolicyProperty ,
6767 ConstraintCharacteristics , CreateConnector , CreateDomain , CreateExtension , CreateFunction ,
@@ -2921,6 +2921,15 @@ pub enum Set {
29212921 /// MySQL-style
29222922 /// SET a = 1, b = 2, ..;
29232923 MultipleAssignments { assignments : Vec < SetAssignment > } ,
2924+ /// Session authorization for Postgres/Redshift
2925+ ///
2926+ /// ```sql
2927+ /// SET SESSION AUTHORIZATION { user_name | DEFAULT }
2928+ /// ```
2929+ ///
2930+ /// See <https://www.postgresql.org/docs/current/sql-set-session-authorization.html>
2931+ /// See <https://docs.aws.amazon.com/redshift/latest/dg/r_SET_SESSION_AUTHORIZATION.html>
2932+ SetSessionAuthorization ( SetSessionAuthorizationParam ) ,
29242933 /// MS-SQL session
29252934 ///
29262935 /// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
@@ -2995,6 +3004,7 @@ impl Display for Set {
29953004 modifier = context_modifier. map( |m| format!( "{m}" ) ) . unwrap_or_default( )
29963005 )
29973006 }
3007+ Self :: SetSessionAuthorization ( kind) => write ! ( f, "SET SESSION AUTHORIZATION {kind}" ) ,
29983008 Self :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
29993009 Self :: SetTransaction {
30003010 modes,
@@ -4260,6 +4270,14 @@ pub enum Statement {
42604270 /// ```
42614271 /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
42624272 Vacuum ( VacuumStatement ) ,
4273+ /// Restore the value of a run-time parameter to the default value.
4274+ ///
4275+ /// ```sql
4276+ /// RESET configuration_parameter;
4277+ /// RESET ALL;
4278+ /// ```
4279+ /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-reset.html)
4280+ Reset ( ResetStatement ) ,
42634281}
42644282
42654283impl From < Analyze > for Statement {
@@ -5758,6 +5776,7 @@ impl fmt::Display for Statement {
57585776 Statement :: AlterSchema ( s) => write ! ( f, "{s}" ) ,
57595777 Statement :: Vacuum ( s) => write ! ( f, "{s}" ) ,
57605778 Statement :: AlterUser ( s) => write ! ( f, "{s}" ) ,
5779+ Statement :: Reset ( s) => write ! ( f, "{s}" ) ,
57615780 }
57625781 }
57635782}
@@ -9819,6 +9838,42 @@ impl fmt::Display for TableObject {
98199838 }
98209839}
98219840
9841+ /// Represents a SET SESSION AUTHORIZATION statement
9842+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9843+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9844+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9845+ pub struct SetSessionAuthorizationParam {
9846+ pub scope : ContextModifier ,
9847+ pub kind : SetSessionAuthorizationParamKind ,
9848+ }
9849+
9850+ impl fmt:: Display for SetSessionAuthorizationParam {
9851+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9852+ write ! ( f, "{}" , self . kind)
9853+ }
9854+ }
9855+
9856+ /// Represents the parameter kind for SET SESSION AUTHORIZATION
9857+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9858+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9859+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9860+ pub enum SetSessionAuthorizationParamKind {
9861+ /// Default authorization
9862+ Default ,
9863+
9864+ /// User name
9865+ User ( Ident ) ,
9866+ }
9867+
9868+ impl fmt:: Display for SetSessionAuthorizationParamKind {
9869+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9870+ match self {
9871+ SetSessionAuthorizationParamKind :: Default => write ! ( f, "DEFAULT" ) ,
9872+ SetSessionAuthorizationParamKind :: User ( name) => write ! ( f, "{}" , name) ,
9873+ }
9874+ }
9875+ }
9876+
98229877#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
98239878#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
98249879#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -10520,6 +10575,38 @@ impl fmt::Display for VacuumStatement {
1052010575 }
1052110576}
1052210577
10578+ /// Variants of the RESET statement
10579+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10580+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10581+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10582+ pub enum Reset {
10583+ /// Resets all session parameters to their default values.
10584+ ALL ,
10585+
10586+ /// Resets a specific session parameter to its default value.
10587+ ConfigurationParameter ( ObjectName ) ,
10588+ }
10589+
10590+ /// Resets a session parameter to its default value.
10591+ /// ```sql
10592+ /// RESET { ALL | <configuration_parameter> }
10593+ /// ```
10594+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10595+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10596+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10597+ pub struct ResetStatement {
10598+ pub reset : Reset ,
10599+ }
10600+
10601+ impl fmt:: Display for ResetStatement {
10602+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10603+ match & self . reset {
10604+ Reset :: ALL => write ! ( f, "RESET ALL" ) ,
10605+ Reset :: ConfigurationParameter ( param) => write ! ( f, "RESET {}" , param) ,
10606+ }
10607+ }
10608+ }
10609+
1052310610impl From < Set > for Statement {
1052410611 fn from ( s : Set ) -> Self {
1052510612 Self :: Set ( s)
@@ -10760,6 +10847,12 @@ impl From<VacuumStatement> for Statement {
1076010847 }
1076110848}
1076210849
10850+ impl From < ResetStatement > for Statement {
10851+ fn from ( r : ResetStatement ) -> Self {
10852+ Self :: Reset ( r)
10853+ }
10854+ }
10855+
1076310856#[ cfg( test) ]
1076410857mod tests {
1076510858 use crate :: tokenizer:: Location ;
0 commit comments