Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6cef5d2

Browse files
committed
Operators live in namespaces. CREATE/DROP/COMMENT ON OPERATOR take
qualified operator names directly, for example CREATE OPERATOR myschema.+( ... ). To qualify an operator name in an expression you need to writeOPERATOR(myschema.+) (thanks to Peter for suggesting an escape hatch).I also took advantage of having to reformat pg_operator to fix somethingthat'd been bugging me for a while: mergejoinable operators should haveexplicit links to the associated cross-data-type comparison operators,rather than hardwiring an assumption that they are named < and >.
1 parent4da51bf commit6cef5d2

39 files changed

+1991
-1841
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.41 2002/04/11 19:59:54 tgl Exp $
3+
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.42 2002/04/16 23:08:09 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -1482,6 +1482,15 @@
14821482
<entry>Name of the operator</entry>
14831483
</row>
14841484

1485+
<row>
1486+
<entry>oprnamespace</entry>
1487+
<entry><type>oid</type></entry>
1488+
<entry>pg_namespace.oid</entry>
1489+
<entry>
1490+
The OID of the namespace that contains this operator
1491+
</entry>
1492+
</row>
1493+
14851494
<row>
14861495
<entry>oprowner</entry>
14871496
<entry><type>int4</type></entry>
@@ -1493,7 +1502,8 @@
14931502
<entry>oprprec</entry>
14941503
<entry><type>int2</type></entry>
14951504
<entry></entry>
1496-
<entry>unused</entry>
1505+
<entry>precedence (currently unused, as precedences are hard-wired
1506+
in the grammar)</entry>
14971507
</row>
14981508

14991509
<row>
@@ -1510,7 +1520,8 @@
15101520
<entry>oprisleft</entry>
15111521
<entry><type>bool</type></entry>
15121522
<entry></entry>
1513-
<entry>unused</entry>
1523+
<entry>left-associativity (currently unused, as this is hard-wired
1524+
in the grammar)</entry>
15141525
</row>
15151526

15161527
<row>
@@ -1561,7 +1572,7 @@
15611572
<entry>pg_operator.oid</entry>
15621573
<entry>
15631574
If this operator supports merge joins, the operator that sorts
1564-
the type of the left-hand operand
1575+
the type of the left-hand operand (<literal>L&lt;L</>)
15651576
</entry>
15661577
</row>
15671578

@@ -1571,28 +1582,48 @@
15711582
<entry>pg_operator.oid</entry>
15721583
<entry>
15731584
If this operator supports merge joins, the operator that sorts
1574-
the type of the right-hand operand
1585+
the type of the right-hand operand (<literal>R&lt;R</>)
1586+
</entry>
1587+
</row>
1588+
1589+
<row>
1590+
<entry>oprltcmpop</entry>
1591+
<entry><type>oid</type></entry>
1592+
<entry>pg_operator.oid</entry>
1593+
<entry>
1594+
If this operator supports merge joins, the less-than operator that
1595+
compares the left and right operand types (<literal>L&lt;R</>)
1596+
</entry>
1597+
</row>
1598+
1599+
<row>
1600+
<entry>oprgtcmpop</entry>
1601+
<entry><type>oid</type></entry>
1602+
<entry>pg_operator.oid</entry>
1603+
<entry>
1604+
If this operator supports merge joins, the greater-than operator that
1605+
compares the left and right operand types (<literal>L&gt;R</>)
15751606
</entry>
15761607
</row>
15771608

15781609
<row>
15791610
<entry>oprcode</entry>
15801611
<entry><type>regproc</type></entry>
1581-
<entry></entry>
1612+
<entry>pg_proc.oid</entry>
15821613
<entry>Function that implements this operator</entry>
15831614
</row>
15841615

15851616
<row>
15861617
<entry>oprrest</entry>
15871618
<entry><type>regproc</type></entry>
1588-
<entry></entry>
1619+
<entry>pg_proc.oid</entry>
15891620
<entry>Restriction selectivity estimation function for this operator</entry>
15901621
</row>
15911622

15921623
<row>
15931624
<entry>oprjoin</entry>
15941625
<entry><type>regproc</type></entry>
1595-
<entry></entry>
1626+
<entry>pg_proc.oid</entry>
15961627
<entry>Join selectivity estimation function for this operator</entry>
15971628
</row>
15981629
</tbody>
@@ -2498,28 +2529,28 @@
24982529
<row>
24992530
<entry>typinput</entry>
25002531
<entry><type>regproc</type></entry>
2501-
<entry></entry>
2532+
<entry>pg_proc.oid</entry>
25022533
<entry>Input function</entry>
25032534
</row>
25042535

