1515 </refnamediv>
1616 <REFSYNOPSISDIV>
1717 <REFSYNOPSISDIVINFO>
18- <DATE>1998-09-09 </DATE>
18+ <DATE>1999-04-14 </DATE>
1919 </REFSYNOPSISDIVINFO>
2020 <SYNOPSIS>
2121CREATE OPERATOR <replaceable>name</replaceable> (
@@ -25,15 +25,16 @@ CREATE OPERATOR <replaceable>name</replaceable> (
2525 [, COMMUTATOR = <replaceable class="parameter">com_op</replaceable> ]
2626 [, NEGATOR = <replaceable class="parameter">neg_op</replaceable> ]
2727 [, RESTRICT = <replaceable class="parameter">res_proc</replaceable> ]
28- [, HASHES ]
2928 [, 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> ]
3132 )
3233 </SYNOPSIS>
3334
3435 <REFSECT2 ID="R2-SQL-CREATEOPERATOR-1">
3536 <REFSECT2INFO>
36- <DATE>1998-09-09 </DATE>
37+ <DATE>1999-04-14 </DATE>
3738 </REFSECT2INFO>
3839 <TITLE>
3940 Inputs
@@ -89,7 +90,7 @@ omitted for a left-unary operator.
8990 </TERM>
9091 <LISTITEM>
9192 <PARA>
92- Thecorresponding commutative operator.
93+ Thecommutator for this operator.
9394 </PARA>
9495 </LISTITEM>
9596</VARLISTENTRY>
@@ -99,7 +100,7 @@ The corresponding commutative operator.
99100 </TERM>
100101 <LISTITEM>
101102 <PARA>
102- Thecorresponding negation operator.
103+ Thenegator of this operator.
103104 </PARA>
104105 </LISTITEM>
105106</VARLISTENTRY>
@@ -109,7 +110,17 @@ The corresponding negation operator.
109110 </TERM>
110111 <LISTITEM>
111112 <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.
113124 </PARA>
114125 </LISTITEM>
115126</VARLISTENTRY>
@@ -119,27 +130,27 @@ HASHES
119130 </TERM>
120131 <LISTITEM>
121132 <PARA>
122- This operator can support a hash-join algorithm.
133+ Indicates this operator can support a hash-join algorithm.
123134 </PARA>
124135 </LISTITEM>
125136</VARLISTENTRY>
126137<VARLISTENTRY>
127138 <TERM>
128- <replaceable class="parameter">join_proc </replaceable>
139+ <replaceable class="parameter">left_sort_op </replaceable>
129140 </TERM>
130141 <LISTITEM>
131142 <PARA>
132- Procedure supporting table joins .
143+ Operator that sorts the left-hand data type of this operator .
133144 </PARA>
134145 </LISTITEM>
135146</VARLISTENTRY>
136147<VARLISTENTRY>
137148 <TERM>
138- <replaceable class="parameter">sort_op </replaceable>
149+ <replaceable class="parameter">right_sort_op </replaceable>
139150 </TERM>
140151 <LISTITEM>
141152 <PARA>
142- Operatorto use for sorting .
153+ Operatorthat sorts the right-hand data type of this operator .
143154 </PARA>
144155 </LISTITEM>
145156</VARLISTENTRY>
@@ -149,7 +160,7 @@ Operator to use for sorting.
149160
150161 <REFSECT2 ID="R2-SQL-CREATEOPERATOR-2">
151162 <REFSECT2INFO>
152- <DATE>1998-09-09 </DATE>
163+ <DATE>1999-04-14 </DATE>
153164 </REFSECT2INFO>
154165 <TITLE>
155166 Outputs
@@ -173,7 +184,7 @@ Operator to use for sorting.
173184
174185 <REFSECT1 ID="R1-SQL-CREATEOPERATOR-1">
175186 <REFSECT1INFO>
176- <DATE>1998-09-09 </DATE>
187+ <DATE>1999-04-14 </DATE>
177188 </REFSECT1INFO>
178189 <TITLE>
179190 Description
@@ -252,51 +263,44 @@ Operator to use for sorting.
252263 If a commutator operator name is supplied,
253264 <productname>Postgres</productname>
254265 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 thecurrent (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 thenewly created operator as its
268+ commutator. This applies to the negator, as well.
258269 </para>
259270 <para>
260271 This is to allow the definition of two operators that are
261272 the commutators or the negators of each other. The first
262273 operator should be defined without a commutator or negator
263274 (as appropriate). When the second operator is defined,
264275 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.)
266278 </para>
267279 <para>
268- The nexttwo specifications are present to support the
280+ The nextthree specifications are present to support the
269281 query optimizer in performing joins.
270282 <productname>Postgres</productname> can always
271283 evaluate a join (i.e., processing a clause with two tuple
272284 variables separated by an operator that returns a boolean)
273285 by iterative substitution [WONG76].
274286 In addition, <productname>Postgres</productname>
275- is planning on implementing a hash-join algorithm along
287+ can use a hash-join algorithm along
276288 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>
290297 <para>
291298 Similarly, the two sort operators indicate to the query
292299 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.
300304 </para>
301305 <para>
302306 If other join strategies are found to be practical,
@@ -355,7 +359,7 @@ Operator to use for sorting.
355359
356360 <REFSECT2 ID="R2-SQL-CREATEOPERATOR-3">
357361 <REFSECT2INFO>
358- <DATE>1998-09-09 </DATE>
362+ <DATE>1999-04-14 </DATE>
359363 </REFSECT2INFO>
360364 <TITLE>
361365 Notes
@@ -385,9 +389,10 @@ Operator to use for sorting.
385389 COMMUTATOR = ===,
386390 NEGATOR = !==,
387391 RESTRICT = area_restriction_procedure,
392+ JOIN = area_join_procedure,
388393 HASHES,
389- JOIN =area-join-procedure ,
390- SORT = <<<, <<<)
394+ SORT1 =<<< ,
395+ SORT2 = <<<)
391396 </ProgramListing>
392397 </REFSECT1>
393398
@@ -401,7 +406,7 @@ Operator to use for sorting.
401406
402407 <REFSECT2 ID="R2-SQL-CREATEOPERATOR-4">
403408 <REFSECT2INFO>
404- <DATE>1998-09-09 </DATE>
409+ <DATE>1999-04-14 </DATE>
405410 </REFSECT2INFO>
406411 <TITLE>
407412 SQL92