summaryrefslogtreecommitdiff
path: root/src/include/access/amapi.h
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2025-02-02 10:26:04 +0100
committerPeter Eisentraut <peter@eisentraut.org>2025-02-02 10:26:04 +0100
commitc09e5a6a01659a66dd84f3e745694999d3414ddd (patch)
tree85c7b89405656557e73360aa65216baf91f01a5b /src/include/access/amapi.h
parent119fc30dd5bd918819b864107ddc8baac51f4d22 (diff)
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
Diffstat (limited to 'src/include/access/amapi.h')
-rw-r--r--src/include/access/amapi.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/include/access/amapi.h b/src/include/access/amapi.h
index fb94b3d1acf..6723de75a4d 100644
--- a/src/include/access/amapi.h
+++ b/src/include/access/amapi.h
@@ -12,7 +12,9 @@
#ifndef AMAPI_H
#define AMAPI_H
+#include "access/cmptype.h"
#include "access/genam.h"
+#include "access/stratnum.h"
/*
* We don't wish to include planner header files here, since most of an index
@@ -99,6 +101,12 @@ typedef struct OpFamilyMember
* Callback function signatures --- see indexam.sgml for more info.
*/
+/* translate AM-specific strategies to general operator types */
+typedef CompareType (*amtranslate_strategy_function) (StrategyNumber strategy, Oid opfamily, Oid opcintype);
+
+/* translate general operator types to AM-specific strategies */
+typedef StrategyNumber (*amtranslate_cmptype_function) (CompareType cmptype, Oid opfamily, Oid opcintype);
+
/* build new index */
typedef IndexBuildResult *(*ambuild_function) (Relation heapRelation,
Relation indexRelation,
@@ -301,11 +309,17 @@ 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;
/* Functions in access/index/amapi.c */
extern IndexAmRoutine *GetIndexAmRoutine(Oid amhandler);
extern IndexAmRoutine *GetIndexAmRoutineByAmId(Oid amoid, bool noerror);
+extern CompareType IndexAmTranslateStrategy(StrategyNumber strategy, Oid amoid, Oid opfamily, Oid opcintype, bool missing_ok);
+extern StrategyNumber IndexAmTranslateCompareType(CompareType cmptype, Oid amoid, Oid opfamily, Oid opcintype, bool missing_ok);
#endif /* AMAPI_H */