diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2025-01-15 11:28:39 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2025-01-15 11:34:04 +0100 |
commit | 630f9a43cece93cb4a5c243b30e34abce6a89514 (patch) | |
tree | ef3a4a65f971bd526919b0ee67fad92bb4590ef9 /src/backend/access/gist/gistutil.c | |
parent | 6339f6468e8217f556e38482626250dc72d7cd00 (diff) | |
download | postgresql-630f9a43cece93cb4a5c243b30e34abce6a89514.tar.gz postgresql-630f9a43cece93cb4a5c243b30e34abce6a89514.zip |
Change gist stratnum function to use CompareType
This changes commit 7406ab623fe in that the gist strategy number
mapping support function is changed to use the CompareType enum as
input, instead of the "well-known" RT*StrategyNumber strategy numbers.
This is a bit cleaner, since you are not dealing with two sets of
strategy numbers. Also, this will enable us to subsume this system
into a more general system of using CompareType to define operator
semantics across index methods.
Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com
Diffstat (limited to 'src/backend/access/gist/gistutil.c')
-rw-r--r-- | src/backend/access/gist/gistutil.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index a2fcfbe4807..48db718b904 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -1058,27 +1058,44 @@ gistGetFakeLSN(Relation rel) } /* - * Returns the same number that was received. - * - * This is for GiST opclasses that use the RT*StrategyNumber constants. + * This is a stratnum support function for GiST opclasses that use the + * RT*StrategyNumber constants. */ Datum -gist_stratnum_identity(PG_FUNCTION_ARGS) +gist_stratnum_common(PG_FUNCTION_ARGS) { - StrategyNumber strat = PG_GETARG_UINT16(0); + CompareType cmptype = PG_GETARG_INT32(0); - PG_RETURN_UINT16(strat); + switch (cmptype) + { + case COMPARE_EQ: + PG_RETURN_UINT16(RTEqualStrategyNumber); + case COMPARE_LT: + PG_RETURN_UINT16(RTLessStrategyNumber); + case COMPARE_LE: + PG_RETURN_UINT16(RTLessEqualStrategyNumber); + case COMPARE_GT: + PG_RETURN_UINT16(RTGreaterStrategyNumber); + case COMPARE_GE: + PG_RETURN_UINT16(RTGreaterEqualStrategyNumber); + case COMPARE_OVERLAP: + PG_RETURN_UINT16(RTOverlapStrategyNumber); + case COMPARE_CONTAINED_BY: + PG_RETURN_UINT16(RTContainedByStrategyNumber); + default: + PG_RETURN_UINT16(InvalidStrategy); + } } /* - * Returns the opclass's private stratnum used for the given strategy. + * Returns the opclass's private stratnum used for the given compare type. * * Calls the opclass's GIST_STRATNUM_PROC support function, if any, * and returns the result. * Returns InvalidStrategy if the function is not defined. */ StrategyNumber -GistTranslateStratnum(Oid opclass, StrategyNumber strat) +GistTranslateStratnum(Oid opclass, CompareType cmptype) { Oid opfamily; Oid opcintype; @@ -1095,6 +1112,6 @@ GistTranslateStratnum(Oid opclass, StrategyNumber strat) return InvalidStrategy; /* Ask the translation function */ - result = OidFunctionCall1Coll(funcid, InvalidOid, UInt16GetDatum(strat)); + result = OidFunctionCall1Coll(funcid, InvalidOid, Int32GetDatum(cmptype)); return DatumGetUInt16(result); } |