pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix calculation of which GENERATED columns need to be updated.
6+ messages / 2 participants
[nested] [flat]

* pgsql: Fix calculation of which GENERATED columns need to be updated.
@ 2023-01-05 19:12 Tom Lane <tgl@sss.pgh.pa.us>
  2023-01-07 10:42 ` Re: pgsql: Fix calculation of which GENERATED columns need to be updated. David Rowley <dgrowleyml@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2023-01-05 19:12 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3f7836ff651ad710fef52fa87b248ecdfc6468dc

Modified Files
--------------
src/backend/executor/execMain.c          |   1 +
src/backend/executor/execUtils.c         |  25 ++---
src/backend/executor/nodeModifyTable.c   | 154 +++++++++++++++++++++----------
src/backend/nodes/outfuncs.c             |   1 -
src/backend/nodes/readfuncs.c            |   1 -
src/backend/optimizer/util/inherit.c     | 107 ++++++++++-----------
src/backend/optimizer/util/plancat.c     |  56 +++++++++++
src/backend/replication/logical/worker.c |   5 -
src/backend/rewrite/rewriteHandler.c     |  45 ---------
src/include/nodes/execnodes.h            |   3 +
src/include/nodes/parsenodes.h           |  10 --
src/include/optimizer/plancat.h          |   3 +
src/include/rewrite/rewriteHandler.h     |   4 -
src/test/regress/expected/generated.out  |  19 ++++
src/test/regress/sql/generated.sql       |   9 ++
15 files changed, 257 insertions(+), 186 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Fix calculation of which GENERATED columns need to be updated.
  2023-01-05 19:12 pgsql: Fix calculation of which GENERATED columns need to be updated. Tom Lane <tgl@sss.pgh.pa.us>
@ 2023-01-07 10:42 ` David Rowley <dgrowleyml@gmail.com>
  2023-01-07 15:08   ` Re: pgsql: Fix calculation of which GENERATED columns need to be updated. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: David Rowley @ 2023-01-07 10:42 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers@lists.postgresql.org

On Fri, 6 Jan 2023 at 08:12, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Fix calculation of which GENERATED columns need to be updated.

> Branch
> ------
> master

> src/backend/nodes/outfuncs.c             |   1 -
> src/backend/nodes/readfuncs.c            |   1 -

Is this missing a cat version bump?

David





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Fix calculation of which GENERATED columns need to be updated.
  2023-01-05 19:12 pgsql: Fix calculation of which GENERATED columns need to be updated. Tom Lane <tgl@sss.pgh.pa.us>
  2023-01-07 10:42 ` Re: pgsql: Fix calculation of which GENERATED columns need to be updated. David Rowley <dgrowleyml@gmail.com>
@ 2023-01-07 15:08   ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-01-07 15:08 UTC (permalink / raw)
  To: David Rowley <dgrowleyml@gmail.com>; +Cc: pgsql-committers@lists.postgresql.org

David Rowley <dgrowleyml@gmail.com> writes:
> On Fri, 6 Jan 2023 at 08:12, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Fix calculation of which GENERATED columns need to be updated.

>> src/backend/nodes/outfuncs.c             |   1 -
>> src/backend/nodes/readfuncs.c            |   1 -

> Is this missing a cat version bump?

... Ugh, you're right, I should have done one in HEAD.

Probably too late to be useful now.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix calculation of which GENERATED columns need to be updated.
@ 2023-01-05 19:12 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-01-05 19:12 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3706cc97aa36bb65fd82dbfc79ca809033bcad1f

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix calculation of which GENERATED columns need to be updated.
@ 2023-01-05 19:12 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-01-05 19:12 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix calculation of which GENERATED columns need to be updated.
@ 2023-01-05 19:12 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2023-01-05 19:12 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ad38e2f89116435cffd56507380d94e4eb588789

Modified Files
--------------
contrib/postgres_fdw/postgres_fdw.c      |   4 +-
src/backend/executor/execUtils.c         |  34 +++----
src/backend/executor/nodeModifyTable.c   | 160 ++++++++++++++++++++++---------
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, 329 insertions(+), 126 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2023-01-07 15:08 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 19:12 pgsql: Fix calculation of which GENERATED columns need to be updated. Tom Lane <tgl@sss.pgh.pa.us>
2023-01-07 10:42 ` David Rowley <dgrowleyml@gmail.com>
2023-01-07 15:08   ` Tom Lane <tgl@sss.pgh.pa.us>
2023-01-05 19:12 pgsql: Fix calculation of which GENERATED columns need to be updated. Tom Lane <tgl@sss.pgh.pa.us>
2023-01-05 19:12 pgsql: Fix calculation of which GENERATED columns need to be updated. Tom Lane <tgl@sss.pgh.pa.us>
2023-01-05 19:12 pgsql: Fix calculation of which GENERATED columns need to be updated. Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox