]> begriffs open source - ai-pg/blob - full-docs/man7/ALTER_OPERATOR.7
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man7 / ALTER_OPERATOR.7
1 '\" t
2 .\"     Title: ALTER OPERATOR
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "ALTER OPERATOR" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 ALTER_OPERATOR \- change the definition of an operator
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 ALTER OPERATOR \fIname\fR ( { \fIleft_type\fR | NONE } , \fIright_type\fR )
36     OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
37
38 ALTER OPERATOR \fIname\fR ( { \fIleft_type\fR | NONE } , \fIright_type\fR )
39     SET SCHEMA \fInew_schema\fR
40
41 ALTER OPERATOR \fIname\fR ( { \fIleft_type\fR | NONE } , \fIright_type\fR )
42     SET ( {  RESTRICT = { \fIres_proc\fR | NONE }
43            | JOIN = { \fIjoin_proc\fR | NONE }
44            | COMMUTATOR = \fIcom_op\fR
45            | NEGATOR = \fIneg_op\fR
46            | HASHES
47            | MERGES
48           } [, \&.\&.\&. ] )
49 .fi
50 .SH "DESCRIPTION"
51 .PP
52 \fBALTER OPERATOR\fR
53 changes the definition of an operator\&.
54 .PP
55 You must own the operator to use
56 \fBALTER OPERATOR\fR\&. To alter the owner, you must be able to
57 SET ROLE
58 to the new owning role, and that role must have
59 CREATE
60 privilege on the operator\*(Aqs schema\&. (These restrictions enforce that altering the owner doesn\*(Aqt do anything you couldn\*(Aqt do by dropping and recreating the operator\&. However, a superuser can alter ownership of any operator anyway\&.)
61 .SH "PARAMETERS"
62 .PP
63 \fIname\fR
64 .RS 4
65 The name (optionally schema\-qualified) of an existing operator\&.
66 .RE
67 .PP
68 \fIleft_type\fR
69 .RS 4
70 The data type of the operator\*(Aqs left operand; write
71 NONE
72 if the operator has no left operand\&.
73 .RE
74 .PP
75 \fIright_type\fR
76 .RS 4
77 The data type of the operator\*(Aqs right operand\&.
78 .RE
79 .PP
80 \fInew_owner\fR
81 .RS 4
82 The new owner of the operator\&.
83 .RE
84 .PP
85 \fInew_schema\fR
86 .RS 4
87 The new schema for the operator\&.
88 .RE
89 .PP
90 \fIres_proc\fR
91 .RS 4
92 The restriction selectivity estimator function for this operator; write NONE to remove existing selectivity estimator\&.
93 .RE
94 .PP
95 \fIjoin_proc\fR
96 .RS 4
97 The join selectivity estimator function for this operator; write NONE to remove existing selectivity estimator\&.
98 .RE
99 .PP
100 \fIcom_op\fR
101 .RS 4
102 The commutator of this operator\&. Can only be changed if the operator does not have an existing commutator\&.
103 .RE
104 .PP
105 \fIneg_op\fR
106 .RS 4
107 The negator of this operator\&. Can only be changed if the operator does not have an existing negator\&.
108 .RE
109 .PP
110 HASHES
111 .RS 4
112 Indicates this operator can support a hash join\&. Can only be enabled and not disabled\&.
113 .RE
114 .PP
115 MERGES
116 .RS 4
117 Indicates this operator can support a merge join\&. Can only be enabled and not disabled\&.
118 .RE
119 .SH "NOTES"
120 .PP
121 Refer to
122 Section\ \&36.14
123 and
124 Section\ \&36.15
125 for further information\&.
126 .PP
127 Since commutators come in pairs that are commutators of each other,
128 ALTER OPERATOR SET COMMUTATOR
129 will also set the commutator of the
130 \fIcom_op\fR
131 to be the target operator\&. Likewise,
132 ALTER OPERATOR SET NEGATOR
133 will also set the negator of the
134 \fIneg_op\fR
135 to be the target operator\&. Therefore, you must own the commutator or negator operator as well as the target operator\&.
136 .SH "EXAMPLES"
137 .PP
138 Change the owner of a custom operator
139 a @@ b
140 for type
141 text:
142 .sp
143 .if n \{\
144 .RS 4
145 .\}
146 .nf
147 ALTER OPERATOR @@ (text, text) OWNER TO joe;
148 .fi
149 .if n \{\
150 .RE
151 .\}
152 .PP
153 Change the restriction and join selectivity estimator functions of a custom operator
154 a && b
155 for type
156 int[]:
157 .sp
158 .if n \{\
159 .RS 4
160 .\}
161 .nf
162 ALTER OPERATOR && (int[], int[]) SET (RESTRICT = _int_contsel, JOIN = _int_contjoinsel);
163 .fi
164 .if n \{\
165 .RE
166 .\}
167 .PP
168 Mark the
169 &&
170 operator as being its own commutator:
171 .sp
172 .if n \{\
173 .RS 4
174 .\}
175 .nf
176 ALTER OPERATOR && (int[], int[]) SET (COMMUTATOR = &&);
177 .fi
178 .if n \{\
179 .RE
180 .\}
181 .sp
182 .SH "COMPATIBILITY"
183 .PP
184 There is no
185 \fBALTER OPERATOR\fR
186 statement in the SQL standard\&.
187 .SH "SEE ALSO"
188 CREATE OPERATOR (\fBCREATE_OPERATOR\fR(7)), DROP OPERATOR (\fBDROP_OPERATOR\fR(7))