]> begriffs open source - ai-pg/blob - full-docs/txt/sql-alteroperator.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-alteroperator.txt
1
2 ALTER OPERATOR
3
4    ALTER OPERATOR — change the definition of an operator
5
6 Synopsis
7
8 ALTER OPERATOR name ( { left_type | NONE } , right_type )
9     OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
10
11 ALTER OPERATOR name ( { left_type | NONE } , right_type )
12     SET SCHEMA new_schema
13
14 ALTER OPERATOR name ( { left_type | NONE } , right_type )
15     SET ( {  RESTRICT = { res_proc | NONE }
16            | JOIN = { join_proc | NONE }
17            | COMMUTATOR = com_op
18            | NEGATOR = neg_op
19            | HASHES
20            | MERGES
21           } [, ... ] )
22
23 Description
24
25    ALTER OPERATOR changes the definition of an operator.
26
27    You must own the operator to use ALTER OPERATOR. To alter the owner,
28    you must be able to SET ROLE to the new owning role, and that role must
29    have CREATE privilege on the operator's schema. (These restrictions
30    enforce that altering the owner doesn't do anything you couldn't do by
31    dropping and recreating the operator. However, a superuser can alter
32    ownership of any operator anyway.)
33
34 Parameters
35
36    name
37           The name (optionally schema-qualified) of an existing operator.
38
39    left_type
40           The data type of the operator's left operand; write NONE if the
41           operator has no left operand.
42
43    right_type
44           The data type of the operator's right operand.
45
46    new_owner
47           The new owner of the operator.
48
49    new_schema
50           The new schema for the operator.
51
52    res_proc
53           The restriction selectivity estimator function for this
54           operator; write NONE to remove existing selectivity estimator.
55
56    join_proc
57           The join selectivity estimator function for this operator; write
58           NONE to remove existing selectivity estimator.
59
60    com_op
61           The commutator of this operator. Can only be changed if the
62           operator does not have an existing commutator.
63
64    neg_op
65           The negator of this operator. Can only be changed if the
66           operator does not have an existing negator.
67
68    HASHES
69           Indicates this operator can support a hash join. Can only be
70           enabled and not disabled.
71
72    MERGES
73           Indicates this operator can support a merge join. Can only be
74           enabled and not disabled.
75
76 Notes
77
78    Refer to Section 36.14 and Section 36.15 for further information.
79
80    Since commutators come in pairs that are commutators of each other,
81    ALTER OPERATOR SET COMMUTATOR will also set the commutator of the
82    com_op to be the target operator. Likewise, ALTER OPERATOR SET NEGATOR
83    will also set the negator of the neg_op to be the target operator.
84    Therefore, you must own the commutator or negator operator as well as
85    the target operator.
86
87 Examples
88
89    Change the owner of a custom operator a @@ b for type text:
90 ALTER OPERATOR @@ (text, text) OWNER TO joe;
91
92    Change the restriction and join selectivity estimator functions of a
93    custom operator a && b for type int[]:
94 ALTER OPERATOR && (int[], int[]) SET (RESTRICT = _int_contsel, JOIN = _int_contj
95 oinsel);
96
97    Mark the && operator as being its own commutator:
98 ALTER OPERATOR && (int[], int[]) SET (COMMUTATOR = &&);
99
100 Compatibility
101
102    There is no ALTER OPERATOR statement in the SQL standard.
103
104 See Also
105
106    CREATE OPERATOR, DROP OPERATOR