Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23b75dd

Browse files
committed
Fix some more cases of missed GENERATED-column updates.
If UPDATE is forced to retry after an EvalPlanQual check, it neglectedto repeat GENERATED-column computations, even though those might wellhave changed since we're dealing with a different tuple than before.Fixing this is mostly a matter of looping back a bit further whenwe retry. In v15 and HEAD that's most easily done by altering the APIof ExecUpdateAct so that it includes computing GENERATED expressions.Also, if an UPDATE in a partitioned table turns into a cross-partitionINSERT operation, we failed to recompute GENERATED columns. That's abug since8bf6ec3 allowed partitions to have different generationexpressions; although it seems to have no ill effects before that.Fixing this is messier because we can now have situations where the samequery needs both the UPDATE-aligned set of GENERATED columns and theINSERT-aligned set, and it's unclear which set will be generated first(else we could hack things by forcing the INSERT-aligned set to begenerated, which is indeed howfe9e658 made it work for MERGE).The best fix seems to be to build and store separate sets of expressionsfor the INSERT and UPDATE cases. That would create ABI issues in theback branches, but so far it seems we can leave this alone in the backbranches.Per bug #17823 from Hisahiro Kauchi. The first part of this affects allbranches back to v12 where GENERATED columns were added.Discussion:https://postgr.es/m/17823-b64909cf7d63de84@postgresql.org
1 parentafa122e commit23b75dd

File tree

5 files changed

+204
-160
lines changed

5 files changed

+204
-160
lines changed

‎src/backend/executor/nodeModifyTable.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,15 @@ ExecUpdate(ModifyTableState *mtstate,
11931193
boolpartition_constraint_failed;
11941194
boolupdate_indexes;
11951195

1196+
/*
1197+
* If we generate a new candidate tuple after EvalPlanQual testing, we
1198+
* must loop back here to try again. (We don't need to redo triggers,
1199+
* however. If there are any BEFORE triggers then trigger.c will have
1200+
* done table_tuple_lock to lock the correct tuple, so there's no need
1201+
* to do them again.)
1202+
*/
1203+
lreplace:
1204+
11961205
/*
11971206
* Constraints and GENERATED expressions might reference the tableoid
11981207
* column, so (re-)initialize tts_tableOid before evaluating them.
@@ -1206,17 +1215,6 @@ ExecUpdate(ModifyTableState *mtstate,
12061215
resultRelationDesc->rd_att->constr->has_generated_stored)
12071216
ExecComputeStoredGenerated(estate,slot);
12081217

1209-
/*
1210-
* Check any RLS UPDATE WITH CHECK policies
1211-
*
1212-
* If we generate a new candidate tuple after EvalPlanQual testing, we
1213-
* must loop back here and recheck any RLS policies and constraints.
1214-
* (We don't need to redo triggers, however. If there are any BEFORE
1215-
* triggers then trigger.c will have done table_tuple_lock to lock the
1216-
* correct tuple, so there's no need to do them again.)
1217-
*/
1218-
lreplace:;
1219-
12201218
/* ensure slot is independent, consider e.g. EPQ */
12211219
ExecMaterializeSlot(slot);
12221220

@@ -1231,6 +1229,7 @@ lreplace:;
12311229
resultRelInfo->ri_PartitionCheck&&
12321230
!ExecPartitionCheck(resultRelInfo,slot,estate, false);
12331231

1232+
/* Check any RLS UPDATE WITH CHECK policies */
12341233
if (!partition_constraint_failed&&
12351234
resultRelInfo->ri_WithCheckOptions!=NIL)
12361235
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp