]> begriffs open source - ai-pg/blob - full-docs/txt/sql-alteropfamily.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-alteropfamily.txt
1
2 ALTER OPERATOR FAMILY
3
4    ALTER OPERATOR FAMILY — change the definition of an operator family
5
6 Synopsis
7
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 [, ...] ) ]
13   } [, ... ]
14
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 ] )
18   } [, ... ]
19
20 ALTER OPERATOR FAMILY name USING index_method
21     RENAME TO new_name
22
23 ALTER OPERATOR FAMILY name USING index_method
24     OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
25
26 ALTER OPERATOR FAMILY name USING index_method
27     SET SCHEMA new_schema
28
29 Description
30
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.
34
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.
49
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.)
53
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
58    operator family.
59
60    Refer to Section 36.16 for further information.
61
62 Parameters
63
64    name
65           The name (optionally schema-qualified) of an existing operator
66           family.
67
68    index_method
69           The name of the index method this operator family is for.
70
71    strategy_number
72           The index method's strategy number for an operator associated
73           with the operator family.
74
75    operator_name
76           The name (optionally schema-qualified) of an operator associated
77           with the operator family.
78
79    op_type
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
83           always be specified.
84
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.
94
95           In a DROP FUNCTION clause, the operand data type(s) the function
96           is intended to support must be specified.
97
98    sort_family_name
99           The name (optionally schema-qualified) of an existing btree
100           operator family that describes the sort ordering associated with
101           an ordering operator.
102
103           If neither FOR SEARCH nor FOR ORDER BY is specified, FOR SEARCH
104           is the default.
105
106    support_number
107           The index method's support function number for a function
108           associated with the operator family.
109
110    function_name
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
114           schema.
115
116    argument_type
117           The parameter data type(s) of the function.
118
119    new_name
120           The new name of the operator family.
121
122    new_owner
123           The new owner of the operator family.
124
125    new_schema
126           The new schema for the operator family.
127
128    The OPERATOR and FUNCTION clauses can appear in any order.
129
130 Notes
131
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
138    function.
139
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.
145
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.
149
150 Examples
151
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
156
157   -- int4 vs int2
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) ,
164
165   -- int2 vs int4
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) ;
172
173    To remove these entries again:
174 ALTER OPERATOR FAMILY integer_ops USING btree DROP
175
176   -- int4 vs int2
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) ,
183
184   -- int2 vs int4
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) ;
191
192 Compatibility
193
194    There is no ALTER OPERATOR FAMILY statement in the SQL standard.
195
196 See Also
197
198    CREATE OPERATOR FAMILY, DROP OPERATOR FAMILY, CREATE OPERATOR CLASS,
199    ALTER OPERATOR CLASS, DROP OPERATOR CLASS