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