diff options
author | Peter Eisentraut | 2025-06-02 06:33:04 +0000 |
---|---|---|
committer | Peter Eisentraut | 2025-06-02 06:41:27 +0000 |
commit | 32edf732e8dc9eb3e7a923aeb67d49246744a20a (patch) | |
tree | 16156ef00c2a2d2170268a652c557945e34fce29 /doc/src/sgml/gist.sgml | |
parent | 5231ed8262c94936a69bce41f64076630bbd99a2 (diff) |
Rename gist stratnum support function
Commit 7406ab623fe added a gist support function that we internally
refer to by the symbol GIST_STRATNUM_PROC. This translated from
"well-known" strategy numbers to opfamily-specific strategy numbers.
However, we later (commit 630f9a43cec) changed this to fit into
index-AM-level compare type mapping, so this function actually now
maps from compare type to opfamily-specific strategy numbers. So this
name is no longer fitting.
Moreover, the index AM level also supports the opposite, a function to
map from strategy number to compare type. This is currently not
supported in gist, but one might wonder what this function is supposed
to be called when it is added.
This patch changes the naming of the gist-level functionality to be
more in line with the index-AM-level functionality. This makes sense
because these are essentially the same thing on different levels.
This also changes the names of the externally visible functions that
are provided for use as such a support function.
Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://www.postgresql.org/message-id/37ebb1d9-9036-485f-a215-e55435689917%40eisentraut.org
Diffstat (limited to 'doc/src/sgml/gist.sgml')
-rw-r--r-- | doc/src/sgml/gist.sgml | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/doc/src/sgml/gist.sgml b/doc/src/sgml/gist.sgml index a373a8aa4b2..ee86e170055 100644 --- a/doc/src/sgml/gist.sgml +++ b/doc/src/sgml/gist.sgml @@ -1170,7 +1170,7 @@ my_sortsupport(PG_FUNCTION_ARGS) </varlistentry> <varlistentry> - <term><function>stratnum</function></term> + <term><function>translate_cmptype</function></term> <listitem> <para> Given a <literal>CompareType</literal> value from @@ -1189,11 +1189,22 @@ my_sortsupport(PG_FUNCTION_ARGS) </para> <para> + This support function corresponds to the index access method callback + function <structfield>amtranslatecmptype</structfield> (see <xref + linkend="index-functions"/>). The + <structfield>amtranslatecmptype</structfield> callback function for + GiST indexes merely calls down to the + <function>translate_cmptype</function> support function of the + respective operator family, since the GiST index access method has no + fixed strategy numbers itself. + </para> + + <para> The <acronym>SQL</acronym> declaration of the function must look like this: <programlisting> -CREATE OR REPLACE FUNCTION my_stratnum(integer) +CREATE OR REPLACE FUNCTION my_translate_cmptype(integer) RETURNS smallint AS 'MODULE_PATHNAME' LANGUAGE C STRICT; @@ -1202,7 +1213,7 @@ LANGUAGE C STRICT; And the operator family registration must look like this: <programlisting> ALTER OPERATOR FAMILY my_opfamily USING gist ADD - FUNCTION 12 ("any", "any") my_stratnum(int); + FUNCTION 12 ("any", "any") my_translate_cmptype(int); </programlisting> </para> @@ -1210,10 +1221,10 @@ ALTER OPERATOR FAMILY my_opfamily USING gist ADD The matching code in the C module could then follow this skeleton: <programlisting> -PG_FUNCTION_INFO_V1(my_stratnum); +PG_FUNCTION_INFO_V1(my_translate_cmptype); Datum -my_stratnum(PG_FUNCTION_ARGS) +my_translate_cmptype(PG_FUNCTION_ARGS) { CompareType cmptype = PG_GETARG_INT32(0); StrategyNumber ret = InvalidStrategy; @@ -1232,11 +1243,11 @@ my_stratnum(PG_FUNCTION_ARGS) <para> One translation function is provided by <productname>PostgreSQL</productname>: - <literal>gist_stratnum_common</literal> is for operator classes that + <literal>gist_translate_cmptype_common</literal> is for operator classes that use the <literal>RT*StrategyNumber</literal> constants. The <literal>btree_gist</literal> extension defines a second translation function, - <literal>gist_stratnum_btree</literal>, for operator classes that use + <literal>gist_translate_cmptype_btree</literal>, for operator classes that use the <literal>BT*StrategyNumber</literal> constants. </para> </listitem> |