@@ -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:: { Copy , CsvFormatOptions , Delete , Insert , Update } ;
7779pub use self :: operator:: { BinaryOperator , UnaryOperator } ;
@@ -2787,7 +2789,7 @@ impl fmt::Display for Declare {
27872789}
27882790
27892791/// Sql options of a `CREATE TABLE` statement.
2790- #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash , Default ) ]
2792+ #[ derive( Debug , Default , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
27912793#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
27922794#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
27932795pub enum CreateTableOptions {
@@ -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,
@@ -4084,7 +4096,7 @@ pub enum Statement {
40844096 /// ```
40854097 CreateType {
40864098 name : ObjectName ,
4087- representation : UserDefinedTypeRepresentation ,
4099+ representation : Option < UserDefinedTypeRepresentation > ,
40884100 } ,
40894101 /// ```sql
40904102 /// PRAGMA <schema-name>.<pragma-name> = <pragma-value>
@@ -4245,6 +4257,14 @@ pub enum Statement {
42454257 /// ```
42464258 /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
42474259 Vacuum ( VacuumStatement ) ,
4260+ /// Restore the value of a run-time parameter to the default value.
4261+ ///
4262+ /// ```sql
4263+ /// RESET configuration_parameter;
4264+ /// RESET ALL;
4265+ /// ```
4266+ /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-reset.html)
4267+ Reset ( ResetStatement ) ,
42484268}
42494269
42504270impl From < Analyze > for Statement {
@@ -5589,7 +5609,11 @@ impl fmt::Display for Statement {
55895609 name,
55905610 representation,
55915611 } => {
5592- write ! ( f, "CREATE TYPE {name} AS {representation}" )
5612+ write ! ( f, "CREATE TYPE {name}" ) ?;
5613+ if let Some ( repr) = representation {
5614+ write ! ( f, " {repr}" ) ?;
5615+ }
5616+ Ok ( ( ) )
55935617 }
55945618 Statement :: Pragma { name, value, is_eq } => {
55955619 write ! ( f, "PRAGMA {name}" ) ?;
@@ -5702,6 +5726,7 @@ impl fmt::Display for Statement {
57025726 Statement :: AlterSchema ( s) => write ! ( f, "{s}" ) ,
57035727 Statement :: Vacuum ( s) => write ! ( f, "{s}" ) ,
57045728 Statement :: AlterUser ( s) => write ! ( f, "{s}" ) ,
5729+ Statement :: Reset ( s) => write ! ( f, "{s}" ) ,
57055730 }
57065731 }
57075732}
@@ -9763,6 +9788,42 @@ impl fmt::Display for TableObject {
97639788 }
97649789}
97659790
9791+ /// Represents a SET SESSION AUTHORIZATION statement
9792+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9793+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9794+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9795+ pub struct SetSessionAuthorizationParam {
9796+ pub scope : ContextModifier ,
9797+ pub kind : SetSessionAuthorizationParamKind ,
9798+ }
9799+
9800+ impl fmt:: Display for SetSessionAuthorizationParam {
9801+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9802+ write ! ( f, "{}" , self . kind)
9803+ }
9804+ }
9805+
9806+ /// Represents the parameter kind for SET SESSION AUTHORIZATION
9807+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
9808+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
9809+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
9810+ pub enum SetSessionAuthorizationParamKind {
9811+ /// Default authorization
9812+ Default ,
9813+
9814+ /// User name
9815+ User ( Ident ) ,
9816+ }
9817+
9818+ impl fmt:: Display for SetSessionAuthorizationParamKind {
9819+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9820+ match self {
9821+ SetSessionAuthorizationParamKind :: Default => write ! ( f, "DEFAULT" ) ,
9822+ SetSessionAuthorizationParamKind :: User ( name) => write ! ( f, "{}" , name) ,
9823+ }
9824+ }
9825+ }
9826+
97669827#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
97679828#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
97689829#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -10464,6 +10525,38 @@ impl fmt::Display for VacuumStatement {
1046410525 }
1046510526}
1046610527
10528+ /// Variants of the RESET statement
10529+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10530+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10531+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10532+ pub enum Reset {
10533+ /// Resets all session parameters to their default values.
10534+ ALL ,
10535+
10536+ /// Resets a specific session parameter to its default value.
10537+ ConfigurationParameter ( ObjectName ) ,
10538+ }
10539+
10540+ /// Resets a session parameter to its default value.
10541+ /// ```sql
10542+ /// RESET { ALL | <configuration_parameter> }
10543+ /// ```
10544+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10545+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10546+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10547+ pub struct ResetStatement {
10548+ pub reset : Reset ,
10549+ }
10550+
10551+ impl fmt:: Display for ResetStatement {
10552+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10553+ match & self . reset {
10554+ Reset :: ALL => write ! ( f, "RESET ALL" ) ,
10555+ Reset :: ConfigurationParameter ( param) => write ! ( f, "RESET {}" , param) ,
10556+ }
10557+ }
10558+ }
10559+
1046710560impl From < Set > for Statement {
1046810561 fn from ( s : Set ) -> Self {
1046910562 Self :: Set ( s)
@@ -10704,6 +10797,12 @@ impl From<VacuumStatement> for Statement {
1070410797 }
1070510798}
1070610799
10800+ impl From < ResetStatement > for Statement {
10801+ fn from ( r : ResetStatement ) -> Self {
10802+ Self :: Reset ( r)
10803+ }
10804+ }
10805+
1070710806#[ cfg( test) ]
1070810807mod tests {
1070910808 use crate :: tokenizer:: Location ;
0 commit comments