~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>CREATE OPERATOR CLASS</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.1beta1 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SQL Commands"
HREF="sql-commands.html"><LINK
REL="PREVIOUS"
TITLE="CREATE OPERATOR"
HREF="sql-createoperator.html"><LINK
REL="NEXT"
TITLE="CREATE OPERATOR FAMILY"
HREF="sql-createopfamily.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2011-04-27T21:20:33"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.1beta1 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="CREATE OPERATOR"
HREF="sql-createoperator.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="CREATE OPERATOR"
HREF="sql-createoperator.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
TITLE="CREATE OPERATOR FAMILY"
HREF="sql-createopfamily.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
TITLE="CREATE OPERATOR FAMILY"
HREF="sql-createopfamily.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="SQL-CREATEOPCLASS"
></A
>CREATE OPERATOR CLASS</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN66164"
></A
><H2
>Name</H2
>CREATE OPERATOR CLASS&nbsp;--&nbsp;define a new operator class</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN66169"
></A
><H2
>Synopsis</H2
><PRE
CLASS="SYNOPSIS"
>CREATE OPERATOR CLASS <TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
> [ DEFAULT ] FOR TYPE <TT
CLASS="REPLACEABLE"
><I
>data_type</I
></TT
>
  USING <TT
CLASS="REPLACEABLE"
><I
>index_method</I
></TT
> [ FAMILY <TT
CLASS="REPLACEABLE"
><I
>family_name</I
></TT
> ] AS
  {  OPERATOR <TT
CLASS="REPLACEABLE"
><I
>strategy_number</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>operator_name</I
></TT
> [ ( <TT
CLASS="REPLACEABLE"
><I
>op_type</I
></TT
>, <TT
CLASS="REPLACEABLE"
><I
>op_type</I
></TT
> ) ] [ FOR SEARCH | FOR ORDER BY <TT
CLASS="REPLACEABLE"
><I
>sort_family_name</I
></TT
> ]
   | FUNCTION <TT
CLASS="REPLACEABLE"
><I
>support_number</I
></TT
> [ ( <TT
CLASS="REPLACEABLE"
><I
>op_type</I
></TT
> [ , <TT
CLASS="REPLACEABLE"
><I
>op_type</I
></TT
> ] ) ] <TT
CLASS="REPLACEABLE"
><I
>function_name</I
></TT
> ( <TT
CLASS="REPLACEABLE"
><I
>argument_type</I
></TT
> [, ...] )
   | STORAGE <TT
CLASS="REPLACEABLE"
><I
>storage_type</I
></TT
>
  } [, ... ]</PRE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN66186"
></A
><H2
>Description</H2
><P
>   <TT
CLASS="COMMAND"
>CREATE OPERATOR CLASS</TT
> creates a new operator class.
   An operator class defines how a particular data type can be used with
   an index.  The operator class specifies that certain operators will fill
   particular roles or <SPAN
CLASS="QUOTE"
>"strategies"</SPAN
> for this data type and this
   index method.  The operator class also specifies the support procedures to
   be used by
   the index method when the operator class is selected for an
   index column.  All the operators and functions used by an operator
   class must be defined before the operator class can be created.
  </P
><P
>   If a schema name is given then the operator class is created in the
   specified schema.  Otherwise it is created in the current schema.
   Two operator classes in the same schema can have the same name only if they
   are for different index methods.
  </P
><P
>   The user who defines an operator class becomes its owner.  Presently,
   the creating user must be a superuser.  (This restriction is made because
   an erroneous operator class definition could confuse or even crash the
   server.)
  </P
><P
>   <TT
CLASS="COMMAND"
>CREATE OPERATOR CLASS</TT
> does not presently check
   whether the operator class definition includes all the operators and
   functions required by the index method, nor whether the operators and
   functions form a self-consistent set.  It is the user's
   responsibility to define a valid operator class.
  </P
><P
>   Related operator classes can be grouped into <I
CLASS="FIRSTTERM"
>operator
   families</I
>.  To add a new operator class to an existing family,
   specify the <TT
CLASS="LITERAL"
>FAMILY</TT
> option in <TT
CLASS="COMMAND"
>CREATE OPERATOR
   CLASS</TT
