Skip to content

Commit bab64ef

Browse files
committed
Fix two problems in infer_arbiter_indexes().
The first is a pretty simple bug where a relcache entry is used after the relation is closed. In this particular situation it does not appear to have bad consequences unless compiled with RELCACHE_FORCE_RELEASE. The second is that infer_arbiter_indexes() skipped indexes that aren't yet valid according to indcheckxmin. That's not required here, because uniqueness checks don't care about visibility according to an older snapshot. While thats not really a bug, it makes things undesirably non-deterministic. There is some hope that this explains a test failure on buildfarm member jaguarundi. Discussion: 9096.1431102730@sss.pgh.pa.us
1 parent de76884 commit bab64ef

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/backend/optimizer/util/plancat.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,11 @@ infer_arbiter_indexes(PlannerInfo *root)
547547
goto next;
548548

549549
/*
550-
* If the index is valid, but cannot yet be used, ignore it. See
551-
* src/backend/access/heap/README.HOT for discussion.
550+
* Note that we do not perform a check against indcheckxmin (like
551+
* e.g. get_relation_info()) here to eliminate candidates, because
552+
* uniqueness checking only cares about the most recently committed
553+
* tuple versions.
552554
*/
553-
if (idxForm->indcheckxmin &&
554-
!TransactionIdPrecedes(HeapTupleHeaderGetXmin(idxRel->rd_indextuple->t_data),
555-
TransactionXmin))
556-
goto next;
557555

558556
/*
559557
* Look for match on "ON constraint_name" variant, which may not be
@@ -566,10 +564,10 @@ infer_arbiter_indexes(PlannerInfo *root)
566564
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
567565
errmsg("ON CONFLICT DO UPDATE not supported with exclusion constraints")));
568566

567+
candidates = lappend_oid(candidates, idxForm->indexrelid);
569568
list_free(indexList);
570569
index_close(idxRel, NoLock);
571570
heap_close(relation, NoLock);
572-
candidates = lappend_oid(candidates, idxForm->indexrelid);
573571
return candidates;
574572
}
575573
else if (indexOidFromConstraint != InvalidOid)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy