Skip to content

Commit 362de94

Browse files
committed
Remove field UpdateContext->updated in nodeModifyTable.c
This field has been redundant ever since it was added by commit 25e777c, which split up ExecUpdate() and ExecDelete() into reusable pieces. The only place that reads it is ExecMergeMatched(), if the result from ExecUpdateAct() is TM_Ok. However, all paths through ExecUpdateAct() that return TM_Ok also set this field to true, so the return status by itself is sufficient to tell if the update happened. Removing this field is a modest simplification, and it brings the UPDATE path in ExecMergeMatched() more into line with ExecUpdate(), ensuring that ExecUpdateEpilogue() is always called if ExecUpdateAct() returns TM_Ok, reducing the chance of bugs. Dean Rasheed, reviewed by Alvaro Herrera. Discussion: https://postgr.es/m/CAEZATCWGGmigGBzLHkJm5Ccv2mMxXmwi3%2Buq0yhwDHm-tsvSLg%40mail.gmail.com
1 parent 6fd144e commit 362de94

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/backend/executor/nodeModifyTable.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ typedef struct ModifyTableContext
109109
*/
110110
typedef struct UpdateContext
111111
{
112-
bool updated; /* did UPDATE actually occur? */
113112
bool crossPartUpdate; /* was it a cross-partition update? */
114113
TU_UpdateIndexes updateIndexes; /* Which index updates are required? */
115114

@@ -2042,7 +2041,6 @@ ExecUpdateAct(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
20422041
&insert_destrel))
20432042
{
20442043
/* success! */
2045-
updateCxt->updated = true;
20462044
updateCxt->crossPartUpdate = true;
20472045

20482046
/*
@@ -2111,8 +2109,6 @@ ExecUpdateAct(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
21112109
true /* wait for commit */ ,
21122110
&context->tmfd, &updateCxt->lockmode,
21132111
&updateCxt->updateIndexes);
2114-
if (result == TM_Ok)
2115-
updateCxt->updated = true;
21162112

21172113
return result;
21182114
}
@@ -2919,7 +2915,7 @@ ExecMergeMatched(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
29192915
return true;
29202916
}
29212917

2922-
if (result == TM_Ok && updateCxt.updated)
2918+
if (result == TM_Ok)
29232919
{
29242920
ExecUpdateEpilogue(context, &updateCxt, resultRelInfo,
29252921
tupleid, NULL, newslot);

0 commit comments

Comments
 (0)