>.  Without this option, the new class is placed into
   a family named the same as the new class (creating that family if
   it doesn't already exist).
  </P
><P
>   Refer to <A
HREF="xindex.html"
>Section 35.14</A
> for further information.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN66201"
></A
><H2
>Parameters</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
></DT
><DD
><P
>      The name of the operator class to be created.  The name can be
      schema-qualified.
     </P
></DD
><DT
><TT
CLASS="LITERAL"
>DEFAULT</TT
></DT
><DD
><P
>      If present, the operator class will become the default
      operator class for its data type.  At most one operator class
      can be the default for a specific data type and index method.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>data_type</I
></TT
></DT
><DD
><P
>      The column data type that this operator class is for.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>index_method</I
></TT
></DT
><DD
><P
>      The name of the index method this operator class is for.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>family_name</I
></TT
></DT
><DD
><P
>      The name of the existing operator family to add this operator class to.
      If not specified, a family named the same as the operator class is
      used (creating it, if it doesn't already exist).
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>strategy_number</I
></TT
></DT
><DD
><P
>      The index method's strategy number for an operator
      associated with the operator class.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>operator_name</I
></TT
></DT
><DD
><P
>      The name (optionally schema-qualified) of an operator associated
      with the operator class.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>op_type</I
></TT
></DT
><DD
><P
>      In an <TT
CLASS="LITERAL"
>OPERATOR</TT
> clause,
      the operand data type(s) of the operator, or <TT
CLASS="LITERAL"
>NONE</TT
> to
      signify a left-unary or right-unary operator.  The operand data
      types can be omitted in the normal case where they are the same
      as the operator class's data type.
     </P
><P
>      In a <TT
CLASS="LITERAL"
>FUNCTION</TT
> clause, the operand data type(s) the
      function is intended to support, if different from
      the input data type(s) of the function (for B-tree and hash indexes)
      or the class's data type (for GIN and GiST indexes).  These defaults
      are always correct, so there is no point in specifying <TT
CLASS="REPLACEABLE"
><I
>op_type</I
></TT
> in a <TT
CLASS="LITERAL"
>FUNCTION</TT
> clause
      in <TT
CLASS="COMMAND"
>CREATE OPERATOR CLASS</TT
>, but the option is provided
      for consistency with the comparable syntax in
      <TT
CLASS="COMMAND"
>ALTER OPERATOR FAMILY</TT
>.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>sort_family_name</I
></TT
></DT
><DD
><P
>      The name (optionally schema-qualified) of an existing btree operator
      family that describes the sort ordering associated with an ordering
      operator.
     </P
><P
>      If neither <TT
CLASS="LITERAL"
>FOR SEARCH</TT
> nor <TT
CLASS="LITERAL"
>FOR ORDER BY</TT
> is
      specified, <TT
CLASS="LITERAL"
>FOR SEARCH</TT
> is the default.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>support_number</I
></TT
></DT
><DD
><P
>      The index method's support procedure number for a
      function associated with the operator class.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>function_name</I
></TT
></DT
><DD
><P
>      The name (optionally schema-qualified) of a function that is an
      index method support procedure for the operator class.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>argument_type</I
></TT
></DT
><DD
><P
>      The parameter data type(s) of the function.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>storage_type</I
></TT
></DT
><DD
><P
>      The data type actually stored in the index.  Normally this is
      the same as the column data type, but some index methods
      (currently GIN and GiST) allow it to be different.  The
      <TT
CLASS="LITERAL"
>STORAGE</TT
> clause must be omitted unless the index
      method allows a different type to be used.
     </P
></DD
></DL
></DIV
><P
>   The <TT
CLASS="LITERAL"
>OPERATOR</TT
>, <TT
CLASS="LITERAL"
>FUNCTION</TT
>, and <TT
CLASS="LITERAL"
>STORAGE</TT
>
   clauses can appear in any order.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN66286"
></A
><H2
>Notes</H2
><P
>   Because the index machinery does not check access permissions on functions
   before using them, including a function or operator in an operator class
   is tantamount to granting public execute permission on it.  This is usually
   not an issue for the sorts of functions that are useful in an operator
   class.
  </P
><P
>   The operators should not be defined by SQL functions.  A SQL function
   is likely to be inlined into the calling query, which will prevent
   the optimizer from recognizing that the query matches an index.
  </P
><P
>   Before <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> 8.4, the <TT
CLASS="LITERAL"
>OPERATOR</TT
>
   clause could include a <TT
CLASS="LITERAL"
>RECHECK</TT
> option.  This is no longer
   supported because whether an index operator is <SPAN
CLASS="QUOTE"
>"lossy"</SPAN
> is now
   determined on-the-fly at run time.  This allows efficient handling of
   cases where an operator might or might not be lossy.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN66295"
></A
><H2
>Examples</H2
><P
>   The following example command defines a GiST index operator class
   for the data type <TT
CLASS="LITERAL"
>_int4</TT
> (array of <TT
CLASS="TYPE"
>int4</TT
>).  See the
   <A
HREF="intarray.html"
>Section F.18</A
> module for the complete example.
  </P
><PRE
CLASS="PROGRAMLISTING"
>CREATE OPERATOR CLASS gist__int_ops
    DEFAULT FOR TYPE _int4 USING gist AS
        OPERATOR        3       &amp;&amp;,
        OPERATOR        6       = (anyarray, anyarray),
        OPERATOR        7       @&gt;,
        OPERATOR        8       &lt;@,
        OPERATOR        20      @@ (_int4, query_int),
        FUNCTION        1       g_int_consistent (internal, _int4, int, oid, internal),
        FUNCTION        2       g_int_union (internal, internal),
        FUNCTION        3       g_int_compress (internal),
        FUNCTION        4       g_int_decompress (internal),
        FUNCTION        5       g_int_penalty (internal, internal, internal),
        FUNCTION        6       g_int_picksplit (internal, internal),
        FUNCTION        7       g_int_same (_int4, _int4, internal);</PRE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN66302"
></A
><H2
>Compatibility</H2
><P
>   <TT
CLASS="COMMAND"
>CREATE OPERATOR CLASS</TT
> is a
   <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> extension.  There is no
   <TT
CLASS="COMMAND"
>CREATE OPERATOR CLASS</TT
> statement in the SQL
   standard.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN66308"
></A
><H2
>See Also</H2
><A
HREF="sql-alteropclass.html"
>ALTER OPERATOR CLASS</A
>, <A
HREF="sql-dropopclass.html"
>DROP OPERATOR CLASS</A
>, <A
HREF="sql-createopfamily.html"
>CREATE OPERATOR FAMILY</A
>, <A
HREF="sql-alteropfamily.html"
>ALTER OPERATOR FAMILY</A
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-createoperator.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sql-createopfamily.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>CREATE OPERATOR</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="sql-commands.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>CREATE OPERATOR FAMILY</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>