@@ -59,20 +59,22 @@ pub use self::dcl::{
5959 AlterRoleOperation , CreateRole , ResetConfig , RoleOption , SecondaryRoles , SetConfigValue , Use ,
6060} ;
6161pub use self :: ddl:: {
62- AlterColumnOperation , AlterConnectorOwner , AlterIndexOperation , AlterPolicyOperation ,
63- AlterSchema , AlterSchemaOperation , AlterTable , AlterTableAlgorithm , AlterTableLock ,
64- AlterTableOperation , AlterType , AlterTypeAddValue , AlterTypeAddValuePosition ,
65- AlterTypeOperation , AlterTypeRename , AlterTypeRenameValue , ClusteredBy , ColumnDef ,
66- ColumnOption , ColumnOptionDef , ColumnOptions , ColumnPolicy , ColumnPolicyProperty ,
67- ConstraintCharacteristics , CreateConnector , CreateDomain , CreateExtension , CreateFunction ,
68- CreateIndex , CreateOperator , CreateOperatorClass , CreateOperatorFamily , CreateTable ,
69- CreateTrigger , CreateView , Deduplicate , DeferrableInitial , DropBehavior , DropExtension ,
70- DropFunction , DropTrigger , GeneratedAs , GeneratedExpressionMode , IdentityParameters ,
71- IdentityProperty , IdentityPropertyFormatKind , IdentityPropertyKind , IdentityPropertyOrder ,
72- IndexColumn , IndexOption , IndexType , KeyOrIndexDisplay , Msck , NullsDistinctOption ,
73- OperatorArgTypes , OperatorClassItem , OperatorPurpose , Owner , Partition , ProcedureParam ,
74- ReferentialAction , RenameTableNameKind , ReplicaIdentity , TagsColumnOption , TriggerObjectKind ,
75- Truncate , UserDefinedTypeCompositeAttributeDef , UserDefinedTypeRepresentation , ViewColumnDef ,
62+ Alignment , AlterColumnOperation , AlterConnectorOwner , AlterIndexOperation ,
63+ AlterPolicyOperation , AlterSchema , AlterSchemaOperation , AlterTable , AlterTableAlgorithm ,
64+ AlterTableLock , AlterTableOperation , AlterTableType , AlterType , AlterTypeAddValue ,
65+ AlterTypeAddValuePosition , AlterTypeOperation , AlterTypeRename , AlterTypeRenameValue ,
66+ ClusteredBy , ColumnDef , ColumnOption , ColumnOptionDef , ColumnOptions , ColumnPolicy ,
67+ ColumnPolicyProperty , ConstraintCharacteristics , CreateConnector , CreateDomain ,
68+ CreateExtension , CreateFunction , CreateIndex , CreateOperator , CreateOperatorClass ,
69+ CreateOperatorFamily , CreateTable , CreateTrigger , CreateView , Deduplicate , DeferrableInitial ,
70+ DropBehavior , DropExtension , DropFunction , DropTrigger , GeneratedAs , GeneratedExpressionMode ,
71+ IdentityParameters , IdentityProperty , IdentityPropertyFormatKind , IdentityPropertyKind ,
72+ IdentityPropertyOrder , IndexColumn , IndexOption , IndexType , KeyOrIndexDisplay , Msck ,
73+ NullsDistinctOption , OperatorArgTypes , OperatorClassItem , OperatorPurpose , Owner , Partition ,
74+ ProcedureParam , ReferentialAction , RenameTableNameKind , ReplicaIdentity , TagsColumnOption ,
75+ TriggerObjectKind , Truncate , UserDefinedTypeCompositeAttributeDef ,
76+ UserDefinedTypeInternalLength , UserDefinedTypeRangeOption , UserDefinedTypeRepresentation ,
77+ UserDefinedTypeSqlDefinitionOption , UserDefinedTypeStorage , ViewColumnDef ,
7678} ;
7779pub use self :: dml:: { Delete , Insert , Update } ;
7880pub use self :: operator:: { BinaryOperator , UnaryOperator } ;
@@ -2920,6 +2922,15 @@ pub enum Set {
29202922 /// MySQL-style
29212923 /// SET a = 1, b = 2, ..;
29222924 MultipleAssignments { assignments : Vec < SetAssignment > } ,
2925+ /// Session authorization for Postgres/Redshift
2926+ ///
2927+ /// ```sql
2928+ /// SET SESSION AUTHORIZATION { user_name | DEFAULT }
2929+ /// ```
2930+ ///
2931+ /// See <https://www.postgresql.org/docs/current/sql-set-session-authorization.html>
2932+ /// See <https://docs.aws.amazon.com/redshift/latest/dg/r_SET_SESSION_AUTHORIZATION.html>
2933+ SetSessionAuthorization ( SetSessionAuthorizationParam ) ,
29232934 /// MS-SQL session
29242935 ///
29252936 /// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
@@ -2994,6 +3005,7 @@ impl Display for Set {
29943005 modifier = context_modifier. map( |m| format!( "{m}" ) ) . unwrap_or_default( )
29953006 )
29963007 }
3008+ Self :: SetSessionAuthorization ( kind) => write ! ( f, "SET SESSION AUTHORIZATION {kind}" ) ,
29973009 Self :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
29983010 Self :: SetTransaction {
29993011 modes,
@@ -4113,7 +4125,7 @@ pub enum Statement {
41134125 /// ```
41144126 CreateType {
41154127 name : ObjectName ,
4116- representation : UserDefinedTypeRepresentation ,
4128+ representation : Option < UserDefinedTypeRepresentation > ,
41174129 } ,
41184130 /// ```sql
41194131 /// PRAGMA <schema-name>.<pragma-name> = <pragma-value>
@@ -4274,6 +4286,14 @@ pub enum Statement {
42744286 /// ```
42754287 /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
42764288 Vacuum ( VacuumStatement ) ,
4289+ /// Restore the value of a run-time parameter to the default value.
4290+ ///
4291+ /// ```sql
4292+ /// RESET configuration_parameter;
4293+ /// RESET ALL;
4294+ /// ```
4295+ /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-reset.html)
4296+ Reset ( ResetStatement ) ,
42774297}
42784298
42794299impl From < Analyze > for Statement {
@@ -5660,7 +5680,11 @@ impl fmt::Display for Statement {
56605680 name,
56615681 representation,
56625682 } => {
5663- write ! ( f, "CREATE TYPE {name} AS {representation}" )
5683+ write ! ( f, "CREATE TYPE {name}" ) ?;
5684+ if let Some ( repr) = representation {
5685+ write ! ( f, " {repr}" ) ?;
5686+ }
5687+ Ok ( ( ) )
56645688 }
56655689 Statement :: Pragma { name, value, is_eq } => {
56665690 write ! ( f, "PRAGMA {name}" ) ?;
@@ -5773,6 +5797,7 @@ impl fmt::Display for Statement {
57735797 Statement :: AlterSchema ( s) => write ! ( f, "{s}" ) ,
57745798 Statement :: Vacuum ( s) => write ! ( f, "{s}" ) ,
57755799 Statement :: AlterUser ( s) => write ! ( f, "{s}" ) ,
5800+ Statement :: Reset ( s) => write ! ( f, "{s}" ) ,
57765801 }
57775802 }
57785803}
@@ -9834,6 +9859,42 @@ impl fmt::Display for TableObject {
98349859 }
98359860}
98369861
9862+ /// Represents a SET SESSION AUTHORIZATION statement
9863+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9864+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9865+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9866+ pub struct SetSessionAuthorizationParam {
9867+ pub scope : ContextModifier ,
9868+ pub kind : SetSessionAuthorizationParamKind ,
9869+ }
9870+
9871+ impl fmt:: Display for SetSessionAuthorizationParam {
9872+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9873+ write ! ( f, "{}" , self . kind)
9874+ }
9875+ }
9876+
9877+ /// Represents the parameter kind for SET SESSION AUTHORIZATION
9878+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9879+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9880+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9881+ pub enum SetSessionAuthorizationParamKind {
9882+ /// Default authorization
9883+ Default ,
9884+
9885+ /// User name
9886+ User ( Ident ) ,
9887+ }
9888+
9889+ impl fmt:: Display for SetSessionAuthorizationParamKind {
9890+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9891+ match self {
9892+ SetSessionAuthorizationParamKind :: Default => write ! ( f, "DEFAULT" ) ,
9893+ SetSessionAuthorizationParamKind :: User ( name) => write ! ( f, "{}" , name) ,
9894+ }
9895+ }
9896+ }
9897+
98379898#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
98389899#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
98399900#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -10535,6 +10596,38 @@ impl fmt::Display for VacuumStatement {
1053510596 }
1053610597}
1053710598
10599+ /// Variants of the RESET statement
10600+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10601+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10602+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10603+ pub enum Reset {
10604+ /// Resets all session parameters to their default values.
10605+ ALL ,
10606+
10607+ /// Resets a specific session parameter to its default value.
10608+ ConfigurationParameter ( ObjectName ) ,
10609+ }
10610+
10611+ /// Resets a session parameter to its default value.
10612+ /// ```sql
10613+ /// RESET { ALL | <configuration_parameter> }
10614+ /// ```
10615+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10616+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10617+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10618+ pub struct ResetStatement {
10619+ pub reset : Reset ,
10620+ }
10621+
10622+ impl fmt:: Display for ResetStatement {
10623+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10624+ match & self . reset {
10625+ Reset :: ALL => write ! ( f, "RESET ALL" ) ,
10626+ Reset :: ConfigurationParameter ( param) => write ! ( f, "RESET {}" , param) ,
10627+ }
10628+ }
10629+ }
10630+
1053810631impl From < Set > for Statement {
1053910632 fn from ( s : Set ) -> Self {
1054010633 Self :: Set ( s)
@@ -10775,6 +10868,12 @@ impl From<VacuumStatement> for Statement {
1077510868 }
1077610869}
1077710870
10871+ impl From < ResetStatement > for Statement {
10872+ fn from ( r : ResetStatement ) -> Self {
10873+ Self :: Reset ( r)
10874+ }
10875+ }
10876+
1077810877#[ cfg( test) ]
1077910878mod tests {
1078010879 use crate :: tokenizer:: Location ;
0 commit comments