Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2025-01-15 10:28:39 +0000
committerPeter Eisentraut2025-01-15 10:34:04 +0000
commit630f9a43cece93cb4a5c243b30e34abce6a89514 (patch)
treeef3a4a65f971bd526919b0ee67fad92bb4590ef9 /src/backend/access/gist
parent6339f6468e8217f556e38482626250dc72d7cd00 (diff)
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')
-rw-r--r--src/backend/access/gist/gistutil.c35
-rw-r--r--src/backend/access/gist/gistvalidate.c2
2 files changed, 27 insertions, 10 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);
}
diff --git a/src/backend/access/gist/gistvalidate.c b/src/backend/access/gist/gistvalidate.c
index 499ed8c8748..bb86b559486 100644
--- a/src/backend/access/gist/gistvalidate.c
+++ b/src/backend/access/gist/gistvalidate.c
@@ -148,7 +148,7 @@ gistvalidate(Oid opclassoid)
break;
case GIST_STRATNUM_PROC:
ok = check_amproc_signature(procform->amproc, INT2OID, true,
- 1, 1, INT2OID);
+ 1, 1, INT4OID);
break;
default:
ereport(INFO,