25052536
<row>
25062537
<entry>typoutput</entry>
25072538
<entry><type>regproc</type></entry>
2508-
<entry></entry>
2539+
<entry>pg_proc.oid</entry>
25092540
<entry>Output function</entry>
25102541
</row>
25112542

25122543
<row>
25132544
<entry>typreceive</entry>
25142545
<entry><type>regproc</type></entry>
2515-
<entry></entry>
2546+
<entry>pg_proc.oid</entry>
25162547
<entry>unused</entry>
25172548
</row>
25182549

25192550
<row>
25202551
<entry>typsend</entry>
25212552
<entry><type>regproc</type></entry>
2522-
<entry></entry>
2553+
<entry>pg_proc.oid</entry>
25232554
<entry>unused</entry>
25242555
</row>
25252556

‎doc/src/sgml/ref/create_operator.sgml

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.25 2002/03/22 19:20:39 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.26 2002/04/16 23:08:10 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -28,7 +28,9 @@ CREATE OPERATOR <replaceable>name</replaceable> ( PROCEDURE = <replaceable class
2828
] [, RIGHTARG = <replaceable class="parameter">righttype</replaceable> ]
2929
[, COMMUTATOR = <replaceable class="parameter">com_op</replaceable> ] [, NEGATOR = <replaceable class="parameter">neg_op</replaceable> ]
3030
[, RESTRICT = <replaceable class="parameter">res_proc</replaceable> ] [, JOIN = <replaceable class="parameter">join_proc</replaceable> ]
31-
[, HASHES ] [, SORT1 = <replaceable class="parameter">left_sort_op</replaceable> ] [, SORT2 = <replaceable class="parameter">right_sort_op</replaceable> ] )
31+
[, HASHES ] [, MERGES ]
32+
[, SORT1 = <replaceable class="parameter">left_sort_op</replaceable> ] [, SORT2 = <replaceable class="parameter">right_sort_op</replaceable> ]
33+
[, LTCMP = <replaceable class="parameter">less_than_op</replaceable> ] [, GTCMP = <replaceable class="parameter">greater_than_op</replaceable> ] )
3234
</synopsis>
3335

