Skip to content

Commit f810735

Browse files
committed
Pass indexUnchanged to index_update method
1 parent ccd2bc8 commit f810735

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

src/backend/access/index/indexam.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ index_update(Relation indexRelation,
278278
Datum oldTupleid,
279279
Relation heapRelation,
280280
IndexUniqueCheck checkUnique,
281+
bool indexUnchanged,
281282
IndexInfo *indexInfo)
282283
{
283284
RELATION_CHECKS;
@@ -294,6 +295,7 @@ index_update(Relation indexRelation,
294295
valuesOld, isnullOld, oldTupleid,
295296
heapRelation,
296297
checkUnique,
298+
indexUnchanged,
297299
indexInfo);
298300
}
299301

src/backend/executor/execIndexing.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ ExecUpdateIndexTuples(ResultRelInfo *resultRelInfo,
552552
IndexInfo *indexInfo;
553553
bool applyNoDupErr;
554554
IndexUniqueCheck checkUnique;
555+
bool indexUnchanged;
555556
bool satisfiesConstraint;
556557
bool new_valid = true;
557558

@@ -643,6 +644,16 @@ ExecUpdateIndexTuples(ResultRelInfo *resultRelInfo,
643644
else
644645
checkUnique = UNIQUE_CHECK_PARTIAL;
645646

647+
/*
648+
* There's definitely going to be an index_insert() call for this
649+
* index. If we're being called as part of an UPDATE statement,
650+
* consider if the 'indexUnchanged' = true hint should be passed.
651+
*/
652+
indexUnchanged = index_unchanged_by_update(resultRelInfo,
653+
estate,
654+
indexInfo,
655+
indexRelation);
656+
646657
if (indexRelation->rd_indam->ammvccaware)
647658
{
648659
Datum valuesOld[INDEX_MAX_KEYS];
@@ -704,22 +715,12 @@ ExecUpdateIndexTuples(ResultRelInfo *resultRelInfo,
704715
oldTupleidDatum,
705716
heapRelation, /* heap relation */
706717
checkUnique, /* type of uniqueness check to do */
718+
indexUnchanged, /* UPDATE without logical change? */
707719
indexInfo); /* index AM may need this */
708720

709721
}
710722
else
711723
{
712-
bool indexUnchanged;
713-
/*
714-
* There's definitely going to be an index_insert() call for this
715-
* index. If we're being called as part of an UPDATE statement,
716-
* consider if the 'indexUnchanged' = true hint should be passed.
717-
*/
718-
indexUnchanged = index_unchanged_by_update(resultRelInfo,
719-
estate,
720-
indexInfo,
721-
indexRelation);
722-
723724
satisfiesConstraint =
724725
index_insert(indexRelation, /* index relation */
725726
values, /* array of index Datums */
@@ -1212,9 +1213,10 @@ check_exclusion_or_unique_constraint(Relation heap, Relation index,
12121213
continue;
12131214
}
12141215
} else {
1215-
Assert(tupleidDatum > 0);
1216-
Pointer rowid = DatumGetPointer(tupleidDatum);
1216+
Pointer rowid;
12171217

1218+
Assert(tupleidDatum > 0);
1219+
rowid = DatumGetPointer(tupleidDatum);
12181220
if (PointerIsValid(rowid))
12191221
{
12201222
bool isnull;

src/include/access/amapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ typedef bool (*amupdate_function) (Relation indexRelation,
142142
Datum oldTupleid,
143143
Relation heapRelation,
144144
IndexUniqueCheck checkUnique,
145+
bool indexUnchanged,
145146
struct IndexInfo *indexInfo);
146147
/* delete this tuple */
147148
typedef bool (*amdelete_function) (Relation indexRelation,

src/include/access/genam.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ extern bool index_update(Relation indexRelation,
162162
Datum oldTupleid,
163163
Relation heapRelation,
164164
IndexUniqueCheck checkUnique,
165+
bool indexUnchanged,
165166
struct IndexInfo *indexInfo);
166167
extern bool index_delete(Relation indexRelation, Datum *values, bool *isnull,
167168
Datum tupleid, Relation heapRelation,

0 commit comments

Comments
 (0)