mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Replace ad-hoc insertions into pg_opclass and friends with CREATE
OPERATOR CLASS commands. Further tweaking of documentation for same.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.15 2002/01/07 02:29:11 petere Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.16 2002/07/30 17:34:37 tgl Exp $
|
||||
-->
|
||||
|
||||
<chapter id="extend">
|
||||
@ -255,11 +255,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.15 2002/01/07 02:29:11 pete
|
||||
There are many columns and relationships that
|
||||
have obvious meanings, but there are many
|
||||
(particularly those that have to do with access
|
||||
methods) that do not. The relationships between
|
||||
<classname>pg_am</>, <classname>pg_amop</>, <classname>pg_amproc</>, <classname>pg_operator</>, and
|
||||
<classname>pg_opclass</> are particularly hard to understand
|
||||
and will be described in depth (in <xref linkend="xindex">)
|
||||
after we have discussed basic extensions.
|
||||
methods) that do not.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/indices.sgml,v 1.34 2002/06/21 19:06:44 momjian Exp $ -->
|
||||
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/indices.sgml,v 1.35 2002/07/30 17:34:37 tgl Exp $ -->
|
||||
|
||||
<chapter id="indexes">
|
||||
<title id="indexes-title">Indexes</title>
|
||||
@ -407,8 +407,18 @@ CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The following query shows all defined operator classes:
|
||||
<programlisting>
|
||||
The following query shows all defined operator classes:
|
||||
|
||||
<programlisting>
|
||||
SELECT am.amname AS acc_method,
|
||||
opc.opcname AS ops_name
|
||||
FROM pg_am am, pg_opclass opc
|
||||
WHERE opc.opcamid = am.oid
|
||||
ORDER BY acc_method, ops_name;
|
||||
</programlisting>
|
||||
|
||||
It can be extended to show all the operators included in each class:
|
||||
<programlisting>
|
||||
SELECT am.amname AS acc_method,
|
||||
opc.opcname AS ops_name,
|
||||
opr.oprname AS ops_comp
|
||||
@ -416,8 +426,8 @@ SELECT am.amname AS acc_method,
|
||||
WHERE opc.opcamid = am.oid AND
|
||||
amop.amopclaid = opc.oid AND
|
||||
amop.amopopr = opr.oid
|
||||
ORDER BY acc_method, ops_name, ops_comp
|
||||
</programlisting>
|
||||
ORDER BY acc_method, ops_name, ops_comp;
|
||||
</programlisting>
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_index.sgml,v 1.34 2002/06/21 19:06:44 momjian Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_index.sgml,v 1.35 2002/07/30 17:34:37 tgl Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
@ -382,13 +382,10 @@ ERROR: Cannot create index: 'index_name' already exists.
|
||||
|
||||
<programlisting>
|
||||
SELECT am.amname AS acc_method,
|
||||
opc.opcname AS ops_name,
|
||||
opr.oprname AS ops_comp
|
||||
FROM pg_am am, pg_opclass opc, pg_amop amop, pg_operator opr
|
||||
WHERE opc.opcamid = am.oid AND
|
||||
amop.amopclaid = opc.oid AND
|
||||
amop.amopopr = opr.oid
|
||||
ORDER BY acc_method, ops_name, ops_comp;
|
||||
opc.opcname AS ops_name
|
||||
FROM pg_am am, pg_opclass opc
|
||||
WHERE opc.opcamid = am.oid
|
||||
ORDER BY acc_method, ops_name;
|
||||
</programlisting>
|
||||
</para>
|
||||
</refsect2>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.27 2002/07/30 05:24:56 tgl Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.28 2002/07/30 17:34:37 tgl Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
@ -97,7 +97,7 @@ PostgreSQL documentation
|
||||
Because
|
||||
<productname>PostgreSQL</productname> allows the user to define operators,
|
||||
<productname>PostgreSQL</productname> cannot look at the name of an operator
|
||||
(e.g., <literal>></> or <literal><</>) and tell what kind of
|
||||
(e.g., <literal><</> or <literal>>=</>) and tell what kind of
|
||||
comparison it is. Instead, the index access method defines a set of
|
||||
<quote>strategies</>, which can be thought of as generalized operators.
|
||||
Each operator class shows which actual operator corresponds to each
|
||||
@ -279,18 +279,16 @@ PostgreSQL documentation
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Operation</entry>
|
||||
<entry>Function</entry>
|
||||
<entry>Support Number</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>
|
||||
Compare two keys and return -1, 0,
|
||||
or +1, depending on whether the first key is less than, equal to,
|
||||
or greater than the second. (Actually, this routine can
|
||||
return any negative int32 value (< 0), zero, or any non-zero positive
|
||||
int32 value (> 0).)
|
||||
Compare two keys and return an integer less than zero, zero, or
|
||||
greater than zero, indicating whether the first key is less than, equal to,
|
||||
or greater than the second.
|
||||
</entry>
|
||||
<entry>1</entry>
|
||||
</row>
|
||||
@ -309,13 +307,13 @@ PostgreSQL documentation
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Operation</entry>
|
||||
<entry>Function</entry>
|
||||
<entry>Support Number</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>compute the hash value for a key</entry>
|
||||
<entry>Compute the hash value for a key</entry>
|
||||
<entry>1</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
@ -333,7 +331,7 @@ PostgreSQL documentation
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Operation</entry>
|
||||
<entry>Function</entry>
|
||||
<entry>Support Number</entry>
|
||||
</row>
|
||||
</thead>
|
||||
@ -365,7 +363,7 @@ PostgreSQL documentation
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Operation</entry>
|
||||
<entry>Function</entry>
|
||||
<entry>Support Number</entry>
|
||||
</row>
|
||||
</thead>
|
||||
@ -442,8 +440,8 @@ PostgreSQL documentation
|
||||
return (amag==bmag);
|
||||
}
|
||||
</programlisting>
|
||||
(Note that we will only show the equality operator for the rest of
|
||||
the examples. The other four operators are very similar. Refer to
|
||||
(Note that we will only show the equality operator in this text.
|
||||
The other four operators are very similar. Refer to
|
||||
<filename>complex.c</filename> or
|
||||
<filename>complex.source</filename> for the details.)
|
||||
</para>
|
||||
@ -555,11 +553,11 @@ CREATE FUNCTION complex_abs_cmp(complex, complex)
|
||||
<programlisting>
|
||||
CREATE OPERATOR CLASS complex_abs_ops
|
||||
DEFAULT FOR TYPE complex USING btree AS
|
||||
OPERATOR 1 < ,
|
||||
OPERATOR 2 <= ,
|
||||
OPERATOR 1 < ,
|
||||
OPERATOR 2 <= ,
|
||||
OPERATOR 3 = ,
|
||||
OPERATOR 4 >= ,
|
||||
OPERATOR 5 > ,
|
||||
OPERATOR 4 >= ,
|
||||
OPERATOR 5 > ,
|
||||
FUNCTION 1 complex_abs_cmp(complex, complex);
|
||||
</programlisting>
|
||||
</para>
|
||||
@ -572,7 +570,7 @@ CREATE OPERATOR CLASS complex_abs_ops
|
||||
<para>
|
||||
We could have written the operator entries more verbosely, as in
|
||||
<programlisting>
|
||||
OPERATOR 1 < (complex, complex) ,
|
||||
OPERATOR 1 < (complex, complex) ,
|
||||
</programlisting>
|
||||
but there is no need to do so when the operators take the same datatype
|
||||
we are defining the operator class for.
|
||||
@ -599,7 +597,7 @@ CREATE OPERATOR CLASS complex_abs_ops
|
||||
that the index access method can retrieve exactly the set of rows
|
||||
that satisfy a WHERE condition using the operator. For example,
|
||||
<programlisting>
|
||||
SELECT * FROM table WHERE integer_column < 4;
|
||||
SELECT * FROM table WHERE integer_column < 4;
|
||||
</programlisting>
|
||||
can be satisfied exactly by a B-tree index on the integer column.
|
||||
But there are cases where an index is useful as an inexact guide to
|
||||
@ -610,8 +608,8 @@ SELECT * FROM table WHERE integer_column < 4;
|
||||
box overlaps the bounding box of the target object, and then do the
|
||||
exact overlap test only on the objects found by the index. If this
|
||||
scenario applies, the index is said to be <quote>lossy</> for the
|
||||
operator, and we mark the <literal>OPERATOR</> clause in the
|
||||
<command>CREATE OPERATOR CLASS</> command with <literal>RECHECK</>.
|
||||
operator, and we add <literal>RECHECK</> to the <literal>OPERATOR</> clause
|
||||
in the <command>CREATE OPERATOR CLASS</> command.
|
||||
<literal>RECHECK</> is valid if the index is guaranteed to return
|
||||
all the required tuples, plus perhaps some additional tuples, which
|
||||
can be eliminated by performing the original operator comparison.
|
||||
|
Reference in New Issue
Block a user