PostgreSQL Source Code git master
execIndexing.c File Reference
#include "postgres.h"
#include "access/genam.h"
#include "access/relscan.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/index.h"
#include "executor/executor.h"
#include "nodes/nodeFuncs.h"
#include "storage/lmgr.h"
#include "utils/injection_point.h"
#include "utils/multirangetypes.h"
#include "utils/rangetypes.h"
#include "utils/snapmgr.h"
Include dependency graph for execIndexing.c:

Go to the source code of this file.

Enumerations

enum  CEOUC_WAIT_MODE { CEOUC_WAIT , CEOUC_NOWAIT , CEOUC_LIVELOCK_PREVENTING_WAIT }
 

Functions

static bool check_exclusion_or_unique_constraint (Relation heap, Relation index, IndexInfo *indexInfo, const ItemPointerData *tupleid, const Datum *values, const bool *isnull, EState *estate, bool newIndex, CEOUC_WAIT_MODE waitMode, bool violationOK, ItemPointer conflictTid)
 
static bool index_recheck_constraint (Relation index, const Oid *constr_procs, const Datum *existing_values, const bool *existing_isnull, const Datum *new_values)
 
static bool index_unchanged_by_update (ResultRelInfo *resultRelInfo, EState *estate, IndexInfo *indexInfo, Relation indexRelation)
 
static bool index_expression_changed_walker (Node *node, Bitmapset *allUpdatedCols)
 
static void ExecWithoutOverlapsNotEmpty (Relation rel, NameData attname, Datum attval, char typtype, Oid atttypid)
 
void ExecOpenIndices (ResultRelInfo *resultRelInfo, bool speculative)
 
void ExecCloseIndices (ResultRelInfo *resultRelInfo)
 
ListExecInsertIndexTuples (ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool update, bool noDupErr, bool *specConflict, List *arbiterIndexes, bool onlySummarizing)
 
bool ExecCheckIndexConstraints (ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, ItemPointer conflictTid, const ItemPointerData *tupleid, List *arbiterIndexes)
 
void check_exclusion_constraint (Relation heap, Relation index, IndexInfo *indexInfo, const ItemPointerData *tupleid, const Datum *values, const bool *isnull, EState *estate, bool newIndex)
 

Enumeration Type Documentation

◆ CEOUC_WAIT_MODE

Enumerator
CEOUC_WAIT 
CEOUC_NOWAIT 
CEOUC_LIVELOCK_PREVENTING_WAIT 

Definition at line 123 of file execIndexing.c.

