Support for GiST in get_equal_strategy_number()

A WITHOUT OVERLAPS primary key or unique constraint is accepted as a
REPLICA IDENTITY, since it guarantees uniqueness.  But subscribers
applying logical decoding messages would fail because there was not
support for looking up the equals operator for a gist index.  This
fixes that: For GiST indexes we can use the stratnum GiST support
function.

Reviewed-by: Paul Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CA+renyUApHgSZF9-nd-a0+OPGharLQLO=mDHcY4_qQ0+noCUVg@mail.gmail.com
This commit is contained in:
Peter Eisentraut 2024-12-10 13:26:09 +01:00
parent 13544e790e
commit 74edabce7a

View File

@ -15,6 +15,7 @@
#include "postgres.h" #include "postgres.h"
#include "access/genam.h" #include "access/genam.h"
#include "access/gist.h"
#include "access/relscan.h" #include "access/relscan.h"
#include "access/tableam.h" #include "access/tableam.h"
#include "access/transam.h" #include "access/transam.h"
@ -40,11 +41,6 @@ static bool tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2,
/* /*
* Returns the fixed strategy number, if any, of the equality operator for the * Returns the fixed strategy number, if any, of the equality operator for the
* given operator class, otherwise, InvalidStrategy. * given operator class, otherwise, InvalidStrategy.
*
* Currently, only Btree and Hash indexes are supported. The other index access
* methods don't have a fixed strategy for equality operation - instead, the
* support routines of each operator class interpret the strategy numbers
* according to the operator class's definition.
*/ */
StrategyNumber StrategyNumber
get_equal_strategy_number(Oid opclass) get_equal_strategy_number(Oid opclass)
@ -60,8 +56,10 @@ get_equal_strategy_number(Oid opclass)
case HASH_AM_OID: case HASH_AM_OID:
ret = HTEqualStrategyNumber; ret = HTEqualStrategyNumber;
break; break;
case GIST_AM_OID:
ret = GistTranslateStratnum(opclass, RTEqualStrategyNumber);
break;
default: default:
/* XXX: Only Btree and Hash indexes are supported */
ret = InvalidStrategy; ret = InvalidStrategy;
break; break;
} }