@@ -4301,25 +4301,25 @@ impl fmt::Display for OperatorArgTypes {
43014301#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
43024302#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
43034303pub enum OperatorClassItem {
4304- /// OPERATOR clause
4304+ /// ` OPERATOR` clause
43054305 Operator {
4306- strategy_number : u32 ,
4306+ strategy_number : u64 ,
43074307 operator_name : ObjectName ,
43084308 /// Optional operator argument types
43094309 op_types : Option < OperatorArgTypes > ,
4310- /// FOR SEARCH or FOR ORDER BY
4310+ /// ` FOR SEARCH` or ` FOR ORDER BY`
43114311 purpose : Option < OperatorPurpose > ,
43124312 } ,
4313- /// FUNCTION clause
4313+ /// ` FUNCTION` clause
43144314 Function {
4315- support_number : u32 ,
4315+ support_number : u64 ,
43164316 /// Optional function argument types for the operator class
43174317 op_types : Option < Vec < DataType > > ,
43184318 function_name : ObjectName ,
43194319 /// Function argument types
43204320 argument_types : Vec < DataType > ,
43214321 } ,
4322- /// STORAGE clause
4322+ /// ` STORAGE` clause
43234323 Storage { storage_type : DataType } ,
43244324}
43254325
@@ -4516,3 +4516,189 @@ impl Spanned for DropOperatorClass {
45164516 Span :: empty ( )
45174517 }
45184518}
4519+
4520+ /// An item in an ALTER OPERATOR FAMILY ADD statement
4521+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4522+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4523+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4524+ pub enum OperatorFamilyItem {
4525+ /// `OPERATOR` clause
4526+ Operator {
4527+ strategy_number : u64 ,
4528+ operator_name : ObjectName ,
4529+ /// Operator argument types
4530+ op_types : Vec < DataType > ,
4531+ /// `FOR SEARCH` or `FOR ORDER BY`
4532+ purpose : Option < OperatorPurpose > ,
4533+ } ,
4534+ /// `FUNCTION` clause
4535+ Function {
4536+ support_number : u64 ,
4537+ /// Optional operator argument types for the function
4538+ op_types : Option < Vec < DataType > > ,
4539+ function_name : ObjectName ,
4540+ /// Function argument types
4541+ argument_types : Vec < DataType > ,
4542+ } ,
4543+ }
4544+
4545+ /// An item in an ALTER OPERATOR FAMILY DROP statement
4546+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4547+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4548+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4549+ pub enum OperatorFamilyDropItem {
4550+ /// `OPERATOR` clause
4551+ Operator {
4552+ strategy_number : u64 ,
4553+ /// Operator argument types
4554+ op_types : Vec < DataType > ,
4555+ } ,
4556+ /// `FUNCTION` clause
4557+ Function {
4558+ support_number : u64 ,
4559+ /// Operator argument types for the function
4560+ op_types : Vec < DataType > ,
4561+ } ,
4562+ }
4563+
4564+ impl fmt:: Display for OperatorFamilyItem {
4565+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4566+ match self {
4567+ OperatorFamilyItem :: Operator {
4568+ strategy_number,
4569+ operator_name,
4570+ op_types,
4571+ purpose,
4572+ } => {
4573+ write ! (
4574+ f,
4575+ "OPERATOR {strategy_number} {operator_name} ({})" ,
4576+ display_comma_separated( op_types)
4577+ ) ?;
4578+ if let Some ( purpose) = purpose {
4579+ write ! ( f, " {purpose}" ) ?;
4580+ }
4581+ Ok ( ( ) )
4582+ }
4583+ OperatorFamilyItem :: Function {
4584+ support_number,
4585+ op_types,
4586+ function_name,
4587+ argument_types,
4588+ } => {
4589+ write ! ( f, "FUNCTION {support_number}" ) ?;
4590+ if let Some ( types) = op_types {
4591+ write ! ( f, " ({})" , display_comma_separated( types) ) ?;
4592+ }
4593+ write ! ( f, " {function_name}" ) ?;
4594+ if !argument_types. is_empty ( ) {
4595+ write ! ( f, "({})" , display_comma_separated( argument_types) ) ?;
4596+ }
4597+ Ok ( ( ) )
4598+ }
4599+ }
4600+ }
4601+ }
4602+
4603+ impl fmt:: Display for OperatorFamilyDropItem {
4604+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4605+ match self {
4606+ OperatorFamilyDropItem :: Operator {
4607+ strategy_number,
4608+ op_types,
4609+ } => {
4610+ write ! (
4611+ f,
4612+ "OPERATOR {strategy_number} ({})" ,
4613+ display_comma_separated( op_types)
4614+ )
4615+ }
4616+ OperatorFamilyDropItem :: Function {
4617+ support_number,
4618+ op_types,
4619+ } => {
4620+ write ! (
4621+ f,
4622+ "FUNCTION {support_number} ({})" ,
4623+ display_comma_separated( op_types)
4624+ )
4625+ }
4626+ }
4627+ }
4628+ }
4629+
4630+ /// `ALTER OPERATOR FAMILY` statement
4631+ /// See <https://www.postgresql.org/docs/current/sql-alteropfamily.html>
4632+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4633+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4634+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4635+ pub struct AlterOperatorFamily {
4636+ /// Operator family name (can be schema-qualified)
4637+ pub name : ObjectName ,
4638+ /// Index method (btree, hash, gist, gin, etc.)
4639+ pub using : Ident ,
4640+ /// The operation to perform
4641+ pub operation : AlterOperatorFamilyOperation ,
4642+ }
4643+
4644+ /// An [AlterOperatorFamily] operation
4645+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4646+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4647+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4648+ pub enum AlterOperatorFamilyOperation {
4649+ /// `ADD { OPERATOR ... | FUNCTION ... } [, ...]`
4650+ Add {
4651+ /// List of operator family items to add
4652+ items : Vec < OperatorFamilyItem > ,
4653+ } ,
4654+ /// `DROP { OPERATOR ... | FUNCTION ... } [, ...]`
4655+ Drop {
4656+ /// List of operator family items to drop
4657+ items : Vec < OperatorFamilyDropItem > ,
4658+ } ,
4659+ /// `RENAME TO new_name`
4660+ RenameTo { new_name : ObjectName } ,
4661+ /// `OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }`
4662+ OwnerTo ( Owner ) ,
4663+ /// `SET SCHEMA new_schema`
4664+ SetSchema { schema_name : ObjectName } ,
4665+ }
4666+
4667+ impl fmt:: Display for AlterOperatorFamily {
4668+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4669+ write ! (
4670+ f,
4671+ "ALTER OPERATOR FAMILY {} USING {}" ,
4672+ self . name, self . using
4673+ ) ?;
4674+ write ! ( f, " {}" , self . operation)
4675+ }
4676+ }
4677+
4678+ impl fmt:: Display for AlterOperatorFamilyOperation {
4679+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4680+ match self {
4681+ AlterOperatorFamilyOperation :: Add { items } => {
4682+ write ! ( f, "ADD {}" , display_comma_separated( items) )
4683+ }
4684+ AlterOperatorFamilyOperation :: Drop { items } => {
4685+ write ! ( f, "DROP {}" , display_comma_separated( items) )
4686+ }
4687+ AlterOperatorFamilyOperation :: RenameTo { new_name } => {
4688+ write ! ( f, "RENAME TO {new_name}" )
4689+ }
4690+ AlterOperatorFamilyOperation :: OwnerTo ( owner) => {
4691+ write ! ( f, "OWNER TO {owner}" )
4692+ }
4693+ AlterOperatorFamilyOperation :: SetSchema { schema_name } => {
4694+ write ! ( f, "SET SCHEMA {schema_name}" )
4695+ }
4696+ }
4697+ }
4698+ }
4699+
4700+ impl Spanned for AlterOperatorFamily {
4701+ fn span ( & self ) -> Span {
4702+ Span :: empty ( )
4703+ }
4704+ }
0 commit comments