15
15
</refnamediv>
16
16
<REFSYNOPSISDIV>
17
17
<REFSYNOPSISDIVINFO>
18
- <DATE>1998-09-09 </DATE>
18
+ <DATE>1999-04-14 </DATE>
19
19
</REFSYNOPSISDIVINFO>
20
20
<SYNOPSIS>
21
21
CREATE OPERATOR <replaceable>name</replaceable> (
@@ -25,15 +25,16 @@ CREATE OPERATOR <replaceable>name</replaceable> (
25
25
[, COMMUTATOR = <replaceable class="parameter">com_op</replaceable> ]
26
26
[, NEGATOR = <replaceable class="parameter">neg_op</replaceable> ]
27
27
[, RESTRICT = <replaceable class="parameter">res_proc</replaceable> ]
28
- [, HASHES ]
29
28
[, JOIN = <replaceable class="parameter">join_proc</replaceable> ]
30
- [, SORT = <replaceable class="parameter">sort_op</replaceable> [, ...] ]
29
+ [, HASHES ]
30
+ [, SORT1 = <replaceable class="parameter">left_sort_op</replaceable> ]
31
+ [, SORT2 = <replaceable class="parameter">right_sort_op</replaceable> ]
31
32
)
32
33
</SYNOPSIS>
33
34
34
35
<REFSECT2 ID="R2-SQL-CREATEOPERATOR-1">
35
36
<REFSECT2INFO>
36
- <DATE>1998-09-09 </DATE>
37
+ <DATE>1999-04-14 </DATE>
37
38
</REFSECT2INFO>
38
39
<TITLE>
39
40
Inputs
@@ -89,7 +90,7 @@ omitted for a left-unary operator.
89
90
</TERM>
90
91
<LISTITEM>
91
92
<PARA>
92
- The corresponding commutative operator.
93
+ The commutator for this operator.
93
94
</PARA>
94
95
</LISTITEM>
95
96
</VARLISTENTRY>
@@ -99,7 +100,7 @@ The corresponding commutative operator.
99
100
</TERM>
100
101
<LISTITEM>
101
102
<PARA>
102
- The corresponding negation operator.
103
+ The negator of this operator.
103
104
</PARA>
104
105
</LISTITEM>
105
106
</VARLISTENTRY>
@@ -109,7 +110,17 @@ The corresponding negation operator.
109
110
</TERM>
110
111
<LISTITEM>
111
112
<PARA>
112
- The corresponding restriction operator.
113
+ The restriction selectivity estimator function for this operator.
114
+ </PARA>
115
+ </LISTITEM>
116
+ </VARLISTENTRY>
117
+ <VARLISTENTRY>
118
+ <TERM>
119
+ <replaceable class="parameter">join_proc</replaceable>
120
+ </TERM>
121
+ <LISTITEM>
122
+ <PARA>
123
+ The join selectivity estimator function for this operator.
113
124
</PARA>
114
125
</LISTITEM>
115
126
</VARLISTENTRY>
@@ -119,27 +130,27 @@ HASHES
119
130
</TERM>
120
131
<LISTITEM>
121
132
<PARA>
122
- This operator can support a hash-join algorithm.
133
+ Indicates this operator can support a hash-join algorithm.
123
134
</PARA>
124
135
</LISTITEM>
125
136
</VARLISTENTRY>
126
137
<VARLISTENTRY>
127
138
<TERM>
128
- <replaceable class="parameter">join_proc </replaceable>
139
+ <replaceable class="parameter">left_sort_op </replaceable>
129
140
</TERM>
130
141
<LISTITEM>
131
142
<PARA>
132
- Procedure supporting table joins .
143
+ Operator that sorts the left-hand data type of this operator .
133
144
</PARA>
134
145
</LISTITEM>
135
146
</VARLISTENTRY>
136
147
<VARLISTENTRY>
137
148
<TERM>
138
- <replaceable class="parameter">sort_op </replaceable>
149
+ <replaceable class="parameter">right_sort_op </replaceable>
139
150
</TERM>
140
151
<LISTITEM>
141
152
<PARA>
142
- Operator to use for sorting .
153
+ Operator that sorts the right-hand data type of this operator .
143
154
</PARA>
144
155
</LISTITEM>
145
156
</VARLISTENTRY>
@@ -149,7 +160,7 @@ Operator to use for sorting.
149
160
150
161
<REFSECT2 ID="R2-SQL-CREATEOPERATOR-2">
151
162
<REFSECT2INFO>
152
- <DATE>1998-09-09 </DATE>
163
+ <DATE>1999-04-14 </DATE>
153
164
</REFSECT2INFO>
154
165
<TITLE>
155
166
Outputs
@@ -173,7 +184,7 @@ Operator to use for sorting.
173
184
174
185
<REFSECT1 ID="R1-SQL-CREATEOPERATOR-1">
175
186
<REFSECT1INFO>
176
- <DATE>1998-09-09 </DATE>
187
+ <DATE>1999-04-14 </DATE>
177
188
</REFSECT1INFO>
178
189
<TITLE>
179
190
Description
@@ -252,51 +263,44 @@ Operator to use for sorting.
252
263
If a commutator operator name is supplied,
253
264
<productname>Postgres</productname>
254
265
searches for it in the catalog. If it is found and it
255
- does not yet have a commutator itself, then the commutator's
256
- entry is updated to have the current (new) operator
257
- as its commutator. This applies to the negator, as well.
266
+ does not yet have a commutator itself, then the commutator's
267
+ entry is updated to have the newly created operator as its
268
+ commutator. This applies to the negator, as well.
258
269
</para>
259
270
<para>
260
271
This is to allow the definition of two operators that are
261
272
the commutators or the negators of each other. The first
262
273
operator should be defined without a commutator or negator
263
274
(as appropriate). When the second operator is defined,
264
275
name the first as the commutator or negator. The first
265
- will be updated as a side effect.
276
+ will be updated as a side effect. (As of Postgres 6.5,
277
+ it also works to just have both operators refer to each other.)
266
278
</para>
267
279
<para>
268
- The next two specifications are present to support the
280
+ The next three specifications are present to support the
269
281
query optimizer in performing joins.
270
282
<productname>Postgres</productname> can always
271
283
evaluate a join (i.e., processing a clause with two tuple
272
284
variables separated by an operator that returns a boolean)
273
285
by iterative substitution [WONG76].
274
286
In addition, <productname>Postgres</productname>
275
- is planning on implementing a hash-join algorithm along
287
+ can use a hash-join algorithm along
276
288
the lines of [SHAP86]; however, it must know whether this
277
- strategy is applicable.
278
- For example, a hash-join
279
- algorithm is usable for a clause of the form:
280
- <programlisting>
281
- MYBOXES.description === MYBOXES2.description
282
- </programlisting>
283
- but not for a clause of the form:
284
- <programlisting>
285
- MYBOXES.description <<< MYBOXES2.description.
286
- </programlisting>
287
- The HASHES flag gives the needed information to the query
288
- optimizer concerning whether a hash join strategy is
289
- usable for the operator in question.</para>
289
+ strategy is applicable. The current hash-join algorithm
290
+ is only correct for operators that represent equality tests;
291
+ furthermore, equality of the datatype must mean bitwise equality
292
+ of the representation of the type. (For example, a datatype that
293
+ contains unused bits that don't matter for equality tests could
294
+ not be hashjoined.)
295
+ The HASHES flag indicates to the query optimizer that a hash join
296
+ may safely be used with this operator.</para>
290
297
<para>
291
298
Similarly, the two sort operators indicate to the query
292
299
optimizer whether merge-sort is a usable join strategy and
293
- what operators should be used to sort the two operand
294
- classes. For the === clause above, the optimizer must
295
- sort both relations using the operator, <<<. On the other
296
- hand, merge-sort is not usable with the clause:
297
- <programlisting>
298
- MYBOXES.description <<< MYBOXES2.description
299
- </programlisting>
300
+ which operators should be used to sort the two operand
301
+ classes. Sort operators should only be provided for an equality
302
+ operator, and they should refer to less-than operators for the
303
+ left and right side data types respectively.
300
304
</para>
301
305
<para>
302
306
If other join strategies are found to be practical,
@@ -355,7 +359,7 @@ Operator to use for sorting.
355
359
356
360
<REFSECT2 ID="R2-SQL-CREATEOPERATOR-3">
357
361
<REFSECT2INFO>
358
- <DATE>1998-09-09 </DATE>
362
+ <DATE>1999-04-14 </DATE>
359
363
</REFSECT2INFO>
360
364
<TITLE>
361
365
Notes
@@ -385,9 +389,10 @@ Operator to use for sorting.
385
389
COMMUTATOR = ===,
386
390
NEGATOR = !==,
387
391
RESTRICT = area_restriction_procedure,
392
+ JOIN = area_join_procedure,
388
393
HASHES,
389
- JOIN = area-join-procedure ,
390
- SORT = <<<, <<<)
394
+ SORT1 = <<< ,
395
+ SORT2 = <<<)
391
396
</ProgramListing>
392
397
</REFSECT1>
393
398
@@ -401,7 +406,7 @@ Operator to use for sorting.
401
406
402
407
<REFSECT2 ID="R2-SQL-CREATEOPERATOR-4">
403
408
<REFSECT2INFO>
404
- <DATE>1998-09-09 </DATE>
409
+ <DATE>1999-04-14 </DATE>
405
410
</REFSECT2INFO>
406
411
<TITLE>
407
412
SQL92
0 commit comments