@@ -535,6 +535,14 @@ pub enum AlterTableOperation {
535535 /// Parenthesized options supplied to `SET (...)`.
536536 options : Vec < SqlOption > ,
537537 } ,
538+ /// `SET TABLESPACE tablespace_name`
539+ ///
540+ /// Note: this is a PostgreSQL-specific operation.
541+ /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-altertable.html)
542+ SetTablespace {
543+ /// The target tablespace name.
544+ tablespace_name : Ident ,
545+ } ,
538546}
539547
540548/// An `ALTER Policy` (`Statement::AlterPolicy`) operation
@@ -700,6 +708,14 @@ pub enum AlterIndexOperation {
700708 /// The new name for the index.
701709 index_name : ObjectName ,
702710 } ,
711+ /// `SET TABLESPACE tablespace_name`
712+ ///
713+ /// Note: this is a PostgreSQL-specific operation.
714+ /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-alterindex.html)
715+ SetTablespace {
716+ /// The target tablespace name.
717+ tablespace_name : Ident ,
718+ } ,
703719}
704720
705721impl fmt:: Display for AlterTableOperation {
@@ -1045,6 +1061,9 @@ impl fmt::Display for AlterTableOperation {
10451061 AlterTableOperation :: SetOptionsParens { options } => {
10461062 write ! ( f, "SET ({})" , display_comma_separated( options) )
10471063 }
1064+ AlterTableOperation :: SetTablespace { tablespace_name } => {
1065+ write ! ( f, "SET TABLESPACE {tablespace_name}" )
1066+ }
10481067 }
10491068 }
10501069}
@@ -1055,6 +1074,9 @@ impl fmt::Display for AlterIndexOperation {
10551074 AlterIndexOperation :: RenameIndex { index_name } => {
10561075 write ! ( f, "RENAME TO {index_name}" )
10571076 }
1077+ AlterIndexOperation :: SetTablespace { tablespace_name } => {
1078+ write ! ( f, "SET TABLESPACE {tablespace_name}" )
1079+ }
10581080 }
10591081 }
10601082}
@@ -5390,13 +5412,16 @@ pub enum AlterFunctionKind {
53905412 Function ,
53915413 /// `AGGREGATE`
53925414 Aggregate ,
5415+ /// `PROCEDURE`
5416+ Procedure ,
53935417}
53945418
53955419impl fmt:: Display for AlterFunctionKind {
53965420 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
53975421 match self {
53985422 Self :: Function => write ! ( f, "FUNCTION" ) ,
53995423 Self :: Aggregate => write ! ( f, "AGGREGATE" ) ,
5424+ Self :: Procedure => write ! ( f, "PROCEDURE" ) ,
54005425 }
54015426 }
54025427}
@@ -5471,7 +5496,7 @@ impl fmt::Display for AlterFunction {
54715496 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
54725497 write ! ( f, "ALTER {} " , self . kind) ?;
54735498 match self . kind {
5474- AlterFunctionKind :: Function => {
5499+ AlterFunctionKind :: Function | AlterFunctionKind :: Procedure => {
54755500 write ! ( f, "{} " , self . function) ?;
54765501 }
54775502 AlterFunctionKind :: Aggregate => {
@@ -6137,6 +6162,124 @@ impl From<CreateTextSearchTemplate> for crate::ast::Statement {
61376162 }
61386163}
61396164
6165+ /// `ALTER DOMAIN` statement.
6166+ ///
6167+ /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-alterdomain.html)
6168+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6169+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6170+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6171+ pub struct AlterDomain {
6172+ /// Name of the domain being altered.
6173+ pub name : ObjectName ,
6174+ /// The operation to perform.
6175+ pub operation : AlterDomainOperation ,
6176+ }
6177+
6178+ /// An [AlterDomain] operation.
6179+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6180+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6181+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6182+ pub enum AlterDomainOperation {
6183+ /// `ADD CONSTRAINT constraint_name CHECK (expr) [NOT VALID]`
6184+ AddConstraint {
6185+ /// The constraint to add.
6186+ constraint : TableConstraint ,
6187+ /// Whether `NOT VALID` was specified.
6188+ not_valid : bool ,
6189+ } ,
6190+ /// `DROP CONSTRAINT [IF EXISTS] constraint_name [CASCADE | RESTRICT]`
6191+ DropConstraint {
6192+ /// Whether `IF EXISTS` was specified.
6193+ if_exists : bool ,
6194+ /// Name of the constraint to drop.
6195+ name : Ident ,
6196+ /// Optional drop behavior.
6197+ drop_behavior : Option < DropBehavior > ,
6198+ } ,
6199+ /// `RENAME CONSTRAINT old_name TO new_name`
6200+ RenameConstraint {
6201+ /// Existing constraint name.
6202+ old_name : Ident ,
6203+ /// New constraint name.
6204+ new_name : Ident ,
6205+ } ,
6206+ /// `OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }`
6207+ OwnerTo ( Owner ) ,
6208+ /// `RENAME TO new_name`
6209+ RenameTo {
6210+ /// New name for the domain.
6211+ new_name : Ident ,
6212+ } ,
6213+ /// `SET SCHEMA schema_name`
6214+ SetSchema {
6215+ /// The target schema name.
6216+ schema_name : ObjectName ,
6217+ } ,
6218+ /// `SET DEFAULT expr`
6219+ SetDefault {
6220+ /// Default value expression.
6221+ default : Expr ,
6222+ } ,
6223+ /// `DROP DEFAULT`
6224+ DropDefault ,
6225+ /// `VALIDATE CONSTRAINT constraint_name`
6226+ ValidateConstraint {
6227+ /// Name of the constraint to validate.
6228+ name : Ident ,
6229+ } ,
6230+ }
6231+
6232+ impl fmt:: Display for AlterDomain {
6233+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6234+ write ! ( f, "ALTER DOMAIN {} {}" , self . name, self . operation)
6235+ }
6236+ }
6237+
6238+ impl fmt:: Display for AlterDomainOperation {
6239+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6240+ match self {
6241+ AlterDomainOperation :: AddConstraint {
6242+ constraint,
6243+ not_valid,
6244+ } => {
6245+ write ! ( f, "ADD {constraint}" ) ?;
6246+ if * not_valid {
6247+ write ! ( f, " NOT VALID" ) ?;
6248+ }
6249+ Ok ( ( ) )
6250+ }
6251+ AlterDomainOperation :: DropConstraint {
6252+ if_exists,
6253+ name,
6254+ drop_behavior,
6255+ } => {
6256+ write ! ( f, "DROP CONSTRAINT" ) ?;
6257+ if * if_exists {
6258+ write ! ( f, " IF EXISTS" ) ?;
6259+ }
6260+ write ! ( f, " {name}" ) ?;
6261+ if let Some ( behavior) = drop_behavior {
6262+ write ! ( f, " {behavior}" ) ?;
6263+ }
6264+ Ok ( ( ) )
6265+ }
6266+ AlterDomainOperation :: RenameConstraint { old_name, new_name } => {
6267+ write ! ( f, "RENAME CONSTRAINT {old_name} TO {new_name}" )
6268+ }
6269+ AlterDomainOperation :: OwnerTo ( owner) => write ! ( f, "OWNER TO {owner}" ) ,
6270+ AlterDomainOperation :: RenameTo { new_name } => write ! ( f, "RENAME TO {new_name}" ) ,
6271+ AlterDomainOperation :: SetSchema { schema_name } => {
6272+ write ! ( f, "SET SCHEMA {schema_name}" )
6273+ }
6274+ AlterDomainOperation :: SetDefault { default } => write ! ( f, "SET DEFAULT {default}" ) ,
6275+ AlterDomainOperation :: DropDefault => write ! ( f, "DROP DEFAULT" ) ,
6276+ AlterDomainOperation :: ValidateConstraint { name } => {
6277+ write ! ( f, "VALIDATE CONSTRAINT {name}" )
6278+ }
6279+ }
6280+ }
6281+ }
6282+
61406283/// The target of a `CREATE PUBLICATION` statement: which rows to publish.
61416284///
61426285/// See <https://www.postgresql.org/docs/current/sql-createpublication.html>
@@ -6170,6 +6313,131 @@ impl fmt::Display for PublicationTarget {
61706313 }
61716314}
61726315
6316+ impl From < AlterDomain > for crate :: ast:: Statement {
6317+ fn from ( a : AlterDomain ) -> Self {
6318+ crate :: ast:: Statement :: AlterDomain ( a)
6319+ }
6320+ }
6321+
6322+ /// `ALTER TRIGGER name ON table_name RENAME TO new_name` statement.
6323+ ///
6324+ /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-altertrigger.html)
6325+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6326+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6327+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6328+ pub struct AlterTrigger {
6329+ /// Name of the trigger being altered.
6330+ pub name : Ident ,
6331+ /// Name of the table the trigger is defined on.
6332+ pub table_name : ObjectName ,
6333+ /// The operation to perform.
6334+ pub operation : AlterTriggerOperation ,
6335+ }
6336+
6337+ /// An [AlterTrigger] operation.
6338+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6339+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6340+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6341+ pub enum AlterTriggerOperation {
6342+ /// `RENAME TO new_name`
6343+ RenameTo {
6344+ /// New name for the trigger.
6345+ new_name : Ident ,
6346+ } ,
6347+ }
6348+
6349+ impl fmt:: Display for AlterTrigger {
6350+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6351+ write ! (
6352+ f,
6353+ "ALTER TRIGGER {} ON {} {}" ,
6354+ self . name, self . table_name, self . operation
6355+ )
6356+ }
6357+ }
6358+
6359+ impl fmt:: Display for AlterTriggerOperation {
6360+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6361+ match self {
6362+ AlterTriggerOperation :: RenameTo { new_name } => write ! ( f, "RENAME TO {new_name}" ) ,
6363+ }
6364+ }
6365+ }
6366+
6367+ impl From < AlterTrigger > for crate :: ast:: Statement {
6368+ fn from ( a : AlterTrigger ) -> Self {
6369+ crate :: ast:: Statement :: AlterTrigger ( a)
6370+ }
6371+ }
6372+
6373+ /// `ALTER EXTENSION` statement.
6374+ ///
6375+ /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-alterextension.html)
6376+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6377+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6378+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6379+ pub struct AlterExtension {
6380+ /// Name of the extension being altered.
6381+ pub name : Ident ,
6382+ /// The operation to perform.
6383+ pub operation : AlterExtensionOperation ,
6384+ }
6385+
6386+ /// An [AlterExtension] operation.
6387+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6388+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6389+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6390+ pub enum AlterExtensionOperation {
6391+ /// `UPDATE [ TO new_version ]`
6392+ UpdateTo {
6393+ /// Optional target version string or identifier.
6394+ version : Option < Ident > ,
6395+ } ,
6396+ /// `SET SCHEMA schema_name`
6397+ SetSchema {
6398+ /// The target schema name.
6399+ schema_name : ObjectName ,
6400+ } ,
6401+ /// `OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }`
6402+ OwnerTo ( Owner ) ,
6403+ /// `RENAME TO new_name`
6404+ RenameTo {
6405+ /// New name for the extension.
6406+ new_name : Ident ,
6407+ } ,
6408+ }
6409+
6410+ impl fmt:: Display for AlterExtension {
6411+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6412+ write ! ( f, "ALTER EXTENSION {} {}" , self . name, self . operation)
6413+ }
6414+ }
6415+
6416+ impl fmt:: Display for AlterExtensionOperation {
6417+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6418+ match self {
6419+ AlterExtensionOperation :: UpdateTo { version } => {
6420+ write ! ( f, "UPDATE" ) ?;
6421+ if let Some ( v) = version {
6422+ write ! ( f, " TO {v}" ) ?;
6423+ }
6424+ Ok ( ( ) )
6425+ }
6426+ AlterExtensionOperation :: SetSchema { schema_name } => {
6427+ write ! ( f, "SET SCHEMA {schema_name}" )
6428+ }
6429+ AlterExtensionOperation :: OwnerTo ( owner) => write ! ( f, "OWNER TO {owner}" ) ,
6430+ AlterExtensionOperation :: RenameTo { new_name } => write ! ( f, "RENAME TO {new_name}" ) ,
6431+ }
6432+ }
6433+ }
6434+
6435+ impl From < AlterExtension > for crate :: ast:: Statement {
6436+ fn from ( a : AlterExtension ) -> Self {
6437+ crate :: ast:: Statement :: AlterExtension ( a)
6438+ }
6439+ }
6440+
61736441/// A `CREATE PUBLICATION` statement.
61746442///
61756443/// Note: this is a PostgreSQL-specific statement.
0 commit comments