4 ALTER OPERATOR FAMILY — change the definition of an operator family
8 ALTER OPERATOR FAMILY name USING index_method ADD
9 { OPERATOR strategy_number operator_name ( op_type, op_type )
10 [ FOR SEARCH | FOR ORDER BY sort_family_name ]
11 | FUNCTION support_number [ ( op_type [ , op_type ] ) ]
12 function_name [ ( argument_type [, ...] ) ]
15 ALTER OPERATOR FAMILY name USING index_method DROP
16 { OPERATOR strategy_number ( op_type [ , op_type ] )
17 | FUNCTION support_number ( op_type [ , op_type ] )
20 ALTER OPERATOR FAMILY name USING index_method
23 ALTER OPERATOR FAMILY name USING index_method
24 OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
26 ALTER OPERATOR FAMILY name USING index_method
31 ALTER OPERATOR FAMILY changes the definition of an operator family. You
32 can add operators and support functions to the family, remove them from
33 the family, or change the family's name or owner.
35 When operators and support functions are added to a family with ALTER
36 OPERATOR FAMILY, they are not part of any specific operator class
37 within the family, but are just “loose” within the family. This
38 indicates that these operators and functions are compatible with the
39 family's semantics, but are not required for correct functioning of any
40 specific index. (Operators and functions that are so required should be
41 declared as part of an operator class, instead; see CREATE OPERATOR
42 CLASS.) PostgreSQL will allow loose members of a family to be dropped
43 from the family at any time, but members of an operator class cannot be
44 dropped without dropping the whole class and any indexes that depend on
45 it. Typically, single-data-type operators and functions are part of
46 operator classes because they are needed to support an index on that
47 specific data type, while cross-data-type operators and functions are
48 made loose members of the family.
50 You must be a superuser to use ALTER OPERATOR FAMILY. (This restriction
51 is made because an erroneous operator family definition could confuse
52 or even crash the server.)
54 ALTER OPERATOR FAMILY does not presently check whether the operator
55 family definition includes all the operators and functions required by
56 the index method, nor whether the operators and functions form a
57 self-consistent set. It is the user's responsibility to define a valid
60 Refer to Section 36.16 for further information.
65 The name (optionally schema-qualified) of an existing operator
69 The name of the index method this operator family is for.
72 The index method's strategy number for an operator associated
73 with the operator family.
76 The name (optionally schema-qualified) of an operator associated
77 with the operator family.
80 In an OPERATOR clause, the operand data type(s) of the operator,
81 or NONE to signify a prefix operator. Unlike the comparable
82 syntax in CREATE OPERATOR CLASS, the operand data types must
85 In an ADD FUNCTION clause, the operand data type(s) the function
86 is intended to support, if different from the input data type(s)
87 of the function. For B-tree comparison functions and hash
88 functions it is not necessary to specify op_type since the
89 function's input data type(s) are always the correct ones to
90 use. For B-tree sort support functions, B-Tree equal image
91 functions, and all functions in GiST, SP-GiST and GIN operator
92 classes, it is necessary to specify the operand data type(s) the
93 function is to be used with.
95 In a DROP FUNCTION clause, the operand data type(s) the function
96 is intended to support must be specified.
99 The name (optionally schema-qualified) of an existing btree
100 operator family that describes the sort ordering associated with
101 an ordering operator.
103 If neither FOR SEARCH nor FOR ORDER BY is specified, FOR SEARCH
107 The index method's support function number for a function
108 associated with the operator family.
111 The name (optionally schema-qualified) of a function that is an
112 index method support function for the operator family. If no
113 argument list is specified, the name must be unique in its
117 The parameter data type(s) of the function.
120 The new name of the operator family.
123 The new owner of the operator family.
126 The new schema for the operator family.
128 The OPERATOR and FUNCTION clauses can appear in any order.
132 Notice that the DROP syntax only specifies the “slot” in the operator
133 family, by strategy or support number and input data type(s). The name
134 of the operator or function occupying the slot is not mentioned. Also,
135 for DROP FUNCTION the type(s) to specify are the input data type(s) the
136 function is intended to support; for GiST, SP-GiST and GIN indexes this
137 might have nothing to do with the actual input argument types of the
140 Because the index machinery does not check access permissions on
141 functions before using them, including a function or operator in an
142 operator family is tantamount to granting public execute permission on
143 it. This is usually not an issue for the sorts of functions that are
144 useful in an operator family.
146 The operators should not be defined by SQL functions. An SQL function
147 is likely to be inlined into the calling query, which will prevent the
148 optimizer from recognizing that the query matches an index.
152 The following example command adds cross-data-type operators and
153 support functions to an operator family that already contains B-tree
154 operator classes for data types int4 and int2.
155 ALTER OPERATOR FAMILY integer_ops USING btree ADD
158 OPERATOR 1 < (int4, int2) ,
159 OPERATOR 2 <= (int4, int2) ,
160 OPERATOR 3 = (int4, int2) ,
161 OPERATOR 4 >= (int4, int2) ,
162 OPERATOR 5 > (int4, int2) ,
163 FUNCTION 1 btint42cmp(int4, int2) ,
166 OPERATOR 1 < (int2, int4) ,
167 OPERATOR 2 <= (int2, int4) ,
168 OPERATOR 3 = (int2, int4) ,
169 OPERATOR 4 >= (int2, int4) ,
170 OPERATOR 5 > (int2, int4) ,
171 FUNCTION 1 btint24cmp(int2, int4) ;
173 To remove these entries again:
174 ALTER OPERATOR FAMILY integer_ops USING btree DROP
177 OPERATOR 1 (int4, int2) ,
178 OPERATOR 2 (int4, int2) ,
179 OPERATOR 3 (int4, int2) ,
180 OPERATOR 4 (int4, int2) ,
181 OPERATOR 5 (int4, int2) ,
182 FUNCTION 1 (int4, int2) ,
185 OPERATOR 1 (int2, int4) ,
186 OPERATOR 2 (int2, int4) ,
187 OPERATOR 3 (int2, int4) ,
188 OPERATOR 4 (int2, int4) ,
189 OPERATOR 5 (int2, int4) ,
190 FUNCTION 1 (int2, int4) ;
194 There is no ALTER OPERATOR FAMILY statement in the SQL standard.
198 CREATE OPERATOR FAMILY, DROP OPERATOR FAMILY, CREATE OPERATOR CLASS,
199 ALTER OPERATOR CLASS, DROP OPERATOR CLASS