|
| 1 | +<!-- |
| 2 | +$PostgreSQL: pgsql/doc/src/sgml/ref/alter_opfamily.sgml,v 1.1 2007/01/23 05:07:17 tgl Exp $ |
| 3 | +PostgreSQL documentation |
| 4 | +--> |
| 5 | + |
| 6 | +<refentry id="SQL-ALTEROPFAMILY"> |
| 7 | + <refmeta> |
| 8 | + <refentrytitle id="SQL-ALTEROPFAMILY-TITLE">ALTER OPERATOR FAMILY</refentrytitle> |
| 9 | + <refmiscinfo>SQL - Language Statements</refmiscinfo> |
| 10 | + </refmeta> |
| 11 | + |
| 12 | + <refnamediv> |
| 13 | + <refname>ALTER OPERATOR FAMILY</refname> |
| 14 | + <refpurpose>change the definition of an operator family</refpurpose> |
| 15 | + </refnamediv> |
| 16 | + |
| 17 | + <indexterm zone="sql-alteropfamily"> |
| 18 | + <primary>ALTER OPERATOR FAMILY</primary> |
| 19 | + </indexterm> |
| 20 | + |
| 21 | + <refsynopsisdiv> |
| 22 | +<synopsis> |
| 23 | +ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable> ADD |
| 24 | + { OPERATOR <replaceable class="parameter">strategy_number</replaceable> <replaceable class="parameter">operator_name</replaceable> ( <replaceable class="parameter">op_type</replaceable>, <replaceable class="parameter">op_type</replaceable> ) [ RECHECK ] |
| 25 | + | FUNCTION <replaceable class="parameter">support_number</replaceable> [ ( <replaceable class="parameter">op_type</replaceable> [ , <replaceable class="parameter">op_type</replaceable> ] ) ] <replaceable class="parameter">funcname</replaceable> ( <replaceable class="parameter">argument_type</replaceable> [, ...] ) |
| 26 | + } [, ... ] |
| 27 | +ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable> DROP |
| 28 | + { OPERATOR <replaceable class="parameter">strategy_number</replaceable> ( <replaceable class="parameter">op_type</replaceable> [ , <replaceable class="parameter">op_type</replaceable> ] ) |
| 29 | + | FUNCTION <replaceable class="parameter">support_number</replaceable> ( <replaceable class="parameter">op_type</replaceable> [ , <replaceable class="parameter">op_type</replaceable> ] ) |
| 30 | + } [, ... ] |
| 31 | +ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable> RENAME TO <replaceable>newname</replaceable> |
| 32 | +ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable> OWNER TO <replaceable>newowner</replaceable> |
| 33 | +</synopsis> |
| 34 | + </refsynopsisdiv> |
| 35 | + |
| 36 | + <refsect1> |
| 37 | + <title>Description</title> |
| 38 | + |
| 39 | + <para> |
| 40 | + <command>ALTER OPERATOR FAMILY</command> changes the definition of |
| 41 | + an operator family. You can add operators and support functions |
| 42 | + to the family, remove them from the family, |
| 43 | + or change the family's name or owner. |
| 44 | + </para> |
| 45 | + |
| 46 | + <para> |
| 47 | + When operators and support functions are added to a family with |
| 48 | + <command>ALTER OPERATOR FAMILY</command>, they are not part of any |
| 49 | + specific operator class within the family, but are just <quote>loose</> |
| 50 | + within the family. This indicates that these operators and functions |
| 51 | + are compatible with the family's semantics, but are not required for |
| 52 | + correct functioning of any specific index. (Operators and functions |
| 53 | + that are so required should be declared as part of an operator class, |
| 54 | + instead; see <xref linkend="sql-createopclass" |
| 55 | + endterm="sql-createopclass-title">.) |
| 56 | + <productname>PostgreSQL</productname> will allow loose members of a |
| 57 | + family to be dropped from the family at any time, but members of an |
| 58 | + operator class cannot be dropped without dropping the whole class and |
| 59 | + any indexes that depend on it. |
| 60 | + Typically, single-data-type operators |
| 61 | + and functions are part of operator classes because they are needed to |
| 62 | + support an index on that specific data type, while cross-data-type |
| 63 | + operators and functions are made loose members of the family. |
| 64 | + </para> |
| 65 | + |
| 66 | + <para> |
| 67 | + You must be a superuser to use <command>ALTER OPERATOR FAMILY</>. |
| 68 | + </para> |
| 69 | + </refsect1> |
| 70 | + |
| 71 | + <refsect1> |
| 72 | + <title>Parameters</title> |
| 73 | + |
| 74 | + <variablelist> |
| 75 | + <varlistentry> |
| 76 | + <term><replaceable class="parameter">name</replaceable></term> |
| 77 | + <listitem> |
| 78 | + <para> |
| 79 | + The name (optionally schema-qualified) of an existing operator |
| 80 | + family. |
| 81 | + </para> |
| 82 | + </listitem> |
| 83 | + </varlistentry> |
| 84 | + |
| 85 | + <varlistentry> |
| 86 | + <term><replaceable class="parameter">index_method</replaceable></term> |
| 87 | + <listitem> |
| 88 | + <para> |
| 89 | + The name of the index method this operator family is for. |
| 90 | + </para> |
| 91 | + </listitem> |
| 92 | + </varlistentry> |
| 93 | + |
| 94 | + <varlistentry> |
| 95 | + <term><replaceable class="parameter">strategy_number</replaceable></term> |
| 96 | + <listitem> |
| 97 | + <para> |
| 98 | + The index method's strategy number for an operator |
| 99 | + associated with the operator family. |
| 100 | + </para> |
| 101 | + </listitem> |
| 102 | + </varlistentry> |
| 103 | + |
| 104 | + <varlistentry> |
| 105 | + <term><replaceable class="parameter">operator_name</replaceable></term> |
| 106 | + <listitem> |
| 107 | + <para> |
| 108 | + The name (optionally schema-qualified) of an operator associated |
| 109 | + with the operator family. |
| 110 | + </para> |
| 111 | + </listitem> |
| 112 | + </varlistentry> |
| 113 | + |
| 114 | + <varlistentry> |
| 115 | + <term><replaceable class="parameter">op_type</replaceable></term> |
| 116 | + <listitem> |
| 117 | + <para> |
| 118 | + In an <literal>OPERATOR</> clause, |
| 119 | + the operand data type(s) of the operator, or <literal>NONE</> to |
| 120 | + signify a left-unary or right-unary operator. Unlike the comparable |
| 121 | + syntax in <command>CREATE OPERATOR CLASS</>, the operand data types |
| 122 | + must always be specified. |
| 123 | + </para> |
| 124 | + |
| 125 | + <para> |
| 126 | + In an <literal>ADD FUNCTION</> clause, the operand data type(s) the |
| 127 | + function is intended to support, if different from |
| 128 | + the input data type(s) of the function. For B-tree and hash indexes |
| 129 | + it is not necessary to specify <replaceable |
| 130 | + class="parameter">op_type</replaceable> since the function's input |
| 131 | + data type(s) are always the correct ones to use. For GIN and GiST |
| 132 | + indexes it is necessary to specify the input data type the function |
| 133 | + is to be used with. |
| 134 | + </para> |
| 135 | + |
| 136 | + <para> |
| 137 | + In a <literal>DROP FUNCTION</> clause, the operand data type(s) the |
| 138 | + function is intended to support must be specified. |
| 139 | + </para> |
| 140 | + </listitem> |
| 141 | + </varlistentry> |
| 142 | + |
| 143 | + <varlistentry> |
| 144 | + <term><literal>RECHECK</></term> |
| 145 | + <listitem> |
| 146 | + <para> |
| 147 | + If present, the index is <quote>lossy</> for this operator, and |
| 148 | + so the rows retrieved using the index must be rechecked to |
| 149 | + verify that they actually satisfy the qualification clause |
| 150 | + involving this operator. |
| 151 | + </para> |
| 152 | + </listitem> |
| 153 | + </varlistentry> |
| 154 | + |
| 155 | + <varlistentry> |
| 156 | + <term><replaceable class="parameter">support_number</replaceable></term> |
| 157 | + <listitem> |
| 158 | + <para> |
| 159 | + The index method's support procedure number for a |
| 160 | + function associated with the operator family. |
| 161 | + </para> |
| 162 | + </listitem> |
| 163 | + </varlistentry> |
| 164 | + |
| 165 | + <varlistentry> |
| 166 | + <term><replaceable class="parameter">funcname</replaceable></term> |
| 167 | + <listitem> |
| 168 | + <para> |
| 169 | + The name (optionally schema-qualified) of a function that is an |
| 170 | + index method support procedure for the operator family. |
| 171 | + </para> |
| 172 | + </listitem> |
| 173 | + </varlistentry> |
| 174 | + |
| 175 | + <varlistentry> |
| 176 | + <term><replaceable class="parameter">argument_types</replaceable></term> |
| 177 | + <listitem> |
| 178 | + <para> |
| 179 | + The parameter data type(s) of the function. |
| 180 | + </para> |
| 181 | + </listitem> |
| 182 | + </varlistentry> |
| 183 | + |
| 184 | + <varlistentry> |
| 185 | + <term><replaceable class="parameter">newname</replaceable></term> |
| 186 | + <listitem> |
| 187 | + <para> |
| 188 | + The new name of the operator family. |
| 189 | + </para> |
| 190 | + </listitem> |
| 191 | + </varlistentry> |
| 192 | + |
| 193 | + <varlistentry> |
| 194 | + <term><replaceable class="parameter">newowner</replaceable></term> |
| 195 | + <listitem> |
| 196 | + <para> |
| 197 | + The new owner of the operator family. |
| 198 | + </para> |
| 199 | + </listitem> |
| 200 | + </varlistentry> |
| 201 | + </variablelist> |
| 202 | + |
| 203 | + <para> |
| 204 | + The <literal>OPERATOR</> and <literal>FUNCTION</> |
| 205 | + clauses may appear in any order. |
| 206 | + </para> |
| 207 | + |
| 208 | + </refsect1> |
| 209 | + |
| 210 | + <refsect1> |
| 211 | + <title>Notes</title> |
| 212 | + |
| 213 | + <para> |
| 214 | + Notice that the <literal>DROP</> syntax only specifies the <quote>slot</> |
| 215 | + in the operator family, by strategy or support number and input data |
| 216 | + type(s). The name of the operator or function occupying the slot is not |
| 217 | + mentioned. Also, for <literal>DROP FUNCTION</> the type(s) to specify |
| 218 | + are the input data type(s) the function is intended to support; for |
| 219 | + GIN and GiST indexes this may have nothing to do with the actual input |
| 220 | + argument types of the function. |
| 221 | + </para> |
| 222 | + |
| 223 | + <para> |
| 224 | + Because the index machinery does not check access permissions on functions |
| 225 | + before using them, including a function or operator in an operator family |
| 226 | + is tantamount to granting public execute permission on it. This is usually |
| 227 | + not an issue for the sorts of functions that are useful in an operator |
| 228 | + family. |
| 229 | + </para> |
| 230 | + |
| 231 | + <para> |
| 232 | + The operators should not be defined by SQL functions. A SQL function |
| 233 | + is likely to be inlined into the calling query, which will prevent |
| 234 | + the optimizer from recognizing that the query matches an index. |
| 235 | + </para> |
| 236 | + </refsect1> |
| 237 | + |
| 238 | + <refsect1> |
| 239 | + <title>Examples</title> |
| 240 | + |
| 241 | + <para> |
| 242 | + The following example command adds cross-data-type operators and |
| 243 | + support functions to an operator family that already contains B-tree |
| 244 | + operator classes for data types <type>int4</> and <type>int2</>. |
| 245 | + </para> |
| 246 | + |
| 247 | +<programlisting> |
| 248 | +ALTER OPERATOR FAMILY integer_ops USING btree ADD |
| 249 | + |
| 250 | + -- int4 vs int2 |
| 251 | + OPERATOR 1 < (int4, int2) , |
| 252 | + OPERATOR 2 <= (int4, int2) , |
| 253 | + OPERATOR 3 = (int4, int2) , |
| 254 | + OPERATOR 4 >= (int4, int2) , |
| 255 | + OPERATOR 5 > (int4, int2) , |
| 256 | + FUNCTION 1 btint42cmp(int4, int2) , |
| 257 | + |
| 258 | + -- int2 vs int4 |
| 259 | + OPERATOR 1 < (int2, int4) , |
| 260 | + OPERATOR 2 <= (int2, int4) , |
| 261 | + OPERATOR 3 = (int2, int4) , |
| 262 | + OPERATOR 4 >= (int2, int4) , |
| 263 | + OPERATOR 5 > (int2, int4) , |
| 264 | + FUNCTION 1 btint24cmp(int2, int4) ; |
| 265 | +</programlisting> |
| 266 | + |
| 267 | + <para> |
| 268 | + To remove these entries again: |
| 269 | + </para> |
| 270 | + |
| 271 | +<programlisting> |
| 272 | +ALTER OPERATOR FAMILY integer_ops USING btree DROP |
| 273 | + |
| 274 | + -- int4 vs int2 |
| 275 | + OPERATOR 1 (int4, int2) , |
| 276 | + OPERATOR 2 (int4, int2) , |
| 277 | + OPERATOR 3 (int4, int2) , |
| 278 | + OPERATOR 4 (int4, int2) , |
| 279 | + OPERATOR 5 (int4, int2) , |
| 280 | + FUNCTION 1 (int4, int2) , |
| 281 | + |
| 282 | + -- int2 vs int4 |
| 283 | + OPERATOR 1 (int2, int4) , |
| 284 | + OPERATOR 2 (int2, int4) , |
| 285 | + OPERATOR 3 (int2, int4) , |
| 286 | + OPERATOR 4 (int2, int4) , |
| 287 | + OPERATOR 5 (int2, int4) , |
| 288 | + FUNCTION 1 (int2, int4) ; |
| 289 | +</programlisting> |
| 290 | + </refsect1> |
| 291 | + |
| 292 | + <refsect1> |
| 293 | + <title>Compatibility</title> |
| 294 | + |
| 295 | + <para> |
| 296 | + There is no <command>ALTER OPERATOR FAMILY</command> statement in |
| 297 | + the SQL standard. |
| 298 | + </para> |
| 299 | + </refsect1> |
| 300 | + |
| 301 | + <refsect1> |
| 302 | + <title>See Also</title> |
| 303 | + |
| 304 | + <simplelist type="inline"> |
| 305 | + <member><xref linkend="sql-createopfamily" endterm="sql-createopfamily-title"></member> |
| 306 | + <member><xref linkend="sql-dropopfamily" endterm="sql-dropopfamily-title"></member> |
| 307 | + <member><xref linkend="sql-createopclass" endterm="sql-createopclass-title"></member> |
| 308 | + <member><xref linkend="sql-alteropclass" endterm="sql-alteropclass-title"></member> |
| 309 | + <member><xref linkend="sql-dropopclass" endterm="sql-dropopclass-title"></member> |
| 310 | + </simplelist> |
| 311 | + </refsect1> |
| 312 | +</refentry> |
0 commit comments