Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b92c033

Browse files
peteremarkdilger
andcommitted
Allow non-btree speculative insertion indexes
Previously, only btrees were supported as the arbiter index for speculative insertion because there was no way to get the equality strategy number for other index methods. We have this now (commit c09e5a6), so we can support this. At the moment, only btree supports unique indexes, so this does not change anything in practice, but it would allow another index method that has amcanunique to be supported. Co-authored-by: Mark Dilger <mark.dilger@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com
1 parent bfe21b7 commit b92c033

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/catalog/index.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -2677,9 +2677,6 @@ BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii)
26772677
*/
26782678
Assert(ii->ii_Unique);
26792679

2680-
if (index->rd_rel->relam != BTREE_AM_OID)
2681-
elog(ERROR, "unexpected non-btree speculative unique index");
2682-
26832680
ii->ii_UniqueOps = (Oid *) palloc(sizeof(Oid) * indnkeyatts);
26842681
ii->ii_UniqueProcs = (Oid *) palloc(sizeof(Oid) * indnkeyatts);
26852682
ii->ii_UniqueStrats = (uint16 *) palloc(sizeof(uint16) * indnkeyatts);
@@ -2691,7 +2688,12 @@ BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii)
26912688
/* We need the func OIDs and strategy numbers too */
26922689
for (i = 0; i < indnkeyatts; i++)
26932690
{
2694-
ii->ii_UniqueStrats[i] = BTEqualStrategyNumber;
2691+
ii->ii_UniqueStrats[i] =
2692+
IndexAmTranslateCompareType(COMPARE_EQ,
2693+
index->rd_rel->relam,
2694+
index->rd_opfamily[i],
2695+
index->rd_opcintype[i],
2696+
false);
26952697
ii->ii_UniqueOps[i] =
26962698
get_opfamily_member(index->rd_opfamily[i],
26972699
index->rd_opcintype[i],

0 commit comments

Comments
 (0)