@@ -6535,6 +6535,51 @@ impl fmt::Display for StatisticsKind {
65356535 StatisticsKind :: NDistinct => write ! ( f, "ndistinct" ) ,
65366536 StatisticsKind :: Dependencies => write ! ( f, "dependencies" ) ,
65376537 StatisticsKind :: Mcv => write ! ( f, "mcv" ) ,
6538+ /// The object kind targeted by a `SECURITY LABEL` statement.
6539+ ///
6540+ /// See <https://www.postgresql.org/docs/current/sql-securitylabel.html>
6541+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6542+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6543+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6544+ pub enum SecurityLabelObjectKind {
6545+ /// `TABLE name`
6546+ Table,
6547+ /// `COLUMN name.colname`
6548+ Column,
6549+ /// `DATABASE name`
6550+ Database,
6551+ /// `DOMAIN name`
6552+ Domain,
6553+ /// `FUNCTION name`
6554+ Function,
6555+ /// `ROLE name`
6556+ Role,
6557+ /// `SCHEMA name`
6558+ Schema,
6559+ /// `SEQUENCE name`
6560+ Sequence,
6561+ /// `TYPE name`
6562+ Type,
6563+ /// `VIEW name`
6564+ View,
6565+ /// `MATERIALIZED VIEW name`
6566+ MaterializedView,
6567+ }
6568+
6569+ impl fmt : : Display for SecurityLabelObjectKind {
6570+ fn fmt( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6571+ match self {
6572+ SecurityLabelObjectKind : : Table => write ! ( f, "TABLE" ) ,
6573+ SecurityLabelObjectKind : : Column => write ! ( f, "COLUMN" ) ,
6574+ SecurityLabelObjectKind : : Database => write ! ( f, "DATABASE" ) ,
6575+ SecurityLabelObjectKind : : Domain => write ! ( f, "DOMAIN" ) ,
6576+ SecurityLabelObjectKind : : Function => write ! ( f, "FUNCTION" ) ,
6577+ SecurityLabelObjectKind : : Role => write ! ( f, "ROLE" ) ,
6578+ SecurityLabelObjectKind : : Schema => write ! ( f, "SCHEMA" ) ,
6579+ SecurityLabelObjectKind : : Sequence => write ! ( f, "SEQUENCE" ) ,
6580+ SecurityLabelObjectKind : : Type => write ! ( f, "TYPE" ) ,
6581+ SecurityLabelObjectKind : : View => write ! ( f, "VIEW" ) ,
6582+ SecurityLabelObjectKind : : MaterializedView => write ! ( f, "MATERIALIZED VIEW" ) ,
65386583 }
65396584 }
65406585}
@@ -6571,6 +6616,108 @@ impl fmt::Display for CreateStatistics {
65716616 }
65726617 write!( f, " ON { } ", display_comma_separated( & self . on) ) ?;
65736618 write!( f, " FROM { } ", self. from) ?;
6619+ /// A `SECURITY LABEL` statement.
6620+ ///
6621+ /// Note: this is a PostgreSQL-specific statement.
6622+ /// <https : //www.postgresql.org/docs/current/sql-securitylabel.html>
6623+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6624+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6625+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6626+ pub struct SecurityLabel {
6627+ /// Optional `FOR provider_name` clause.
6628+ pub provider: Option < Ident > ,
6629+ /// The kind of object the label is applied to.
6630+ pub object_kind : SecurityLabelObjectKind ,
6631+ /// The name of the object the label is applied to.
6632+ pub object_name : ObjectName ,
6633+ /// The label string, or `None` for `IS NULL`.
6634+ pub label: Option < Value > ,
6635+ }
6636+
6637+ impl fmt : : Display for SecurityLabel {
6638+ fn fmt( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6639+ write!( f, "SECURITY LABEL" ) ?;
6640+ if let Some ( provider) = & self . provider {
6641+ write!( f, " FOR {provider}" ) ?;
6642+ }
6643+ write!( f, " ON { } { } ", self. object_kind, self. object_name) ?;
6644+ write!( f, " IS ")?;
6645+ match &self.label {
6646+ Some(label) => write!(f, " { label} ") ,
6647+ None => write ! ( f, "NULL" ) ,
6648+ }
6649+ }
6650+ }
6651+
6652+ impl From < SecurityLabel > for crate :: ast:: Statement {
6653+ fn from ( v : SecurityLabel ) -> Self {
6654+ crate :: ast:: Statement :: SecurityLabel ( v)
6655+ }
6656+ }
6657+
6658+ /// The role specification in a `CREATE USER MAPPING` statement.
6659+ ///
6660+ /// See <https://www.postgresql.org/docs/current/sql-createusermapping.html>
6661+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6662+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6663+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6664+ pub enum UserMappingUser {
6665+ /// A specific role name.
6666+ Ident ( Ident ) ,
6667+ /// `USER` (current user)
6668+ User ,
6669+ /// `CURRENT_ROLE`
6670+ CurrentRole ,
6671+ /// `CURRENT_USER`
6672+ CurrentUser ,
6673+ /// `PUBLIC`
6674+ Public ,
6675+ }
6676+
6677+ impl fmt:: Display for UserMappingUser {
6678+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6679+ match self {
6680+ UserMappingUser :: Ident ( ident) => write ! ( f, "{ident}" ) ,
6681+ UserMappingUser :: User => write ! ( f, "USER" ) ,
6682+ UserMappingUser :: CurrentRole => write ! ( f, "CURRENT_ROLE" ) ,
6683+ UserMappingUser :: CurrentUser => write ! ( f, "CURRENT_USER" ) ,
6684+ UserMappingUser :: Public => write ! ( f, "PUBLIC" ) ,
6685+ }
6686+ }
6687+ }
6688+
6689+ /// A `CREATE USER MAPPING` statement.
6690+ ///
6691+ /// Note: this is a PostgreSQL-specific statement.
6692+ /// <https://www.postgresql.org/docs/current/sql-createusermapping.html>
6693+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6694+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6695+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6696+ pub struct CreateUserMapping {
6697+ /// `IF NOT EXISTS`
6698+ pub if_not_exists : bool ,
6699+ /// The user/role for the mapping.
6700+ pub user : UserMappingUser ,
6701+ /// The foreign server name.
6702+ pub server_name : Ident ,
6703+ /// Optional `OPTIONS (key 'value', ...)` clause.
6704+ pub options : Option < Vec < CreateServerOption > > ,
6705+ }
6706+
6707+ impl fmt:: Display for CreateUserMapping {
6708+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6709+ write ! ( f, "CREATE USER MAPPING" ) ?;
6710+ if self . if_not_exists {
6711+ write ! ( f, " IF NOT EXISTS" ) ?;
6712+ }
6713+ write ! ( f, " FOR {} SERVER {}" , self . user, self . server_name) ?;
6714+ if let Some ( options) = & self . options {
6715+ write ! (
6716+ f,
6717+ " OPTIONS ({})" ,
6718+ display_comma_separated( options)
6719+ ) ?;
6720+ }
65746721 Ok ( ( ) )
65756722 }
65766723}
@@ -6699,6 +6846,40 @@ impl fmt::Display for CreateEventTrigger {
66996846 "FUNCTION"
67006847 } ;
67016848 write ! ( f, " EXECUTE {func_kw} {}()" , self . execute) ?;
6849+ impl From < CreateUserMapping > for crate :: ast:: Statement {
6850+ fn from ( v : CreateUserMapping ) -> Self {
6851+ crate :: ast:: Statement :: CreateUserMapping ( v)
6852+ }
6853+ }
6854+
6855+ /// A `CREATE TABLESPACE` statement.
6856+ ///
6857+ /// Note: this is a PostgreSQL-specific statement.
6858+ /// <https://www.postgresql.org/docs/current/sql-createtablespace.html>
6859+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
6860+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
6861+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
6862+ pub struct CreateTablespace {
6863+ /// The tablespace name.
6864+ pub name : Ident ,
6865+ /// Optional `OWNER role` clause.
6866+ pub owner : Option < Ident > ,
6867+ /// The `LOCATION 'directory'` string.
6868+ pub location : Value ,
6869+ /// Optional `WITH (option = value, ...)` clause.
6870+ pub with_options : Vec < SqlOption > ,
6871+ }
6872+
6873+ impl fmt:: Display for CreateTablespace {
6874+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6875+ write ! ( f, "CREATE TABLESPACE {}" , self . name) ?;
6876+ if let Some ( owner) = & self . owner {
6877+ write ! ( f, " OWNER {owner}" ) ?;
6878+ }
6879+ write ! ( f, " LOCATION {}" , self . location) ?;
6880+ if !self . with_options . is_empty ( ) {
6881+ write ! ( f, " WITH ({})" , display_comma_separated( & self . with_options) ) ?;
6882+ }
67026883 Ok ( ( ) )
67036884 }
67046885}
@@ -6776,5 +6957,8 @@ impl fmt::Display for CreateTransform {
67766957impl From < CreateTransform > for crate :: ast:: Statement {
67776958 fn from( v : CreateTransform ) -> Self {
67786959 crate :: ast:: Statement :: CreateTransform ( v)
6960+ impl From < CreateTablespace > for crate :: ast:: Statement {
6961+ fn from ( v : CreateTablespace ) -> Self {
6962+ crate :: ast:: Statement :: CreateTablespace ( v)
67796963 }
67806964}
0 commit comments