diff options
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/gist.sgml | 65 | ||||
-rw-r--r-- | doc/src/sgml/xindex.sgml | 8 |
2 files changed, 71 insertions, 2 deletions
diff --git a/doc/src/sgml/gist.sgml b/doc/src/sgml/gist.sgml index 39c7bf370d6..f789824c83b 100644 --- a/doc/src/sgml/gist.sgml +++ b/doc/src/sgml/gist.sgml @@ -266,7 +266,7 @@ CREATE INDEX ON my_table USING GIST (my_inet_column inet_ops); <para> There are five methods that an index operator class for - <acronym>GiST</acronym> must provide, and six that are optional. + <acronym>GiST</acronym> must provide, and seven that are optional. Correctness of the index is ensured by proper implementation of the <function>same</function>, <function>consistent</function> and <function>union</function> methods, while efficiency (size and speed) of the @@ -289,6 +289,10 @@ CREATE INDEX ON my_table USING GIST (my_inet_column inet_ops); user-specified parameters. The optional eleventh method <function>sortsupport</function> is used to speed up building a <acronym>GiST</acronym> index. + The optional twelfth method <function>stratnum</function> is used to + translate well-known <literal>RT*StrategyNumber</literal>s (from + <filename>src/include/access/stratnum.h</filename>) into strategy numbers + used by the operator class. </para> <variablelist> @@ -1163,6 +1167,65 @@ my_sortsupport(PG_FUNCTION_ARGS) </para> </listitem> </varlistentry> + + <varlistentry> + <term><function>stratnum</function></term> + <listitem> + <para> + Given an <literal>RT*StrategyNumber</literal> value from + <filename>src/include/access/stratnum.h</filename>, returns a strategy + number used by this operator class for matching functionality. The + function should return <literal>InvalidStrategy</literal> if the + operator class has no matching strategy. + </para> + + <para> + The <acronym>SQL</acronym> declaration of the function must look like + this: + +<programlisting> +CREATE OR REPLACE FUNCTION my_stratnum(integer) +RETURNS integer +AS 'MODULE_PATHNAME' +LANGUAGE C STRICT; +</programlisting> + </para> + + <para> + The matching code in the C module could then follow this skeleton: + +<programlisting> +PG_FUNCTION_INFO_V1(my_stratnum); + +Datum +my_stratnum(PG_FUNCTION_ARGS) +{ + StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(1); + StrategyNumber ret = InvalidStrategy; + + switch (strategy) + { + case RTEqualStrategyNumber: + ret = BTEqualStrategyNumber; + } + + PG_RETURN_UINT16(ret); +} +</programlisting> + </para> + + <para> + One translation function is provided by + <productname>PostgreSQL</productname>: + <literal>gist_stratnum_identity</literal> is for operator classes that + already use the <literal>RT*StrategyNumber</literal> constants. It + returns whatever is passed to it. The <literal>btree_gist</literal> + extension defines a second translation function, + <literal>gist_stratnum_btree</literal>, for operator classes that use + the <literal>BT*StrategyNumber</literal> constants. + </para> + </listitem> + </varlistentry> </variablelist> <para> diff --git a/doc/src/sgml/xindex.sgml b/doc/src/sgml/xindex.sgml index 22d8ad1aac4..3a19dab15e0 100644 --- a/doc/src/sgml/xindex.sgml +++ b/doc/src/sgml/xindex.sgml @@ -508,7 +508,7 @@ </table> <para> - GiST indexes have eleven support functions, six of which are optional, + GiST indexes have twelve support functions, seven of which are optional, as shown in <xref linkend="xindex-gist-support-table"/>. (For more information see <xref linkend="gist"/>.) </para> @@ -590,6 +590,12 @@ (optional)</entry> <entry>11</entry> </row> + <row> + <entry><function>stratnum</function></entry> + <entry>translate well-known strategy numbers to ones + used by the operator class (optional)</entry> + <entry>12</entry> + </row> </tbody> </tgroup> </table> |