3436
<refsect2 id="R2-SQL-CREATEOPERATOR-1">
@@ -115,11 +117,19 @@ CREATE OPERATOR <replaceable>name</replaceable> ( PROCEDURE = <replaceable class
115117
</para>
116118
</listitem>
117119
</varlistentry>
120+
<varlistentry>
121+
<term>MERGES</term>
122+
<listitem>
123+
<para>
124+
Indicates this operator can support a merge join.
125+
</para>
126+
</listitem>
127+
</varlistentry>
118128
<varlistentry>
119129
<term><replaceable class="parameter">left_sort_op</replaceable></term>
120130
<listitem>
121131
<para>
122-
If this operator can support a merge join, the
132+
If this operator can support a merge join, the less-than
123133
operator that sorts the left-hand data type of this operator.
124134
</para>
125135
</listitem>
@@ -128,11 +138,29 @@ CREATE OPERATOR <replaceable>name</replaceable> ( PROCEDURE = <replaceable class
128138
<term><replaceable class="parameter">right_sort_op</replaceable></term>
129139
<listitem>
130140
<para>
131-
If this operator can support a merge join, the
141+
If this operator can support a merge join, the less-than
132142
operator that sorts the right-hand data type of this operator.
133143
</para>
134144
</listitem>
135145
</varlistentry>
146+
<varlistentry>
147+
<term><replaceable class="parameter">less_than_op</replaceable></term>
148+
<listitem>
149+
<para>
150+
If this operator can support a merge join, the less-than
151+
operator that compares the input data types of this operator.
152+
</para>
153+
</listitem>
154+
</varlistentry>
155+
<varlistentry>
156+
<term><replaceable class="parameter">greater_than_op</replaceable></term>
157+
<listitem>
158+
<para>
159+
If this operator can support a merge join, the greater-than
160+
operator that compares the input data types of this operator.
161+
</para>
162+
</listitem>
163+
</varlistentry>
136164
</variablelist>
137165
</para>
138166
</refsect2>
@@ -295,30 +323,39 @@ MYBOXES.description !== box '((0,0), (1,1))'
295323
it also works to just have both operators refer to each other.)
296324
</para>
297325
<para>
298-
The HASHES, SORT1, and SORT2 options are present to support the
299-
query optimizer in performing joins.
300-
<productname>PostgreSQL</productname> can always
301-
evaluate a join (i.e., processing a clause with two tuple
302-
variables separated by an operator that returns a <type>boolean</type>)
303-
by iterative substitution [WONG76].
304-
In addition, <productname>PostgreSQL</productname>
305-
can use a hash-join algorithm along
306-
the lines of [SHAP86]; however, it must know whether this
307-
strategy is applicable. The current hash-join algorithm
308-
is only correct for operators that represent equality tests;
309-
furthermore, equality of the data type must mean bitwise equality
310-
of the representation of the type. (For example, a data type that
311-
contains unused bits that don't matter for equality tests could
312-
not be hash-joined.)
313-
The HASHES flag indicates to the query optimizer that a hash join
314-
may safely be used with this operator.</para>
326+
The HASHES, MERGES, SORT1, SORT2, LTCMP, and GTCMP options are present to
327+
support the query optimizer in performing joins.
328+
<productname>PostgreSQL</productname> can always evaluate a join (i.e.,
329+
processing a clause with two tuple variables separated by an operator that
330+
returns a <type>boolean</type>) by iterative substitution [WONG76]. In
331+
addition, <productname>PostgreSQL</productname> can use a hash-join
332+
algorithm along the lines of [SHAP86]; however, it must know whether this
333+
strategy is applicable. The current hash-join algorithm is only correct
334+
for operators that represent equality tests; furthermore, equality of the
335+
data type must mean bitwise equality of the representation of the type.
336+
(For example, a data type that contains unused bits that don't matter for
337+
equality tests could not be hash-joined.) The HASHES flag indicates to the
338+
query optimizer that a hash join may safely be used with this
339+
operator.
340+
</para>
315341
<para>
316-
Similarly, the two sort operators indicate to the query
317-
optimizer whether merge-sort is a usable join strategy and
318-
which operators should be used to sort the two operand
319-
classes. Sort operators should only be provided for an equality
320-
operator, and they should refer to less-than operators for the
321-
left and right side data types respectively.
342+
Similarly, the MERGES flag indicates whether merge-sort is a usable join
343+
strategy for this operator. A merge join requires that the two input
344+
datatypes have consistent orderings, and that the mergejoin operator
345+
behave like equality with respect to that ordering. For example, it is
346+
possible to merge-join equality between an integer and a float variable by
347+
sorting both inputs in ordinary
348+
numeric order. Execution of a merge join requires that the system be
349+
able to identify four operators related to the mergejoin equality operator:
350+
less-than comparison for the left input datatype,
351+
less-than comparison for the right input datatype,
352+
less-than comparison between the two datatypes, and
353+
greater-than comparison between the two datatypes. It is possible to
354+
specify these by name, as the SORT1, SORT2, LTCMP, and GTCMP options
355+
respectively. The system will fill in the default names <literal>&lt;</>,
356+
<literal>&lt;</>, <literal>&lt;</>, <literal>&gt;</> respectively if
357+
any of these are omitted when MERGES is specified. Also, MERGES will
358+
be assumed to be implied if any of these four operator options appear.
322359
</para>
323360
<para>
324361
If other join strategies are found to be practical,
@@ -408,8 +445,10 @@ CREATE OPERATOR === (
408445
RESTRICT = area_restriction_procedure,
409446
JOIN = area_join_procedure,
410447
HASHES,
411-
SORT1 = <<<,
412-
SORT2 = <<<
448+
SORT1 = &lt;&lt;&lt;,
449+
SORT2 = &lt;&lt;&lt;
450+
-- Since sort operators were given, MERGES is implied.
451+
-- LTCMP and GTCMP are assumed to be &lt; and &gt; respectively
413452
);
414453
</programlisting>
415454
</refsect1>

‎src/backend/catalog/indexing.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.88 2002/04/11 19:59:57 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.89 2002/04/16 23:08:10 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -62,7 +62,7 @@ char *Name_pg_namespace_indices[Num_pg_namespace_indices] =
6262
char*Name_pg_opclass_indices[Num_pg_opclass_indices]=
6363
{OpclassAmNameIndex,OpclassOidIndex};
6464
char*Name_pg_operator_indices[Num_pg_operator_indices]=
65-
{OperatorOidIndex,OperatorNameIndex};
65+
{OperatorOidIndex,OperatorNameNspIndex};
6666
char*Name_pg_proc_indices[Num_pg_proc_indices]=
6767
{ProcedureOidIndex,ProcedureNameNspIndex};
6868
char*Name_pg_relcheck_indices[Num_pg_relcheck_indices]=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp