diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2023-03-06 18:31:16 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2023-03-06 18:31:27 -0500 |
commit | 7fee7871b4302e916577df130344060d0f9b8004 (patch) | |
tree | 1a87442d162800511c14defbd5c86c167f2d45a1 /src/backend/executor/execUtils.c | |
parent | d937904cce6a3d82e4f9c2127de7b59105a134b3 (diff) | |
download | postgresql-7fee7871b4302e916577df130344060d0f9b8004.tar.gz |
Fix some more cases of missed GENERATED-column updates.
If UPDATE is forced to retry after an EvalPlanQual check, it neglected
to repeat GENERATED-column computations, even though those might well
have changed since we're dealing with a different tuple than before.
Fixing this is mostly a matter of looping back a bit further when
we retry. In v15 and HEAD that's most easily done by altering the API
of ExecUpdateAct so that it includes computing GENERATED expressions.
Also, if an UPDATE in a partitioned table turns into a cross-partition
INSERT operation, we failed to recompute GENERATED columns. That's a
bug since 8bf6ec3ba allowed partitions to have different generation
expressions; although it seems to have no ill effects before that.
Fixing this is messier because we can now have situations where the same
query needs both the UPDATE-aligned set of GENERATED columns and the
INSERT-aligned set, and it's unclear which set will be generated first
(else we could hack things by forcing the INSERT-aligned set to be
generated, which is indeed how fe9e658f4 made it work for MERGE).
The best fix seems to be to build and store separate sets of expressions
for the INSERT and UPDATE cases. That would create ABI issues in the
back branches, but so far it seems we can leave this alone in the back
branches.
Per bug #17823 from Hisahiro Kauchi. The first part of this affects all
branches back to v12 where GENERATED columns were added.
Discussion: https://postgr.es/m/17823-b64909cf7d63de84@postgresql.org
Diffstat (limited to 'src/backend/executor/execUtils.c')
-rw-r--r-- | src/backend/executor/execUtils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index 6eac5f354c..012dbb6965 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -1339,8 +1339,8 @@ ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate) Bitmapset * ExecGetExtraUpdatedCols(ResultRelInfo *relinfo, EState *estate) { - /* In some code paths we can reach here before initializing the info */ - if (relinfo->ri_GeneratedExprs == NULL) + /* Compute the info if we didn't already */ + if (relinfo->ri_GeneratedExprsU == NULL) ExecInitStoredGenerated(relinfo, estate, CMD_UPDATE); return relinfo->ri_extraUpdatedCols; } |