1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5
>CREATE OPERATOR CLASS</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
16
HREF="sql-commands.html"><LINK
18
TITLE="CREATE OPERATOR"
19
HREF="sql-createoperator.html"><LINK
21
TITLE="CREATE OPERATOR FAMILY"
22
HREF="sql-createopfamily.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="CREATE OPERATOR"
57
HREF="sql-createoperator.html"
66
TITLE="CREATE OPERATOR"
67
HREF="sql-createoperator.html"
80
TITLE="CREATE OPERATOR FAMILY"
81
HREF="sql-createopfamily.html"
89
TITLE="CREATE OPERATOR FAMILY"
90
HREF="sql-createopfamily.html"
101
NAME="SQL-CREATEOPCLASS"
103
>CREATE OPERATOR CLASS</H1
111
>CREATE OPERATOR CLASS -- define a new operator class</DIV
113
CLASS="REFSYNOPSISDIV"
121
>CREATE OPERATOR CLASS <TT
126
> [ DEFAULT ] FOR TYPE <TT
163
> ) ] [ FOR SEARCH | FOR ORDER BY <TT
213
>CREATE OPERATOR CLASS</TT
214
> creates a new operator class.
215
An operator class defines how a particular data type can be used with
216
an index. The operator class specifies that certain operators will fill
217
particular roles or <SPAN
220
> for this data type and this
221
index method. The operator class also specifies the support procedures to
223
the index method when the operator class is selected for an
224
index column. All the operators and functions used by an operator
225
class must be defined before the operator class can be created.
228
> If a schema name is given then the operator class is created in the
229
specified schema. Otherwise it is created in the current schema.
230
Two operator classes in the same schema can have the same name only if they
231
are for different index methods.
234
> The user who defines an operator class becomes its owner. Presently,
235
the creating user must be a superuser. (This restriction is made because
236
an erroneous operator class definition could confuse or even crash the
242
>CREATE OPERATOR CLASS</TT
243
> does not presently check
244
whether the operator class definition includes all the operators and
245
functions required by the index method, nor whether the operators and
246
functions form a self-consistent set. It is the user's
247
responsibility to define a valid operator class.
250
> Related operator classes can be grouped into <I
254
>. To add a new operator class to an existing family,
262
>. Without this option, the new class is placed into
263
a family named the same as the new class (creating that family if
264
it doesn't already exist).
270
> for further information.
294
> The name of the operator class to be created. The name can be
305
> If present, the operator class will become the default
306
operator class for its data type. At most one operator class
307
can be the default for a specific data type and index method.
319
> The column data type that this operator class is for.
331
> The name of the index method this operator class is for.
343
> The name of the existing operator family to add this operator class to.
344
If not specified, a family named the same as the operator class is
345
used (creating it, if it doesn't already exist).
357
> The index method's strategy number for an operator
358
associated with the operator class.
370
> The name (optionally schema-qualified) of an operator associated
371
with the operator class.
387
the operand data type(s) of the operator, or <TT
391
signify a left-unary or right-unary operator. The operand data
392
types can be omitted in the normal case where they are the same
393
as the operator class's data type.
399
> clause, the operand data type(s) the
400
function is intended to support, if different from
401
the input data type(s) of the function (for B-tree and hash indexes)
402
or the class's data type (for GIN and GiST indexes). These defaults
403
are always correct, so there is no point in specifying <TT
414
>CREATE OPERATOR CLASS</TT
415
>, but the option is provided
416
for consistency with the comparable syntax in
419
>ALTER OPERATOR FAMILY</TT
432
> The name (optionally schema-qualified) of an existing btree operator
433
family that describes the sort ordering associated with an ordering
459
> The index method's support procedure number for a
460
function associated with the operator class.
472
> The name (optionally schema-qualified) of a function that is an
473
index method support procedure for the operator class.
485
> The parameter data type(s) of the function.
497
> The data type actually stored in the index. Normally this is
498
the same as the column data type, but some index methods
499
(currently GIN and GiST) allow it to be different. The
503
> clause must be omitted unless the index
504
method allows a different type to be used.
520
clauses can appear in any order.
531
> Because the index machinery does not check access permissions on functions
532
before using them, including a function or operator in an operator class
533
is tantamount to granting public execute permission on it. This is usually
534
not an issue for the sorts of functions that are useful in an operator
538
> The operators should not be defined by SQL functions. A SQL function
539
is likely to be inlined into the calling query, which will prevent
540
the optimizer from recognizing that the query matches an index.
550
clause could include a <TT
553
> option. This is no longer
554
supported because whether an index operator is <SPAN
558
determined on-the-fly at run time. This allows efficient handling of
559
cases where an operator might or might not be lossy.
570
> The following example command defines a GiST index operator class
571
for the data type <TT
581
> module for the complete example.
584
CLASS="PROGRAMLISTING"
585
>CREATE OPERATOR CLASS gist__int_ops
586
DEFAULT FOR TYPE _int4 USING gist AS
587
OPERATOR 3 &&,
588
OPERATOR 6 = (anyarray, anyarray),
591
OPERATOR 20 @@ (_int4, query_int),
592
FUNCTION 1 g_int_consistent (internal, _int4, int, oid, internal),
593
FUNCTION 2 g_int_union (internal, internal),
594
FUNCTION 3 g_int_compress (internal),
595
FUNCTION 4 g_int_decompress (internal),
596
FUNCTION 5 g_int_penalty (internal, internal, internal),
597
FUNCTION 6 g_int_picksplit (internal, internal),
598
FUNCTION 7 g_int_same (_int4, _int4, internal);</PRE
610
>CREATE OPERATOR CLASS</TT
615
> extension. There is no
618
>CREATE OPERATOR CLASS</TT
619
> statement in the SQL
631
HREF="sql-alteropclass.html"
632
>ALTER OPERATOR CLASS</A
634
HREF="sql-dropopclass.html"
635
>DROP OPERATOR CLASS</A
637
HREF="sql-createopfamily.html"
638
>CREATE OPERATOR FAMILY</A
640
HREF="sql-alteropfamily.html"
641
>ALTER OPERATOR FAMILY</A
648
SUMMARY="Footer navigation table"
659
HREF="sql-createoperator.html"
677
HREF="sql-createopfamily.html"
693
HREF="sql-commands.html"
701
>CREATE OPERATOR FAMILY</TD
b'\\ No newline at end of file'