@@ -4198,25 +4198,25 @@ impl fmt::Display for OperatorArgTypes {
41984198#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
41994199#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
42004200pub enum OperatorClassItem {
4201- /// OPERATOR clause
4201+ /// ` OPERATOR` clause
42024202 Operator {
4203- strategy_number : u32 ,
4203+ strategy_number : u64 ,
42044204 operator_name : ObjectName ,
42054205 /// Optional operator argument types
42064206 op_types : Option < OperatorArgTypes > ,
4207- /// FOR SEARCH or FOR ORDER BY
4207+ /// ` FOR SEARCH` or ` FOR ORDER BY`
42084208 purpose : Option < OperatorPurpose > ,
42094209 } ,
4210- /// FUNCTION clause
4210+ /// ` FUNCTION` clause
42114211 Function {
4212- support_number : u32 ,
4212+ support_number : u64 ,
42134213 /// Optional function argument types for the operator class
42144214 op_types : Option < Vec < DataType > > ,
42154215 function_name : ObjectName ,
42164216 /// Function argument types
42174217 argument_types : Vec < DataType > ,
42184218 } ,
4219- /// STORAGE clause
4219+ /// ` STORAGE` clause
42204220 Storage { storage_type : DataType } ,
42214221}
42224222
@@ -4413,3 +4413,189 @@ impl Spanned for DropOperatorClass {
44134413 Span :: empty ( )
44144414 }
44154415}
4416+
4417+ /// An item in an ALTER OPERATOR FAMILY ADD statement
4418+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4419+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4420+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4421+ pub enum OperatorFamilyItem {
4422+ /// `OPERATOR` clause
4423+ Operator {
4424+ strategy_number : u64 ,
4425+ operator_name : ObjectName ,
4426+ /// Operator argument types
4427+ op_types : Vec < DataType > ,
4428+ /// `FOR SEARCH` or `FOR ORDER BY`
4429+ purpose : Option < OperatorPurpose > ,
4430+ } ,
4431+ /// `FUNCTION` clause
4432+ Function {
4433+ support_number : u64 ,
4434+ /// Optional operator argument types for the function
4435+ op_types : Option < Vec < DataType > > ,
4436+ function_name : ObjectName ,
4437+ /// Function argument types
4438+ argument_types : Vec < DataType > ,
4439+ } ,
4440+ }
4441+
4442+ /// An item in an ALTER OPERATOR FAMILY DROP statement
4443+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4444+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4445+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4446+ pub enum OperatorFamilyDropItem {
4447+ /// `OPERATOR` clause
4448+ Operator {
4449+ strategy_number : u64 ,
4450+ /// Operator argument types
4451+ op_types : Vec < DataType > ,
4452+ } ,
4453+ /// `FUNCTION` clause
4454+ Function {
4455+ support_number : u64 ,
4456+ /// Operator argument types for the function
4457+ op_types : Vec < DataType > ,
4458+ } ,
4459+ }
4460+
4461+ impl fmt:: Display for OperatorFamilyItem {
4462+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4463+ match self {
4464+ OperatorFamilyItem :: Operator {
4465+ strategy_number,
4466+ operator_name,
4467+ op_types,
4468+ purpose,
4469+ } => {
4470+ write ! (
4471+ f,
4472+ "OPERATOR {strategy_number} {operator_name} ({})" ,
4473+ display_comma_separated( op_types)
4474+ ) ?;
4475+ if let Some ( purpose) = purpose {
4476+ write ! ( f, " {purpose}" ) ?;
4477+ }
4478+ Ok ( ( ) )
4479+ }
4480+ OperatorFamilyItem :: Function {
4481+ support_number,
4482+ op_types,
4483+ function_name,
4484+ argument_types,
4485+ } => {
4486+ write ! ( f, "FUNCTION {support_number}" ) ?;
4487+ if let Some ( types) = op_types {
4488+ write ! ( f, " ({})" , display_comma_separated( types) ) ?;
4489+ }
4490+ write ! ( f, " {function_name}" ) ?;
4491+ if !argument_types. is_empty ( ) {
4492+ write ! ( f, "({})" , display_comma_separated( argument_types) ) ?;
4493+ }
4494+ Ok ( ( ) )
4495+ }
4496+ }
4497+ }
4498+ }
4499+
4500+ impl fmt:: Display for OperatorFamilyDropItem {
4501+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4502+ match self {
4503+ OperatorFamilyDropItem :: Operator {
4504+ strategy_number,
4505+ op_types,
4506+ } => {
4507+ write ! (
4508+ f,
4509+ "OPERATOR {strategy_number} ({})" ,
4510+ display_comma_separated( op_types)
4511+ )
4512+ }
4513+ OperatorFamilyDropItem :: Function {
4514+ support_number,
4515+ op_types,
4516+ } => {
4517+ write ! (
4518+ f,
4519+ "FUNCTION {support_number} ({})" ,
4520+ display_comma_separated( op_types)
4521+ )
4522+ }
4523+ }
4524+ }
4525+ }
4526+
4527+ /// `ALTER OPERATOR FAMILY` statement
4528+ /// See <https://www.postgresql.org/docs/current/sql-alteropfamily.html>
4529+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4530+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4531+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4532+ pub struct AlterOperatorFamily {
4533+ /// Operator family name (can be schema-qualified)
4534+ pub name : ObjectName ,
4535+ /// Index method (btree, hash, gist, gin, etc.)
4536+ pub using : Ident ,
4537+ /// The operation to perform
4538+ pub operation : AlterOperatorFamilyOperation ,
4539+ }
4540+
4541+ /// An [AlterOperatorFamily] operation
4542+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4543+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4544+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4545+ pub enum AlterOperatorFamilyOperation {
4546+ /// `ADD { OPERATOR ... | FUNCTION ... } [, ...]`
4547+ Add {
4548+ /// List of operator family items to add
4549+ items : Vec < OperatorFamilyItem > ,
4550+ } ,
4551+ /// `DROP { OPERATOR ... | FUNCTION ... } [, ...]`
4552+ Drop {
4553+ /// List of operator family items to drop
4554+ items : Vec < OperatorFamilyDropItem > ,
4555+ } ,
4556+ /// `RENAME TO new_name`
4557+ RenameTo { new_name : ObjectName } ,
4558+ /// `OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }`
4559+ OwnerTo ( Owner ) ,
4560+ /// `SET SCHEMA new_schema`
4561+ SetSchema { schema_name : ObjectName } ,
4562+ }
4563+
4564+ impl fmt:: Display for AlterOperatorFamily {
4565+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4566+ write ! (
4567+ f,
4568+ "ALTER OPERATOR FAMILY {} USING {}" ,
4569+ self . name, self . using
4570+ ) ?;
4571+ write ! ( f, " {}" , self . operation)
4572+ }
4573+ }
4574+
4575+ impl fmt:: Display for AlterOperatorFamilyOperation {
4576+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4577+ match self {
4578+ AlterOperatorFamilyOperation :: Add { items } => {
4579+ write ! ( f, "ADD {}" , display_comma_separated( items) )
4580+ }
4581+ AlterOperatorFamilyOperation :: Drop { items } => {
4582+ write ! ( f, "DROP {}" , display_comma_separated( items) )
4583+ }
4584+ AlterOperatorFamilyOperation :: RenameTo { new_name } => {
4585+ write ! ( f, "RENAME TO {new_name}" )
4586+ }
4587+ AlterOperatorFamilyOperation :: OwnerTo ( owner) => {
4588+ write ! ( f, "OWNER TO {owner}" )
4589+ }
4590+ AlterOperatorFamilyOperation :: SetSchema { schema_name } => {
4591+ write ! ( f, "SET SCHEMA {schema_name}" )
4592+ }
4593+ }
4594+ }
4595+ }
4596+
4597+ impl Spanned for AlterOperatorFamily {
4598+ fn span ( & self ) -> Span {
4599+ Span :: empty ( )
4600+ }
4601+ }
0 commit comments