From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix calculation of which GENERATED columns need to be updated. |
Date: | 2023-01-05 19:12:34 |
Message-ID: | E1pDVfG-002Cs6-8L@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix calculation of which GENERATED columns need to be updated.
We were identifying the updatable generated columns of inheritance
children by transposing the calculation made for their parent.
However, there's nothing that says a traditional-inheritance child
can't have generated columns that aren't there in its parent, or that
have different dependencies than are in the parent's expression.
(At present it seems that we don't enforce that for partitioning
either, which is likely wrong to some degree or other; but the case
clearly needs to be handled with traditional inheritance.)
Hence, drop the very-klugy-anyway "extraUpdatedCols" RTE field
in favor of identifying which generated columns depend on updated
columns during executor startup. In HEAD we can remove
extraUpdatedCols altogether; in back branches, it's still there but
always empty. Another difference between the HEAD and back-branch
versions of this patch is that in HEAD we can add the new bitmap field
to ResultRelInfo, but that would cause an ABI break in back branches.
Like 4b3e37993, add a List field at the end of struct EState instead.
Back-patch to v13. The bogus calculation is also being made in v12,
but it doesn't have the same visible effect because we don't use it
to decide which generated columns to recalculate; as a consequence of
which the patch doesn't apply easily. I think that there might still
be a demonstrable bug associated with trigger firing conditions, but
that's such a weird corner-case usage that I'm content to leave it
unfixed in v12.
Amit Langote and Tom Lane
Discussion: https://postgr.es/m/CA+HiwqFshLKNvQUd1DgwJ-7tsTp=dwv7KZqXC4j2wYBV1aCDUA@mail.gmail.com
Discussion: https://postgr.es/m/2793383.1672944799@sss.pgh.pa.us
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/8cd190e13a22dab12e86f7f1b59de6b9b128c784
Modified Files
--------------
contrib/postgres_fdw/postgres_fdw.c | 4 +-
src/backend/executor/execUtils.c | 33 ++++---
src/backend/executor/nodeModifyTable.c | 162 ++++++++++++++++++++++---------
src/backend/optimizer/util/inherit.c | 97 ++++++++++++++++--
src/backend/optimizer/util/plancat.c | 56 +++++++++++
src/backend/replication/logical/worker.c | 3 -
src/backend/rewrite/rewriteHandler.c | 40 --------
src/include/nodes/execnodes.h | 16 +++
src/include/nodes/parsenodes.h | 9 +-
src/include/optimizer/inherit.h | 2 +
src/include/optimizer/plancat.h | 3 +
src/include/rewrite/rewriteHandler.h | 3 -
src/test/regress/expected/generated.out | 19 ++++
src/test/regress/sql/generated.sql | 9 ++
14 files changed, 330 insertions(+), 126 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2023-01-05 19:33:04 | pgsql: Refactor permissions-checking for role grants. |
Previous Message | Peter Geoghegan | 2023-01-05 18:57:05 | Re: pgsql: Delay commit status checks until freezing executes. |