1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Convert strategies to and from compare types

For each Index AM, provide a mapping between operator strategies and
the system-wide generic concept of a comparison type.  For example,
for btree, BTLessStrategyNumber maps to and from COMPARE_LT.  Numerous
places in the planner and executor think directly in terms of btree
strategy numbers (and a few in terms of hash strategy numbers.)  These
should be converted over subsequent commits to think in terms of
CompareType instead.  (This commit doesn't make any use of this API
yet.)

Author: Mark Dilger <mark.dilger@enterprisedb.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com
This commit is contained in:
Peter Eisentraut
2025-02-02 10:26:04 +01:00
parent 119fc30dd5
commit c09e5a6a01
13 changed files with 169 additions and 0 deletions

View File

@ -164,6 +164,10 @@ typedef struct IndexAmRoutine
amestimateparallelscan_function amestimateparallelscan; /* can be NULL */
aminitparallelscan_function aminitparallelscan; /* can be NULL */
amparallelrescan_function amparallelrescan; /* can be NULL */
/* interface functions to support planning */
amtranslate_strategy_function amtranslatestrategy; /* can be NULL */
amtranslate_cmptype_function amtranslatecmptype; /* can be NULL */
} IndexAmRoutine;
</programlisting>
</para>
@ -876,6 +880,28 @@ amparallelrescan (IndexScanDesc scan);
the beginning.
</para>
<para>
<programlisting>
CompareType
amtranslatestrategy (StrategyNumber strategy, Oid opfamily, Oid opcintype);
StrategyNumber
amtranslatecmptype (CompareType cmptype, Oid opfamily, Oid opcintype);
</programlisting>
These functions, if implemented, will be called by the planer and executor
to convert between fixed <type>CompareType</type> values and the specific
strategy numbers used by the access method. These functions can be
implemented by access methods that implement functionality similar to the
built-in btree or hash access methods, and by implementing these
translations, the system can learn about the semantics of the access
method's operations and can use them in place of btree or hash indexes in
various places. If the functionality of the access method is not similar
to those built-in access methods, these functions do not need to be
implemented. If the functions are not implemented, the access method will
be ignored for certain planner and executor decisions, but is otherwise
fully functional.
</para>
</sect1>
<sect1 id="index-scanning">