2
.\" Title: CREATE OPERATOR
3
.\" Author: The PostgreSQL Global Development Group
4
.\" Generator: DocBook XSL Stylesheets v1.75.1 <http://docbook.sf.net/>
6
.\" Manual: PostgreSQL 9.1beta1 Documentation
7
.\" Source: PostgreSQL 9.1beta1
10
.TH "CREATE OPERATOR" "7" "2011-04-27" "PostgreSQL 9.1beta1" "PostgreSQL 9.1beta1 Documentation"
11
.\" -----------------------------------------------------------------
12
.\" * set default formatting
13
.\" -----------------------------------------------------------------
14
.\" disable hyphenation
16
.\" disable justification (adjust text to left margin only)
18
.\" -----------------------------------------------------------------
19
.\" * MAIN CONTENT STARTS HERE *
20
.\" -----------------------------------------------------------------
22
CREATE_OPERATOR \- define a new operator
27
CREATE OPERATOR \fIname\fR (
28
PROCEDURE = \fIfunction_name\fR
29
[, LEFTARG = \fIleft_type\fR ] [, RIGHTARG = \fIright_type\fR ]
30
[, COMMUTATOR = \fIcom_op\fR ] [, NEGATOR = \fIneg_op\fR ]
31
[, RESTRICT = \fIres_proc\fR ] [, JOIN = \fIjoin_proc\fR ]
32
[, HASHES ] [, MERGES ]
38
defines a new operator,
39
\fIname\fR\&. The user who defines an operator becomes its owner\&. If a schema name is given then the operator is created in the specified schema\&. Otherwise it is created in the current schema\&.
41
The operator name is a sequence of up to
42
NAMEDATALEN\-1 (63 by default) characters from the following list:
48
+ \- * / < > = ~ ! @ # % ^ & | ` ?
54
There are a few restrictions on your choice of name:
67
cannot appear anywhere in an operator name, since they will be taken as the start of a comment\&.
78
A multicharacter operator name cannot end in
81
\-, unless the name also contains at least one of these characters:
95
is an allowed operator name, but
97
is not\&. This restriction allows
99
to parse SQL\-compliant commands without requiring spaces between tokens\&.
112
as an operator name is deprecated\&. It may be disallowed altogether in a future release\&.
119
on input, so these two names are always equivalent\&.
125
must be defined\&. For binary operators, both must be defined\&. For right unary operators, only
127
should be defined, while for left unary operators only
133
procedure must have been previously defined using
135
and must be defined to accept the correct number of arguments (either one or two) of the indicated types\&.
137
The other clauses specify optional operator optimization clauses\&. Their meaning is detailed in
138
Section 35.13, \(lqOperator Optimization Information\(rq, in the documentation\&.
143
The name of the operator to be defined\&. See above for allowable characters\&. The name can be schema\-qualified, for example
144
CREATE OPERATOR myschema\&.+ (\&.\&.\&.)\&. If not, then the operator is created in the current schema\&. Two operators in the same schema can have the same name if they operate on different data types\&. This is called
150
The function used to implement this operator\&.
155
The data type of the operator\(aqs left operand, if any\&. This option would be omitted for a left\-unary operator\&.
160
The data type of the operator\(aqs right operand, if any\&. This option would be omitted for a right\-unary operator\&.
165
The commutator of this operator\&.
170
The negator of this operator\&.
175
The restriction selectivity estimator function for this operator\&.
180
The join selectivity estimator function for this operator\&.
185
Indicates this operator can support a hash join\&.
190
Indicates this operator can support a merge join\&.
193
To give a schema\-qualified operator name in
195
or the other optional arguments, use the
203
COMMUTATOR = OPERATOR(myschema\&.===) ,
211
Section 35.12, \(lqUser-defined Operators\(rq, in the documentation
212
for further information\&.
214
It is not possible to specify an operator\(aqs lexical precedence in
215
CREATE OPERATOR, because the parser\(aqs precedence behavior is hard\-wired\&. See
216
Section 4.1.6, \(lqLexical Precedence\(rq, in the documentation
217
for precedence details\&.
224
were formerly used to specify the names of sort operators associated with a merge\-joinable operator\&. This is no longer necessary, since information about associated operators is found by looking at B\-tree operator families instead\&. If one of these options is given, it is ignored except for implicitly setting
229
DROP OPERATOR (\fBDROP_OPERATOR\fR(7))
230
to delete user\-defined operators from a database\&. Use
231
ALTER OPERATOR (\fBALTER_OPERATOR\fR(7))
232
to modify operators in a database\&.
235
The following command defines a new operator, area\-equality, for the data type
242
CREATE OPERATOR === (
245
PROCEDURE = area_equal_procedure,
248
RESTRICT = area_restriction_procedure,
249
JOIN = area_join_procedure,
261
extension\&. There are no provisions for user\-defined operators in the SQL standard\&.
263
ALTER OPERATOR (\fBALTER_OPERATOR\fR(7)), CREATE OPERATOR CLASS (\fBCREATE_OPERATOR_CLASS\fR(7)), DROP OPERATOR (\fBDROP_OPERATOR\fR(7))