1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Change gist stratnum function to use CompareType

This changes commit 7406ab623f 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
This commit is contained in:
Peter Eisentraut
2025-01-15 11:28:39 +01:00
parent 6339f6468e
commit 630f9a43ce
19 changed files with 145 additions and 126 deletions

View File

@ -9997,7 +9997,7 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
if (with_period)
{
StrategyNumber rtstrategy;
CompareType cmptype;
bool for_overlaps = with_period && i == numpks - 1;
/*
@ -10007,14 +10007,14 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
if (amid != GIST_AM_OID)
elog(ERROR, "only GiST indexes are supported for temporal foreign keys");
rtstrategy = for_overlaps ? RTOverlapStrategyNumber : RTEqualStrategyNumber;
cmptype = for_overlaps ? COMPARE_OVERLAP : COMPARE_EQ;
/*
* An opclass can use whatever strategy numbers it wants, so we
* ask the opclass what number it actually uses instead of our RT*
* constants.
*/
eqstrategy = GistTranslateStratnum(opclasses[i], rtstrategy);
eqstrategy = GistTranslateStratnum(opclasses[i], cmptype);
if (eqstrategy == InvalidStrategy)
{
HeapTuple tuple;
@ -10028,8 +10028,8 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
for_overlaps
? errmsg("could not identify an overlaps operator for foreign key")
: errmsg("could not identify an equality operator for foreign key"),
errdetail("Could not translate strategy number %d for operator class \"%s\" for access method \"%s\".",
rtstrategy, NameStr(((Form_pg_opclass) GETSTRUCT(tuple))->opcname), "gist"));
errdetail("Could not translate compare type %d for operator class \"%s\" for access method \"%s\".",
cmptype, NameStr(((Form_pg_opclass) GETSTRUCT(tuple))->opcname), "gist"));
}
}
else