1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +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

@ -4,6 +4,7 @@
#include "postgres.h"
#include "access/stratnum.h"
#include "nodes/primnodes.h"
#include "utils/builtins.h"
PG_MODULE_MAGIC;
@ -60,19 +61,19 @@ gbt_decompress(PG_FUNCTION_ARGS)
Datum
gist_stratnum_btree(PG_FUNCTION_ARGS)
{
StrategyNumber strat = PG_GETARG_UINT16(0);
CompareType cmptype = PG_GETARG_INT32(0);
switch (strat)
switch (cmptype)
{
case RTEqualStrategyNumber:
case COMPARE_EQ:
PG_RETURN_UINT16(BTEqualStrategyNumber);
case RTLessStrategyNumber:
case COMPARE_LT:
PG_RETURN_UINT16(BTLessStrategyNumber);
case RTLessEqualStrategyNumber:
case COMPARE_LE:
PG_RETURN_UINT16(BTLessEqualStrategyNumber);
case RTGreaterStrategyNumber:
case COMPARE_GT:
PG_RETURN_UINT16(BTGreaterStrategyNumber);
case RTGreaterEqualStrategyNumber:
case COMPARE_GE:
PG_RETURN_UINT16(BTGreaterEqualStrategyNumber);
default:
PG_RETURN_UINT16(InvalidStrategy);