@@ -59,19 +59,21 @@ 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 , CreateTable , CreateTrigger , CreateView , Deduplicate , DeferrableInitial ,
69- DropBehavior , DropExtension , DropFunction , DropTrigger , GeneratedAs , GeneratedExpressionMode ,
70- IdentityParameters , IdentityProperty , IdentityPropertyFormatKind , IdentityPropertyKind ,
71- IdentityPropertyOrder , IndexColumn , IndexOption , IndexType , KeyOrIndexDisplay , Msck ,
72- NullsDistinctOption , Owner , Partition , ProcedureParam , ReferentialAction , RenameTableNameKind ,
73- ReplicaIdentity , TagsColumnOption , TriggerObjectKind , Truncate ,
74- 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 , CreateTable , CreateTrigger , CreateView ,
69+ Deduplicate , DeferrableInitial , DropBehavior , DropExtension , DropFunction , DropTrigger ,
70+ GeneratedAs , GeneratedExpressionMode , IdentityParameters , IdentityProperty ,
71+ IdentityPropertyFormatKind , IdentityPropertyKind , IdentityPropertyOrder , IndexColumn ,
72+ IndexOption , IndexType , KeyOrIndexDisplay , Msck , NullsDistinctOption , Owner , Partition ,
73+ ProcedureParam , ReferentialAction , RenameTableNameKind , ReplicaIdentity , TagsColumnOption ,
74+ TriggerObjectKind , Truncate , UserDefinedTypeCompositeAttributeDef ,
75+ UserDefinedTypeInternalLength , UserDefinedTypeRangeOption , UserDefinedTypeRepresentation ,
76+ UserDefinedTypeSqlDefinitionOption , UserDefinedTypeStorage , ViewColumnDef ,
7577} ;
7678pub use self :: dml:: { Delete , Insert , Update } ;
7779pub use self :: operator:: { BinaryOperator , UnaryOperator } ;
@@ -2919,6 +2921,15 @@ pub enum Set {
29192921 /// MySQL-style
29202922 /// SET a = 1, b = 2, ..;
29212923 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 ) ,
29222933 /// MS-SQL session
29232934 ///
29242935 /// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
@@ -2993,6 +3004,7 @@ impl Display for Set {
29933004 modifier = context_modifier. map( |m| format!( "{m}" ) ) . unwrap_or_default( )
29943005 )
29953006 }
3007+ Self :: SetSessionAuthorization ( kind) => write ! ( f, "SET SESSION AUTHORIZATION {kind}" ) ,
29963008 Self :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
29973009 Self :: SetTransaction {
29983010 modes,
@@ -4097,7 +4109,7 @@ pub enum Statement {
40974109 /// ```
40984110 CreateType {
40994111 name : ObjectName ,
4100- representation : UserDefinedTypeRepresentation ,
4112+ representation : Option < UserDefinedTypeRepresentation > ,
41014113 } ,
41024114 /// ```sql
41034115 /// PRAGMA <schema-name>.<pragma-name> = <pragma-value>
@@ -4258,6 +4270,14 @@ pub enum Statement {
42584270 /// ```
42594271 /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
42604272 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 ) ,
42614281}
42624282
42634283impl From < Analyze > for Statement {
@@ -5639,7 +5659,11 @@ impl fmt::Display for Statement {
56395659 name,
56405660 representation,
56415661 } => {
5642- write ! ( f, "CREATE TYPE {name} AS {representation}" )
5662+ write ! ( f, "CREATE TYPE {name}" ) ?;
5663+ if let Some ( repr) = representation {
5664+ write ! ( f, " {repr}" ) ?;
5665+ }
5666+ Ok ( ( ) )
56435667 }
56445668 Statement :: Pragma { name, value, is_eq } => {
56455669 write ! ( f, "PRAGMA {name}" ) ?;
@@ -5752,6 +5776,7 @@ impl fmt::Display for Statement {
57525776 Statement :: AlterSchema ( s) => write ! ( f, "{s}" ) ,
57535777 Statement :: Vacuum ( s) => write ! ( f, "{s}" ) ,
57545778 Statement :: AlterUser ( s) => write ! ( f, "{s}" ) ,
5779+ Statement :: Reset ( s) => write ! ( f, "{s}" ) ,
57555780 }
57565781 }
57575782}
@@ -9813,6 +9838,42 @@ impl fmt::Display for TableObject {
98139838 }
98149839}
98159840
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+
98169877#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
98179878#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
98189879#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -10514,6 +10575,38 @@ impl fmt::Display for VacuumStatement {
1051410575 }
1051510576}
1051610577
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+
1051710610impl From < Set > for Statement {
1051810611 fn from ( s : Set ) -> Self {
1051910612 Self :: Set ( s)
@@ -10754,6 +10847,12 @@ impl From<VacuumStatement> for Statement {
1075410847 }
1075510848}
1075610849
10850+ impl From < ResetStatement > for Statement {
10851+ fn from ( r : ResetStatement ) -> Self {
10852+ Self :: Reset ( r)
10853+ }
10854+ }
10855+
1075710856#[ cfg( test) ]
1075810857mod tests {
1075910858 use crate :: tokenizer:: Location ;
0 commit comments