124{
CEOUC_WAIT_MODE
Definition: execIndexing.c:124
@ CEOUC_NOWAIT
Definition: execIndexing.c:126
@ CEOUC_WAIT
Definition: execIndexing.c:125
@ CEOUC_LIVELOCK_PREVENTING_WAIT
Definition: execIndexing.c:127

Function Documentation

◆ check_exclusion_constraint()

void check_exclusion_constraint ( Relation  heap,
Relation  index,
IndexInfo indexInfo,
const ItemPointerData tupleid,
const Datum values,
const bool *  isnull,
EState estate,
bool  newIndex 
)

Definition at line 962 of file execIndexing.c.

967{
968 (void) check_exclusion_or_unique_constraint(heap, index, indexInfo, tupleid,
969 values, isnull,
970 estate, newIndex,
971 CEOUC_WAIT, false, NULL);
972}
static Datum values[MAXATTR]
Definition: bootstrap.c:153
static bool check_exclusion_or_unique_constraint(Relation heap, Relation index, IndexInfo *indexInfo, const ItemPointerData *tupleid, const Datum *values, const bool *isnull, EState *estate, bool newIndex, CEOUC_WAIT_MODE waitMode, bool violationOK, ItemPointer conflictTid)
Definition: execIndexing.c:705
Definition: type.h:96

References CEOUC_WAIT, check_exclusion_or_unique_constraint(), and values.

Referenced by IndexCheckExclusion().

◆ check_exclusion_or_unique_constraint()

static bool check_exclusion_or_unique_constraint ( Relation  heap,
Relation  index,
IndexInfo indexInfo,
const ItemPointerData tupleid,
const Datum values,
const bool *  isnull,
EState estate,
bool  newIndex,
CEOUC_WAIT_MODE  waitMode,
bool  violationOK,
ItemPointer  conflictTid 
)
static

Definition at line 705 of file execIndexing.c.

713{
714 Oid *constr_procs;
715 uint16 *constr_strats;
716 Oid *index_collations = index->rd_indcollation;
718 IndexScanDesc index_scan;
719 ScanKeyData scankeys[INDEX_MAX_KEYS];
720 SnapshotData DirtySnapshot;
721 int i;
722 bool conflict;
723 bool found_self;
724 ExprContext *econtext;
725 TupleTableSlot *existing_slot;
726 TupleTableSlot *save_scantuple;
727
728 if (indexInfo->ii_ExclusionOps)
729 {
730 constr_procs = indexInfo->ii_ExclusionProcs;
731 constr_strats = indexInfo->ii_ExclusionStrats;
732 }
733 else
734 {
735 constr_procs = indexInfo->ii_UniqueProcs;
736 constr_strats = indexInfo->ii_UniqueStrats;
737 }
738
739 /*
740 * If this is a WITHOUT OVERLAPS constraint, we must also forbid empty
741 * ranges/multiranges. This must happen before we look for NULLs below, or
742 * a UNIQUE constraint could insert an empty range along with a NULL
743 * scalar part.
744 */
745 if (indexInfo->ii_WithoutOverlaps)
746 {
747 /*
748 * Look up the type from the heap tuple, but check the Datum from the
749 * index tuple.
750 */
751 AttrNumber attno = indexInfo->ii_IndexAttrNumbers[indnkeyatts - 1];
752
753 if (!isnull[indnkeyatts - 1])
754 {
755 TupleDesc tupdesc = RelationGetDescr(heap);
756 Form_pg_attribute att = TupleDescAttr(tupdesc, attno - 1);
757 TypeCacheEntry *typcache = lookup_type_cache(att->atttypid, 0);
758
759 ExecWithoutOverlapsNotEmpty(heap, att->attname,
760 values[indnkeyatts - 1],
761 typcache->typtype, att->atttypid);
762 }
763 }
764
765 /*
766 * If any of the input values are NULL, and the index uses the default
767 * nulls-are-distinct mode, the constraint check is assumed to pass (i.e.,
768 * we assume the operators are strict). Otherwise, we interpret the
769 * constraint as specifying IS NULL for each column whose input value is
770 * NULL.
771 */
772 if (!indexInfo->ii_NullsNotDistinct)
773 {
774 for (i = 0; i < indnkeyatts; i++)
775 {
776 if (isnull[i])
777 return true;
778 }
779 }
780
781 /*
782 * Search the tuples that are in the index for any violations, including
783 * tuples that aren't visible yet.
784 */
785 InitDirtySnapshot(DirtySnapshot);
786
787 for (i = 0; i < indnkeyatts; i++)
788 {
789 ScanKeyEntryInitialize(&scankeys[i],
790 isnull[i] ? SK_ISNULL | SK_SEARCHNULL : 0,
791 i + 1,
792 constr_strats[i],
794 index_collations[i],
795 constr_procs[i],
796 values[i]);
797 }
798
799 /*
800 * Need a TupleTableSlot to put existing tuples in.
801 *
802 * To use FormIndexDatum, we have to make the econtext's scantuple point
803 * to this slot. Be sure to save and restore caller's value for
804 * scantuple.
805 */
806 existing_slot = table_slot_create(heap, NULL);
807
808 econtext = GetPerTupleExprContext(estate);
809 save_scantuple = econtext->ecxt_scantuple;
810 econtext->ecxt_scantuple = existing_slot;
811
812 /*
813 * May have to restart scan from this point if a potential conflict is
814 * found.
815 */
816retry:
817 conflict = false;
818 found_self = false;
819 index_scan = index_beginscan(heap, index, &DirtySnapshot, NULL, indnkeyatts, 0);
820 index_rescan(index_scan, scankeys, indnkeyatts, NULL, 0);
821
822 while (index_getnext_slot(index_scan, ForwardScanDirection, existing_slot))
823 {
824 TransactionId xwait;
825 XLTW_Oper reason_wait;
826 Datum existing_values[INDEX_MAX_KEYS];
827 bool existing_isnull[INDEX_MAX_KEYS];
828 char *error_new;
829 char *error_existing;
830
831 /*
832 * Ignore the entry for the tuple we're trying to check.
833 */
834 if (ItemPointerIsValid(tupleid) &&
835 ItemPointerEquals(tupleid, &existing_slot->tts_tid))
836 {
837 if (found_self) /* should not happen */
838 elog(ERROR, "found self tuple multiple times in index \"%s\"",
840 found_self = true;
841 continue;
842 }
843
844 /*
845 * Extract the index column values and isnull flags from the existing
846 * tuple.
847 */
848 FormIndexDatum(indexInfo, existing_slot, estate,
849 existing_values, existing_isnull);
850
851 /* If lossy indexscan, must recheck the condition */
852 if (index_scan->xs_recheck)
853 {
855 constr_procs,
856 existing_values,
857 existing_isnull,
858 values))
859 continue; /* tuple doesn't actually match, so no
860 * conflict */
861 }
862
863 /*
864 * At this point we have either a conflict or a potential conflict.
865 *
866 * If an in-progress transaction is affecting the visibility of this
867 * tuple, we need to wait for it to complete and then recheck (unless
868 * the caller requested not to). For simplicity we do rechecking by
869 * just restarting the whole scan --- this case probably doesn't
870 * happen often enough to be worth trying harder, and anyway we don't
871 * want to hold any index internal locks while waiting.
872 */
873 xwait = TransactionIdIsValid(DirtySnapshot.xmin) ?
874 DirtySnapshot.xmin : DirtySnapshot.xmax;
875
876 if (TransactionIdIsValid(xwait) &&
877 (waitMode == CEOUC_WAIT ||
878 (waitMode == CEOUC_LIVELOCK_PREVENTING_WAIT &&
879 DirtySnapshot.speculativeToken &&
881 {
882 reason_wait = indexInfo->ii_ExclusionOps ?
884 index_endscan(index_scan);
885 if (DirtySnapshot.speculativeToken)
886 SpeculativeInsertionWait(DirtySnapshot.xmin,
887 DirtySnapshot.speculativeToken);
888 else
889 XactLockTableWait(xwait, heap,
890 &existing_slot->tts_tid, reason_wait);
891 goto retry;
892 }
893
894 /*
895 * We have a definite conflict (or a potential one, but the caller
896 * didn't want to wait). Return it to caller, or report it.
897 */
898 if (violationOK)
899 {
900 conflict = true;
901 if (conflictTid)
902 *conflictTid = existing_slot->tts_tid;
903 break;
904 }
905
906 error_new = BuildIndexValueDescription(index, values, isnull);
907 error_existing = BuildIndexValueDescription(index, existing_values,
908 existing_isnull);
909 if (newIndex)
911 (errcode(ERRCODE_EXCLUSION_VIOLATION),
912 errmsg("could not create exclusion constraint \"%s\"",
914 error_new && error_existing ?
915 errdetail("Key %s conflicts with key %s.",
916 error_new, error_existing) :
917 errdetail("Key conflicts exist."),
920 else
922 (errcode(ERRCODE_EXCLUSION_VIOLATION),
923 errmsg("conflicting key value violates exclusion constraint \"%s\"",
925 error_new && error_existing ?
926 errdetail("Key %s conflicts with existing key %s.",
927 error_new, error_existing) :
928 errdetail("Key conflicts with existing key."),
931 }
932
933 index_endscan(index_scan);
934
935 /*
936 * Ordinarily, at this point the search should have found the originally
937 * inserted tuple (if any), unless we exited the loop early because of
938 * conflict. However, it is possible to define exclusion constraints for
939 * which that wouldn't be true --- for instance, if the operator is <>. So
940 * we no longer complain if found_self is still false.
941 */
942
943 econtext->ecxt_scantuple = save_scantuple;
944
945 ExecDropSingleTupleTableSlot(existing_slot);
946
947#ifdef USE_INJECTION_POINTS
948 if (!conflict)
949 INJECTION_POINT("check-exclusion-or-unique-constraint-no-conflict", NULL);
950#endif
951
952 return !conflict;
953}
int16 AttrNumber
Definition: attnum.h:21
uint16_t uint16
Definition: c.h:540
uint32 TransactionId
Definition: c.h:660
int errdetail(const char *fmt,...)
Definition: elog.c:1216
int errcode(int sqlerrcode)
Definition: elog.c:863
int errmsg(const char *fmt,...)
Definition: elog.c:1080
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
#define ereport(elevel,...)
Definition: elog.h:150
static bool index_recheck_constraint(Relation index, const Oid *constr_procs, const Datum *existing_values, const bool *existing_isnull, const Datum *new_values)
Definition: execIndexing.c:979
static void ExecWithoutOverlapsNotEmpty(Relation rel, NameData attname, Datum attval, char typtype, Oid atttypid)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
Definition: execTuples.c:1443
#define GetPerTupleExprContext(estate)
Definition: executor.h:656
char * BuildIndexValueDescription(Relation indexRelation, const Datum *values, const bool *isnull)
Definition: genam.c:178
void FormIndexDatum(IndexInfo *indexInfo, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
Definition: index.c:2730
bool index_getnext_slot(IndexScanDesc scan, ScanDirection direction, TupleTableSlot *slot)
Definition: indexam.c:730
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, IndexScanInstrumentation *instrument, int nkeys, int norderbys)
Definition: indexam.c:256
void index_endscan(IndexScanDesc scan)
Definition: indexam.c:392
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
Definition: indexam.c:366
#define INJECTION_POINT(name, arg)
int i
Definition: isn.c:77
bool ItemPointerEquals(const ItemPointerData *pointer1, const ItemPointerData *pointer2)
Definition: itemptr.c:35
static bool ItemPointerIsValid(const ItemPointerData *pointer)
Definition: itemptr.h:83
void SpeculativeInsertionWait(TransactionId xid, uint32 token)
Definition: lmgr.c:828
void XactLockTableWait(TransactionId xid, Relation rel, const ItemPointerData *ctid, XLTW_Oper oper)
Definition: lmgr.c:663
XLTW_Oper
Definition: lmgr.h:25
@ XLTW_InsertIndex
Definition: lmgr.h:31
@ XLTW_RecheckExclusionConstr
Definition: lmgr.h:34
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:202
#define INDEX_MAX_KEYS
uint64_t Datum
Definition: postgres.h:70
#define InvalidOid
Definition: postgres_ext.h:37
unsigned int Oid
Definition: postgres_ext.h:32
#define RelationGetDescr(relation)
Definition: rel.h:541
#define RelationGetRelationName(relation)
Definition: rel.h:549
#define IndexRelationGetNumberOfKeyAttributes(relation)
Definition: rel.h:534
int errtableconstraint(Relation rel, const char *conname)
Definition: relcache.c:6103
void ScanKeyEntryInitialize(ScanKey entry, int flags, AttrNumber attributeNumber, StrategyNumber strategy, Oid subtype, Oid collation, RegProcedure procedure, Datum argument)
Definition: scankey.c:32
@ ForwardScanDirection
Definition: sdir.h:28
#define SK_SEARCHNULL
Definition: skey.h:121
#define SK_ISNULL
Definition: skey.h:115
#define InitDirtySnapshot(snapshotdata)
Definition: snapmgr.h:42
TupleTableSlot * ecxt_scantuple
Definition: execnodes.h:273
uint16 * ii_ExclusionStrats
Definition: execnodes.h:192
Oid * ii_ExclusionOps
Definition: execnodes.h:188
bool ii_NullsNotDistinct
Definition: execnodes.h:202
uint16 * ii_UniqueStrats
Definition: execnodes.h:197
bool ii_WithoutOverlaps
Definition: execnodes.h:216
Oid * ii_ExclusionProcs
Definition: execnodes.h:190
AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS]
Definition: execnodes.h:175
Oid * ii_UniqueProcs
Definition: execnodes.h:196
TransactionId xmin
Definition: snapshot.h:153
TransactionId xmax
Definition: snapshot.h:154
uint32 speculativeToken
Definition: snapshot.h:189
ItemPointerData tts_tid
Definition: tuptable.h:128
char typtype
Definition: typcache.h:43
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
Definition: tableam.c:92
#define TransactionIdIsValid(xid)
Definition: transam.h:41
static bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.h:263
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition: tupdesc.h:160
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:386
TransactionId GetCurrentTransactionId(void)
Definition: xact.c:455

References BuildIndexValueDescription(), CEOUC_LIVELOCK_PREVENTING_WAIT, CEOUC_WAIT, ExprContext::ecxt_scantuple, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, errtableconstraint(), ExecDropSingleTupleTableSlot(), ExecWithoutOverlapsNotEmpty(), FormIndexDatum(), ForwardScanDirection, GetCurrentTransactionId(), GetPerTupleExprContext, i, IndexInfo::ii_ExclusionOps, IndexInfo::ii_ExclusionProcs, IndexInfo::ii_ExclusionStrats, IndexInfo::ii_IndexAttrNumbers, IndexInfo::ii_NullsNotDistinct, IndexInfo::ii_UniqueProcs, IndexInfo::ii_UniqueStrats, IndexInfo::ii_WithoutOverlaps, index_beginscan(), index_endscan(), index_getnext_slot(), INDEX_MAX_KEYS, index_recheck_constraint(), index_rescan(), IndexRelationGetNumberOfKeyAttributes, InitDirtySnapshot, INJECTION_POINT, InvalidOid, ItemPointerEquals(), ItemPointerIsValid(), lookup_type_cache(), RelationGetDescr, RelationGetRelationName, ScanKeyEntryInitialize(), SK_ISNULL, SK_SEARCHNULL, SpeculativeInsertionWait(), SnapshotData::speculativeToken, table_slot_create(), TransactionIdIsValid, TransactionIdPrecedes(), TupleTableSlot::tts_tid, TupleDescAttr(), TypeCacheEntry::typtype, values, XactLockTableWait(), XLTW_InsertIndex, XLTW_RecheckExclusionConstr, SnapshotData::xmax, SnapshotData::xmin, and IndexScanDescData::xs_recheck.

Referenced by check_exclusion_constraint(), ExecCheckIndexConstraints(), and ExecInsertIndexTuples().

◆ ExecCheckIndexConstraints()

bool ExecCheckIndexConstraints ( ResultRelInfo resultRelInfo,
TupleTableSlot slot,
EState estate,
ItemPointer  conflictTid,
const ItemPointerData tupleid,
List arbiterIndexes 
)

Definition at line 543 of file execIndexing.c.

546{
547 int i;
548 int numIndices;
549 RelationPtr relationDescs;
550 Relation heapRelation;
551 IndexInfo **indexInfoArray;
552 ExprContext *econtext;
554 bool isnull[INDEX_MAX_KEYS];
555 ItemPointerData invalidItemPtr;
556 bool checkedIndex = false;
557
558 ItemPointerSetInvalid(conflictTid);
559 ItemPointerSetInvalid(&invalidItemPtr);
560
561 /*
562 * Get information from the result relation info structure.
563 */
564 numIndices = resultRelInfo->ri_NumIndices;
565 relationDescs = resultRelInfo->ri_IndexRelationDescs;
566 indexInfoArray = resultRelInfo->ri_IndexRelationInfo;
567 heapRelation = resultRelInfo->ri_RelationDesc;
568
569 /*
570 * We will use the EState's per-tuple context for evaluating predicates
571 * and index expressions (creating it if it's not already there).
572 */
573 econtext = GetPerTupleExprContext(estate);
574
575 /* Arrange for econtext's scan tuple to be the tuple under test */
576 econtext->ecxt_scantuple = slot;
577
578 /*
579 * For each index, form index tuple and check if it satisfies the
580 * constraint.
581 */
582 for (i = 0; i < numIndices; i++)
583 {
584 Relation indexRelation = relationDescs[i];
585 IndexInfo *indexInfo;
586 bool satisfiesConstraint;
587
588 if (indexRelation == NULL)
589 continue;
590
591 indexInfo = indexInfoArray[i];
592
593 if (!indexInfo->ii_Unique && !indexInfo->ii_ExclusionOps)
594 continue;
595
596 /* If the index is marked as read-only, ignore it */
597 if (!indexInfo->ii_ReadyForInserts)
598 continue;
599
600 /* When specific arbiter indexes requested, only examine them */
601 if (arbiterIndexes != NIL &&
602 !list_member_oid(arbiterIndexes,
603 indexRelation->rd_index->indexrelid))
604 continue;
605
606 if (!indexRelation->rd_index->indimmediate)
608 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
609 errmsg("ON CONFLICT does not support deferrable unique constraints/exclusion constraints as arbiters"),
610 errtableconstraint(heapRelation,
611 RelationGetRelationName(indexRelation))));
612
613 checkedIndex = true;
614
615 /* Check for partial index */
616 if (indexInfo->ii_Predicate != NIL)
617 {
618 ExprState *predicate;
619
620 /*
621 * If predicate state not set up yet, create it (in the estate's
622 * per-query context)
623 */
624 predicate = indexInfo->ii_PredicateState;
625 if (predicate == NULL)
626 {
627 predicate = ExecPrepareQual(indexInfo->ii_Predicate, estate);
628 indexInfo->ii_PredicateState = predicate;
629 }
630
631 /* Skip this index-update if the predicate isn't satisfied */
632 if (!ExecQual(predicate, econtext))
633 continue;
634 }
635
636 /*
637 * FormIndexDatum fills in its values and isnull parameters with the
638 * appropriate values for the column(s) of the index.
639 */
640 FormIndexDatum(indexInfo,
641 slot,
642 estate,
643 values,
644 isnull);
645
646 satisfiesConstraint =
647 check_exclusion_or_unique_constraint(heapRelation, indexRelation,
648 indexInfo, tupleid,
649 values, isnull, estate, false,
650 CEOUC_WAIT, true,
651 conflictTid);
652 if (!satisfiesConstraint)
653 return false;
654 }
655
656 if (arbiterIndexes != NIL && !checkedIndex)
657 elog(ERROR, "unexpected failure to find arbiter index");
658
659 return true;
660}
ExprState * ExecPrepareQual(List *qual, EState *estate)
Definition: execExpr.c:793
static bool ExecQual(ExprState *state, ExprContext *econtext)
Definition: executor.h:519
static void ItemPointerSetInvalid(ItemPointerData *pointer)
Definition: itemptr.h:184
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:722
#define NIL
Definition: pg_list.h:68
bool ii_Unique
Definition: execnodes.h:200
ExprState * ii_PredicateState
Definition: execnodes.h:185
bool ii_ReadyForInserts
Definition: execnodes.h:204
List * ii_Predicate
Definition: execnodes.h:183
Form_pg_index rd_index
Definition: rel.h:192
int ri_NumIndices
Definition: execnodes.h:483
Relation ri_RelationDesc
Definition: execnodes.h:480
RelationPtr ri_IndexRelationDescs
Definition: execnodes.h:486
IndexInfo ** ri_IndexRelationInfo
Definition: execnodes.h:489

References CEOUC_WAIT, check_exclusion_or_unique_constraint(), ExprContext::ecxt_scantuple, elog, ereport, errcode(), errmsg(), ERROR, errtableconstraint(), ExecPrepareQual(), ExecQual(), FormIndexDatum(), GetPerTupleExprContext, i, IndexInfo::ii_ExclusionOps, IndexInfo::ii_Predicate, IndexInfo::ii_PredicateState, IndexInfo::ii_ReadyForInserts, IndexInfo::ii_Unique, INDEX_MAX_KEYS, ItemPointerSetInvalid(), list_member_oid(), NIL, RelationData::rd_index, RelationGetRelationName, ResultRelInfo::ri_IndexRelationDescs, ResultRelInfo::ri_IndexRelationInfo, ResultRelInfo::ri_NumIndices, ResultRelInfo::ri_RelationDesc, and values.

Referenced by ExecInsert(), and FindConflictTuple().

◆ ExecCloseIndices()

void ExecCloseIndices ( ResultRelInfo resultRelInfo)

Definition at line 239 of file execIndexing.c.

240{
241 int i;
242 int numIndices;
243 RelationPtr indexDescs;
244 IndexInfo **indexInfos;
245
246 numIndices = resultRelInfo->ri_NumIndices;
247 indexDescs = resultRelInfo->ri_IndexRelationDescs;
248 indexInfos = resultRelInfo->ri_IndexRelationInfo;
249
250 for (i = 0; i < numIndices; i++)
251 {
252 /* This Assert will fail if ExecCloseIndices is called twice */
253 Assert(indexDescs[i] != NULL);
254
255 /* Give the index a chance to do some post-insert cleanup */
256 index_insert_cleanup(indexDescs[i], indexInfos[i]);
257
258 /* Drop lock acquired by ExecOpenIndices */
259 index_close(indexDescs[i], RowExclusiveLock);
260
261 /* Mark the index as closed */
262 indexDescs[i] = NULL;
263 }
264
265 /*
266 * We don't attempt to free the IndexInfo data structures or the arrays,
267 * instead assuming that such stuff will be cleaned up automatically in
268 * FreeExecutorState.
269 */
270}
Assert(PointerIsAligned(start, uint64))
void index_insert_cleanup(Relation indexRelation, IndexInfo *indexInfo)
Definition: indexam.c:241
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:177
#define RowExclusiveLock
Definition: lockdefs.h:38

References Assert(), i, index_close(), index_insert_cleanup(), ResultRelInfo::ri_IndexRelationDescs, ResultRelInfo::ri_IndexRelationInfo, ResultRelInfo::ri_NumIndices, and RowExclusiveLock.

Referenced by apply_handle_delete(), apply_handle_insert(), apply_handle_update_internal(), CatalogCloseIndexes(), ExecCleanupTupleRouting(), and ExecCloseResultRelations().

◆ ExecInsertIndexTuples()

List * ExecInsertIndexTuples ( ResultRelInfo resultRelInfo,
TupleTableSlot slot,
EState estate,
bool  update,
bool  noDupErr,
bool *  specConflict,
List arbiterIndexes,
bool  onlySummarizing 
)

Definition at line 310 of file execIndexing.c.

318{
319 ItemPointer tupleid = &slot->tts_tid;
320 List *result = NIL;
321 int i;
322 int numIndices;
323 RelationPtr relationDescs;
324 Relation heapRelation;
325 IndexInfo **indexInfoArray;
326 ExprContext *econtext;
328 bool isnull[INDEX_MAX_KEYS];
329
330 Assert(ItemPointerIsValid(tupleid));
331
332 /*
333 * Get information from the result relation info structure.
334 */
335 numIndices = resultRelInfo->ri_NumIndices;
336 relationDescs = resultRelInfo->ri_IndexRelationDescs;
337 indexInfoArray = resultRelInfo->ri_IndexRelationInfo;
338 heapRelation = resultRelInfo->ri_RelationDesc;
339
340 /* Sanity check: slot must belong to the same rel as the resultRelInfo. */
341 Assert(slot->tts_tableOid == RelationGetRelid(heapRelation));
342
343 /*
344 * We will use the EState's per-tuple context for evaluating predicates
345 * and index expressions (creating it if it's not already there).
346 */
347 econtext = GetPerTupleExprContext(estate);
348
349 /* Arrange for econtext's scan tuple to be the tuple under test */
350 econtext->ecxt_scantuple = slot;
351
352 /*
353 * for each index, form and insert the index tuple
354 */
355 for (i = 0; i < numIndices; i++)
356 {
357 Relation indexRelation = relationDescs[i];
358 IndexInfo *indexInfo;
359 bool applyNoDupErr;
360 IndexUniqueCheck checkUnique;
361 bool indexUnchanged;
362 bool satisfiesConstraint;
363
364 if (indexRelation == NULL)
365 continue;
366
367 indexInfo = indexInfoArray[i];
368
369 /* If the index is marked as read-only, ignore it */
370 if (!indexInfo->ii_ReadyForInserts)
371 continue;
372
373 /*
374 * Skip processing of non-summarizing indexes if we only update
375 * summarizing indexes
376 */
377 if (onlySummarizing && !indexInfo->ii_Summarizing)
378 continue;
379
380 /* Check for partial index */
381 if (indexInfo->ii_Predicate != NIL)
382 {
383 ExprState *predicate;
384
385 /*
386 * If predicate state not set up yet, create it (in the estate's
387 * per-query context)
388 */
389 predicate = indexInfo->ii_PredicateState;
390 if (predicate == NULL)
391 {
392 predicate = ExecPrepareQual(indexInfo->ii_Predicate, estate);
393 indexInfo->ii_PredicateState = predicate;
394 }
395
396 /* Skip this index-update if the predicate isn't satisfied */
397 if (!ExecQual(predicate, econtext))
398 continue;
399 }
400
401 /*
402 * FormIndexDatum fills in its values and isnull parameters with the
403 * appropriate values for the column(s) of the index.
404 */
405 FormIndexDatum(indexInfo,
406 slot,
407 estate,
408 values,
409 isnull);
410
411 /* Check whether to apply noDupErr to this index */
412 applyNoDupErr = noDupErr &&
413 (arbiterIndexes == NIL ||
414 list_member_oid(arbiterIndexes,
415 indexRelation->rd_index->indexrelid));
416
417 /*
418 * The index AM does the actual insertion, plus uniqueness checking.
419 *
420 * For an immediate-mode unique index, we just tell the index AM to
421 * throw error if not unique.
422 *
423 * For a deferrable unique index, we tell the index AM to just detect
424 * possible non-uniqueness, and we add the index OID to the result
425 * list if further checking is needed.
426 *
427 * For a speculative insertion (used by INSERT ... ON CONFLICT), do
428 * the same as for a deferrable unique index.
429 */
430 if (!indexRelation->rd_index->indisunique)
431 checkUnique = UNIQUE_CHECK_NO;
432 else if (applyNoDupErr)
433 checkUnique = UNIQUE_CHECK_PARTIAL;
434 else if (indexRelation->rd_index->indimmediate)
435 checkUnique = UNIQUE_CHECK_YES;
436 else
437 checkUnique = UNIQUE_CHECK_PARTIAL;
438
439 /*
440 * There's definitely going to be an index_insert() call for this
441 * index. If we're being called as part of an UPDATE statement,
442 * consider if the 'indexUnchanged' = true hint should be passed.
443 */
444 indexUnchanged = update && index_unchanged_by_update(resultRelInfo,
445 estate,
446 indexInfo,
447 indexRelation);
448
449 satisfiesConstraint =
450 index_insert(indexRelation, /* index relation */
451 values, /* array of index Datums */
452 isnull, /* null flags */
453 tupleid, /* tid of heap tuple */
454 heapRelation, /* heap relation */
455 checkUnique, /* type of uniqueness check to do */
456 indexUnchanged, /* UPDATE without logical change? */
457 indexInfo); /* index AM may need this */
458
459 /*
460 * If the index has an associated exclusion constraint, check that.
461 * This is simpler than the process for uniqueness checks since we
462 * always insert first and then check. If the constraint is deferred,
463 * we check now anyway, but don't throw error on violation or wait for
464 * a conclusive outcome from a concurrent insertion; instead we'll
465 * queue a recheck event. Similarly, noDupErr callers (speculative
466 * inserters) will recheck later, and wait for a conclusive outcome
467 * then.
468 *
469 * An index for an exclusion constraint can't also be UNIQUE (not an
470 * essential property, we just don't allow it in the grammar), so no
471 * need to preserve the prior state of satisfiesConstraint.
472 */
473 if (indexInfo->ii_ExclusionOps != NULL)
474 {
475 bool violationOK;
476 CEOUC_WAIT_MODE waitMode;
477
478 if (applyNoDupErr)
479 {
480 violationOK = true;
482 }
483 else if (!indexRelation->rd_index->indimmediate)
484 {
485 violationOK = true;
486 waitMode = CEOUC_NOWAIT;
487 }
488 else
489 {
490 violationOK = false;
491 waitMode = CEOUC_WAIT;
492 }
493
494 satisfiesConstraint =
496 indexRelation, indexInfo,
497 tupleid, values, isnull,
498 estate, false,
499 waitMode, violationOK, NULL);
500 }
501
502 if ((checkUnique == UNIQUE_CHECK_PARTIAL ||
503 indexInfo->ii_ExclusionOps != NULL) &&
504 !satisfiesConstraint)
505 {
506 /*
507 * The tuple potentially violates the uniqueness or exclusion
508 * constraint, so make a note of the index so that we can re-check
509 * it later. Speculative inserters are told if there was a
510 * speculative conflict, since that always requires a restart.
511 */
512 result = lappend_oid(result, RelationGetRelid(indexRelation));
513 if (indexRelation->rd_index->indimmediate && specConflict)
514 *specConflict = true;
515 }
516 }
517
518 return result;
519}
static bool index_unchanged_by_update(ResultRelInfo *resultRelInfo, EState *estate, IndexInfo *indexInfo, Relation indexRelation)
IndexUniqueCheck
Definition: genam.h:143
@ UNIQUE_CHECK_NO
Definition: genam.h:144
@ UNIQUE_CHECK_PARTIAL
Definition: genam.h:146
@ UNIQUE_CHECK_YES
Definition: genam.h:145
bool index_insert(Relation indexRelation, Datum *values, bool *isnull, ItemPointer heap_t_ctid, Relation heapRelation, IndexUniqueCheck checkUnique, bool indexUnchanged, IndexInfo *indexInfo)
Definition: indexam.c:213
List * lappend_oid(List *list, Oid datum)
Definition: list.c:375
#define RelationGetRelid(relation)
Definition: rel.h:515
bool ii_Summarizing
Definition: execnodes.h:214
Definition: pg_list.h:54
Oid tts_tableOid
Definition: tuptable.h:129

References Assert(), CEOUC_LIVELOCK_PREVENTING_WAIT, CEOUC_NOWAIT, CEOUC_WAIT, check_exclusion_or_unique_constraint(), ExprContext::ecxt_scantuple, ExecPrepareQual(), ExecQual(), FormIndexDatum(), GetPerTupleExprContext, i, IndexInfo::ii_ExclusionOps, IndexInfo::ii_Predicate, IndexInfo::ii_PredicateState, IndexInfo::ii_ReadyForInserts, IndexInfo::ii_Summarizing, index_insert(), INDEX_MAX_KEYS, index_unchanged_by_update(), ItemPointerIsValid(), lappend_oid(), list_member_oid(), NIL, RelationData::rd_index, RelationGetRelid, ResultRelInfo::ri_IndexRelationDescs, ResultRelInfo::ri_IndexRelationInfo, ResultRelInfo::ri_NumIndices, ResultRelInfo::ri_RelationDesc, TupleTableSlot::tts_tableOid, TupleTableSlot::tts_tid, UNIQUE_CHECK_NO, UNIQUE_CHECK_PARTIAL, UNIQUE_CHECK_YES, and values.

Referenced by CopyFrom(), CopyMultiInsertBufferFlush(), ExecInsert(), ExecSimpleRelationInsert(), ExecSimpleRelationUpdate(), and ExecUpdateEpilogue().

◆ ExecOpenIndices()

void ExecOpenIndices ( ResultRelInfo resultRelInfo,
bool  speculative 
)

Definition at line 161 of file execIndexing.c.

162{
163 Relation resultRelation = resultRelInfo->ri_RelationDesc;
164 List *indexoidlist;
165 ListCell *l;
166 int len,
167 i;
168 RelationPtr relationDescs;
169 IndexInfo **indexInfoArray;
170
171 resultRelInfo->ri_NumIndices = 0;
172
173 /* fast path if no indexes */
174 if (!RelationGetForm(resultRelation)->relhasindex)
175 return;
176
177 /*
178 * Get cached list of index OIDs
179 */
180 indexoidlist = RelationGetIndexList(resultRelation);
181 len = list_length(indexoidlist);
182 if (len == 0)
183 return;
184
185 /* This Assert will fail if ExecOpenIndices is called twice */
186 Assert(resultRelInfo->ri_IndexRelationDescs == NULL);
187
188 /*
189 * allocate space for result arrays
190 */
191 relationDescs = (RelationPtr) palloc(len * sizeof(Relation));
192 indexInfoArray = (IndexInfo **) palloc(len * sizeof(IndexInfo *));
193
194 resultRelInfo->ri_NumIndices = len;
195 resultRelInfo->ri_IndexRelationDescs = relationDescs;
196 resultRelInfo->ri_IndexRelationInfo = indexInfoArray;
197
198 /*
199 * For each index, open the index relation and save pg_index info. We
200 * acquire RowExclusiveLock, signifying we will update the index.
201 *
202 * Note: we do this even if the index is not indisready; it's not worth
203 * the trouble to optimize for the case where it isn't.
204 */
205 i = 0;
206 foreach(l, indexoidlist)
207 {
208 Oid indexOid = lfirst_oid(l);
209 Relation indexDesc;
210 IndexInfo *ii;
211
212 indexDesc = index_open(indexOid, RowExclusiveLock);
213
214 /* extract index key information from the index's pg_index info */
215 ii = BuildIndexInfo(indexDesc);
216
217 /*
218 * If the indexes are to be used for speculative insertion, add extra
219 * information required by unique index entries.
220 */
221 if (speculative && ii->ii_Unique && !indexDesc->rd_index->indisexclusion)
222 BuildSpeculativeIndexInfo(indexDesc, ii);
223
224 relationDescs[i] = indexDesc;
225 indexInfoArray[i] = ii;
226 i++;
227 }
228
229 list_free(indexoidlist);
230}
IndexInfo * BuildIndexInfo(Relation index)
Definition: index.c:2428
void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii)
Definition: index.c:2669
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:133
void list_free(List *list)
Definition: list.c:1546
void * palloc(Size size)
Definition: mcxt.c:1365
const void size_t len
static int list_length(const List *l)
Definition: pg_list.h:152
#define lfirst_oid(lc)
Definition: pg_list.h:174
#define RelationGetForm(relation)
Definition: rel.h:509
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4836
Relation * RelationPtr
Definition: relcache.h:35

References Assert(), BuildIndexInfo(), BuildSpeculativeIndexInfo(), i, IndexInfo::ii_Unique, index_open(), len, lfirst_oid, list_free(), list_length(), palloc(), RelationData::rd_index, RelationGetForm, RelationGetIndexList(), ResultRelInfo::ri_IndexRelationDescs, ResultRelInfo::ri_IndexRelationInfo, ResultRelInfo::ri_NumIndices, ResultRelInfo::ri_RelationDesc, and RowExclusiveLock.

Referenced by apply_handle_delete(), apply_handle_insert(), apply_handle_update_internal(), CatalogOpenIndexes(), CopyFrom(), ExecInitPartitionInfo(), ExecInsert(), and ExecUpdatePrologue().

◆ ExecWithoutOverlapsNotEmpty()

static void ExecWithoutOverlapsNotEmpty ( Relation  rel,
NameData  attname,
Datum  attval,
char  typtype,
Oid  atttypid 
)
static

Definition at line 1153 of file execIndexing.c.

1154{
1155 bool isempty;
1156 RangeType *r;
1157 MultirangeType *mr;
1158
1159 switch (typtype)
1160 {
1161 case TYPTYPE_RANGE:
1162 r = DatumGetRangeTypeP(attval);
1163 isempty = RangeIsEmpty(r);
1164 break;
1165 case TYPTYPE_MULTIRANGE:
1166 mr = DatumGetMultirangeTypeP(attval);
1167 isempty = MultirangeIsEmpty(mr);
1168 break;
1169 default:
1170 elog(ERROR, "WITHOUT OVERLAPS column \"%s\" is not a range or multirange",
1171 NameStr(attname));
1172 }
1173
1174 /* Report a CHECK_VIOLATION */
1175 if (isempty)
1176 ereport(ERROR,
1177 (errcode(ERRCODE_CHECK_VIOLATION),
1178 errmsg("empty WITHOUT OVERLAPS value found in column \"%s\" in relation \"%s\"",
1180}
#define NameStr(name)
Definition: c.h:754
#define MultirangeIsEmpty(mr)
static MultirangeType * DatumGetMultirangeTypeP(Datum X)
NameData attname
Definition: pg_attribute.h:41
static RangeType * DatumGetRangeTypeP(Datum X)
Definition: rangetypes.h:73
#define RangeIsEmpty(r)
Definition: rangetypes.h:55

References attname, DatumGetMultirangeTypeP(), DatumGetRangeTypeP(), elog, ereport, errcode(), errmsg(), ERROR, MultirangeIsEmpty, NameStr, RangeIsEmpty, and RelationGetRelationName.

Referenced by check_exclusion_or_unique_constraint().

◆ index_expression_changed_walker()

static bool index_expression_changed_walker ( Node node,
Bitmapset allUpdatedCols 
)
static

Definition at line 1124 of file execIndexing.c.

1125{
1126 if (node == NULL)
1127 return false;
1128
1129 if (IsA(node, Var))
1130 {
1131 Var *var = (Var *) node;
1132
1134 allUpdatedCols))
1135 {
1136 /* Var was updated -- indicates that we should not hint */
1137 return true;
1138 }
1139
1140 /* Still haven't found a reason to not pass the hint */
1141 return false;
1142 }
1143
1145 allUpdatedCols);
1146}
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:510
static bool index_expression_changed_walker(Node *node, Bitmapset *allUpdatedCols)
#define expression_tree_walker(n, w, c)
Definition: nodeFuncs.h:153
#define IsA(nodeptr, _type_)
Definition: nodes.h:164
Definition: primnodes.h:262
AttrNumber varattno
Definition: primnodes.h:274
#define FirstLowInvalidHeapAttributeNumber
Definition: sysattr.h:27

References bms_is_member(), expression_tree_walker, FirstLowInvalidHeapAttributeNumber, index_expression_changed_walker(), IsA, and Var::varattno.

Referenced by index_expression_changed_walker(), and index_unchanged_by_update().

◆ index_recheck_constraint()

static bool index_recheck_constraint ( Relation  index,
const Oid constr_procs,
const Datum existing_values,
const bool *  existing_isnull,
const Datum new_values 
)
static

Definition at line 979 of file execIndexing.c.

982{
984 int i;
985
986 for (i = 0; i < indnkeyatts; i++)
987 {
988 /* Assume the exclusion operators are strict */
989 if (existing_isnull[i])
990 return false;
991
992 if (!DatumGetBool(OidFunctionCall2Coll(constr_procs[i],
993 index->rd_indcollation[i],
994 existing_values[i],
995 new_values[i])))
996 return false;
997 }
998
999 return true;
1000}
Datum OidFunctionCall2Coll(Oid functionId, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1422
static bool DatumGetBool(Datum X)
Definition: postgres.h:100

References DatumGetBool(), i, IndexRelationGetNumberOfKeyAttributes, and OidFunctionCall2Coll().

Referenced by check_exclusion_or_unique_constraint().

◆ index_unchanged_by_update()

static bool index_unchanged_by_update ( ResultRelInfo resultRelInfo,
EState estate,
IndexInfo indexInfo,
Relation  indexRelation 
)
static

Definition at line 1010 of file execIndexing.c.

1012{
1013 Bitmapset *updatedCols;
1014 Bitmapset *extraUpdatedCols;
1015 Bitmapset *allUpdatedCols;
1016 bool hasexpression = false;
1017 List *idxExprs;
1018
1019 /*
1020 * Check cache first
1021 */
1022 if (indexInfo->ii_CheckedUnchanged)
1023 return indexInfo->ii_IndexUnchanged;
1024 indexInfo->ii_CheckedUnchanged = true;
1025
1026 /*
1027 * Check for indexed attribute overlap with updated columns.
1028 *
1029 * Only do this for key columns. A change to a non-key column within an
1030 * INCLUDE index should not be counted here. Non-key column values are
1031 * opaque payload state to the index AM, a little like an extra table TID.
1032 *
1033 * Note that row-level BEFORE triggers won't affect our behavior, since
1034 * they don't affect the updatedCols bitmaps generally. It doesn't seem
1035 * worth the trouble of checking which attributes were changed directly.
1036 */
1037 updatedCols = ExecGetUpdatedCols(resultRelInfo, estate);
1038 extraUpdatedCols = ExecGetExtraUpdatedCols(resultRelInfo, estate);
1039 for (int attr = 0; attr < indexInfo->ii_NumIndexKeyAttrs; attr++)
1040 {
1041 int keycol = indexInfo->ii_IndexAttrNumbers[attr];
1042
1043 if (keycol <= 0)
1044 {
1045 /*
1046 * Skip expressions for now, but remember to deal with them later
1047 * on
1048 */
1049 hasexpression = true;
1050 continue;
1051 }
1052
1054 updatedCols) ||
1056 extraUpdatedCols))
1057 {
1058 /* Changed key column -- don't hint for this index */
1059 indexInfo->ii_IndexUnchanged = false;
1060 return false;
1061 }
1062 }
1063
1064 /*
1065 * When we get this far and index has no expressions, return true so that
1066 * index_insert() call will go on to pass 'indexUnchanged' = true hint.
1067 *
1068 * The _absence_ of an indexed key attribute that overlaps with updated
1069 * attributes (in addition to the total absence of indexed expressions)
1070 * shows that the index as a whole is logically unchanged by UPDATE.
1071 */
1072 if (!hasexpression)
1073 {
1074 indexInfo->ii_IndexUnchanged = true;
1075 return true;
1076 }
1077
1078 /*
1079 * Need to pass only one bms to expression_tree_walker helper function.
1080 * Avoid allocating memory in common case where there are no extra cols.
1081 */
1082 if (!extraUpdatedCols)
1083 allUpdatedCols = updatedCols;
1084 else
1085 allUpdatedCols = bms_union(updatedCols, extraUpdatedCols);
1086
1087 /*
1088 * We have to work slightly harder in the event of indexed expressions,
1089 * but the principle is the same as before: try to find columns (Vars,
1090 * actually) that overlap with known-updated columns.
1091 *
1092 * If we find any matching Vars, don't pass hint for index. Otherwise
1093 * pass hint.
1094 */
1095 idxExprs = RelationGetIndexExpressions(indexRelation);
1096 hasexpression = index_expression_changed_walker((Node *) idxExprs,
1097 allUpdatedCols);
1098 list_free(idxExprs);
1099 if (extraUpdatedCols)
1100 bms_free(allUpdatedCols);
1101
1102 if (hasexpression)
1103 {
1104 indexInfo->ii_IndexUnchanged = false;
1105 return false;
1106 }
1107
1108 /*
1109 * Deliberately don't consider index predicates. We should even give the
1110 * hint when result rel's "updated tuple" has no corresponding index
1111 * tuple, which is possible with a partial index (provided the usual
1112 * conditions are met).
1113 */
1114 indexInfo->ii_IndexUnchanged = true;
1115 return true;
1116}
void bms_free(Bitmapset *a)
Definition: bitmapset.c:239
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:251
Bitmapset * ExecGetExtraUpdatedCols(ResultRelInfo *relinfo, EState *estate)
Definition: execUtils.c:1403
Bitmapset * ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate)
Definition: execUtils.c:1382
List * RelationGetIndexExpressions(Relation relation)
Definition: relcache.c:5097
bool ii_CheckedUnchanged
Definition: execnodes.h:206
int ii_NumIndexKeyAttrs
Definition: execnodes.h:169
bool ii_IndexUnchanged
Definition: execnodes.h:208
Definition: nodes.h:135

References bms_free(), bms_is_member(), bms_union(), ExecGetExtraUpdatedCols(), ExecGetUpdatedCols(), FirstLowInvalidHeapAttributeNumber, IndexInfo::ii_CheckedUnchanged, IndexInfo::ii_IndexAttrNumbers, IndexInfo::ii_IndexUnchanged, IndexInfo::ii_NumIndexKeyAttrs, index_expression_changed_walker(), list_free(), and RelationGetIndexExpressions().

Referenced by ExecInsertIndexTuples().