@@ -56,8 +56,8 @@ pub use self::data_type::{
5656 ExactNumberInfo , IntervalFields , StructBracketKind , TimezoneInfo ,
5757} ;
5858pub use self :: dcl:: {
59- AlterRoleOperation , CreateRole , Grant , ResetConfig , Revoke , RoleOption , SecondaryRoles ,
60- SetConfigValue , Use ,
59+ AlterDefaultPrivilegesOperation , AlterRoleOperation , CreateRole , Grant , ResetConfig , Revoke ,
60+ RoleOption , SecondaryRoles , SetConfigValue , Use ,
6161} ;
6262pub use self :: ddl:: {
6363 Alignment , AlterCollation , AlterCollationOperation , AlterColumnOperation , AlterColumnStorage ,
@@ -3956,6 +3956,17 @@ pub enum Statement {
39563956 /// ```
39573957 DropFunction ( DropFunction ) ,
39583958 /// ```sql
3959+ /// DROP ROUTINE
3960+ /// ```
3961+ DropRoutine {
3962+ /// `true` when `IF EXISTS` was present.
3963+ if_exists : bool ,
3964+ /// One or more routines to drop.
3965+ routine_desc : Vec < FunctionDesc > ,
3966+ /// Optional drop behavior (`CASCADE` or `RESTRICT`).
3967+ drop_behavior : Option < DropBehavior > ,
3968+ } ,
3969+ /// ```sql
39593970 /// DROP DOMAIN
39603971 /// ```
39613972 /// See [PostgreSQL](https://www.postgresql.org/docs/current/sql-dropdomain.html)
@@ -4319,6 +4330,24 @@ pub enum Statement {
43194330 /// See <https://docs.snowflake.com/en/sql-reference/sql/comment>
43204331 if_exists : bool ,
43214332 } ,
4333+ /// PostgreSQL `COMMENT ON ROUTINE`.
4334+ CommentRoutine {
4335+ /// Routine signature.
4336+ routine : FunctionDesc ,
4337+ /// Comment text, or `NULL` to remove it.
4338+ comment : Option < String > ,
4339+ /// `true` when `IF EXISTS` was present.
4340+ if_exists : bool ,
4341+ } ,
4342+ /// PostgreSQL `ALTER DEFAULT PRIVILEGES`.
4343+ AlterDefaultPrivileges {
4344+ /// Optional roles whose default privileges are changed.
4345+ target_roles : Vec < ObjectName > ,
4346+ /// Optional schemas limiting the change.
4347+ schemas : Vec < ObjectName > ,
4348+ /// Grant or revoke operation.
4349+ operation : AlterDefaultPrivilegesOperation ,
4350+ } ,
43224351 /// ```sql
43234352 /// COMMIT [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]
43244353 /// ```
@@ -4385,6 +4414,8 @@ pub enum Statement {
43854414 ///
43864415 /// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-clone#databases-schemas)
43874416 clone : Option < ObjectName > ,
4417+ /// Statements contained in the schema definition.
4418+ statements : Vec < Statement > ,
43884419 } ,
43894420 /// ```sql
43904421 /// CREATE DATABASE
@@ -5676,6 +5707,22 @@ impl fmt::Display for Statement {
56765707 Ok ( ( ) )
56775708 }
56785709 Statement :: DropFunction ( drop_function) => write ! ( f, "{drop_function}" ) ,
5710+ Statement :: DropRoutine {
5711+ if_exists,
5712+ routine_desc,
5713+ drop_behavior,
5714+ } => {
5715+ write ! (
5716+ f,
5717+ "DROP ROUTINE{} {}" ,
5718+ if * if_exists { " IF EXISTS" } else { "" } ,
5719+ display_comma_separated( routine_desc) ,
5720+ ) ?;
5721+ if let Some ( op) = drop_behavior {
5722+ write ! ( f, " {op}" ) ?;
5723+ }
5724+ Ok ( ( ) )
5725+ }
56795726 Statement :: DropDomain ( DropDomain {
56805727 if_exists,
56815728 name,
@@ -5984,6 +6031,7 @@ impl fmt::Display for Statement {
59846031 options,
59856032 default_collate_spec,
59866033 clone,
6034+ statements,
59876035 } => {
59886036 write ! (
59896037 f,
@@ -6007,6 +6055,11 @@ impl fmt::Display for Statement {
60076055 if let Some ( clone) = clone {
60086056 write ! ( f, " CLONE {clone}" ) ?;
60096057 }
6058+
6059+ for statement in statements {
6060+ write ! ( f, " {statement}" ) ?;
6061+ }
6062+
60106063 Ok ( ( ) )
60116064 }
60126065 Statement :: Assert { condition, message } => {
@@ -6197,6 +6250,35 @@ impl fmt::Display for Statement {
61976250 }
61986251 Ok ( ( ) )
61996252 }
6253+ Statement :: CommentRoutine {
6254+ routine,
6255+ comment,
6256+ if_exists,
6257+ } => {
6258+ write ! (
6259+ f,
6260+ "COMMENT{} ON ROUTINE {routine} IS {}" ,
6261+ if * if_exists { " IF EXISTS" } else { "" } ,
6262+ comment
6263+ . as_ref( )
6264+ . map( |c| format!( "'{}'" , value:: escape_single_quote_string( c) ) )
6265+ . unwrap_or_else( || "NULL" . to_string( ) )
6266+ )
6267+ }
6268+ Statement :: AlterDefaultPrivileges {
6269+ target_roles,
6270+ schemas,
6271+ operation,
6272+ } => {
6273+ write ! ( f, "ALTER DEFAULT PRIVILEGES" ) ?;
6274+ if !target_roles. is_empty ( ) {
6275+ write ! ( f, " FOR ROLE {}" , display_comma_separated( target_roles) ) ?;
6276+ }
6277+ if !schemas. is_empty ( ) {
6278+ write ! ( f, " IN SCHEMA {}" , display_comma_separated( schemas) ) ?;
6279+ }
6280+ write ! ( f, " {operation}" )
6281+ }
62006282 Statement :: CopyIntoSnowflake {
62016283 kind,
62026284 into,
@@ -7450,7 +7532,7 @@ impl fmt::Display for Grantee {
74507532 write ! ( f, "GROUP " ) ?;
74517533 }
74527534 GranteesType :: Public => {
7453- write ! ( f, "PUBLIC " ) ?;
7535+ write ! ( f, "PUBLIC{}" , if self . name . is_some ( ) { " " } else { "" } ) ?;
74547536 }
74557537 GranteesType :: DatabaseRole => {
74567538 write ! ( f, "DATABASE ROLE " ) ?;
@@ -7638,6 +7720,8 @@ pub enum GrantObjects {
76387720 /// Optional argument types for overloaded functions.
76397721 arg_types : Vec < DataType > ,
76407722 } ,
7723+ /// Grant privileges on a routine.
7724+ Routine ( FunctionDesc ) ,
76417725}
76427726
76437727impl fmt:: Display for GrantObjects {
@@ -7783,6 +7867,7 @@ impl fmt::Display for GrantObjects {
77837867 }
77847868 Ok ( ( ) )
77857869 }
7870+ GrantObjects :: Routine ( routine) => write ! ( f, "ROUTINE {routine}" ) ,
77867871 }
77877872 }
77887873}
0 commit comments