pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe
4+ messages / 1 participants
[nested] [flat]

* pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe
@ 2020-10-26 15:37 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2020-10-26 15:37 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In INSERT/UPDATE, use the table's real tuple descriptor as target.

Previously, ExecInitModifyTable relied on ExecInitJunkFilter,
and thence ExecCleanTypeFromTL, to build the target descriptor from
the query tlist.  While we just checked (in ExecCheckPlanOutput)
that the tlist produces compatible output, this is not a great
substitute for the relation's actual tuple descriptor that's
available from the relcache.  For one thing, dropped columns will
not be correctly marked attisdropped; it's a bit surprising that
we've gotten away with that this long.  But the real reason for
being concerned with this is that using the table's descriptor means
that the slot will have correct attrmissing data, allowing us to
revert the klugy fix of commit ba9f18abd.  (This commit undoes
that one's changes in trigger.c, but keeps the new test case.)
Thus we can solve the bogus-trigger-tuple problem with fewer cycles
rather than more.

No back-patch, since this doesn't fix any additional bug, and it
seems somewhat more likely to have unforeseen side effects than
ba9f18abd's narrow fix.

Discussion: https://postgr.es/m/16644-5da7ef98a7ac4545@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/20d3fe9009ddbbbb3da3a2da298f922054b43f8c

Modified Files
--------------
src/backend/commands/trigger.c         | 38 +-----------------------------
src/backend/executor/execJunk.c        | 42 +++++++++++++++++++++++++++-------
src/backend/executor/nodeModifyTable.c | 22 ++++++++++++++----
src/include/executor/executor.h        |  3 +++
4 files changed, 55 insertions(+), 50 deletions(-)



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

* pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe
@ 2020-11-08 18:08 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2020-11-08 18:08 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In INSERT/UPDATE, use the table's real tuple descriptor as target.

This back-patches commit 20d3fe900 into the v12 and v13 branches.
At the time I thought that commit was not fixing any observable
bug, but Bertrand Drouvot showed otherwise: adding a dropped column
to the previously-considered scenario crashes v12 and v13, unless the
dropped column happens to be an integer.  That is, of course, because
the tupdesc we derive from the plan output tlist fails to describe
the dropped column accurately, so that we'll do the wrong thing with
a tuple in which that column isn't NULL.

There is no bug in pre-v12 branches because they already did use
the table's real tuple descriptor for any trigger-returned tuple.
It seems that this set of bugs can be blamed on the changes that
removed es_trig_tuple_slot, though I've not attempted to pin that
down precisely.

Although there's no code change needed in HEAD, update the test case
to include a dropped column there too.

Discussion: https://postgr.es/m/db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.com
Discussion: https://postgr.es/m/16644-5da7ef98a7ac4545@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8b39345a9d9abd1c371f8458301a227d0abb93b2

Modified Files
--------------
src/test/regress/expected/triggers.out | 50 ++++++++++++++++++++++++----------
src/test/regress/sql/triggers.sql      | 13 +++++++--
2 files changed, 47 insertions(+), 16 deletions(-)



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

* pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe
@ 2020-11-08 18:08 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2020-11-08 18:08 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In INSERT/UPDATE, use the table's real tuple descriptor as target.

This back-patches commit 20d3fe900 into the v12 and v13 branches.
At the time I thought that commit was not fixing any observable
bug, but Bertrand Drouvot showed otherwise: adding a dropped column
to the previously-considered scenario crashes v12 and v13, unless the
dropped column happens to be an integer.  That is, of course, because
the tupdesc we derive from the plan output tlist fails to describe
the dropped column accurately, so that we'll do the wrong thing with
a tuple in which that column isn't NULL.

There is no bug in pre-v12 branches because they already did use
the table's real tuple descriptor for any trigger-returned tuple.
It seems that this set of bugs can be blamed on the changes that
removed es_trig_tuple_slot, though I've not attempted to pin that
down precisely.

Although there's no code change needed in HEAD, update the test case
to include a dropped column there too.

Discussion: https://postgr.es/m/db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.com
Discussion: https://postgr.es/m/16644-5da7ef98a7ac4545@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7aeb6404f0aa250e75b7156d21ebe12d0ec2d1c8

Modified Files
--------------
src/backend/commands/trigger.c         | 38 +-------------------------
src/backend/executor/execJunk.c        | 42 ++++++++++++++++++++++------
src/backend/executor/nodeModifyTable.c | 22 +++++++++++----
src/include/executor/executor.h        |  3 ++
src/test/regress/expected/triggers.out | 50 ++++++++++++++++++++++++----------
src/test/regress/sql/triggers.sql      | 13 +++++++--
6 files changed, 102 insertions(+), 66 deletions(-)



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

* pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe
@ 2020-11-08 18:08 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2020-11-08 18:08 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

In INSERT/UPDATE, use the table's real tuple descriptor as target.

This back-patches commit 20d3fe900 into the v12 and v13 branches.
At the time I thought that commit was not fixing any observable
bug, but Bertrand Drouvot showed otherwise: adding a dropped column
to the previously-considered scenario crashes v12 and v13, unless the
dropped column happens to be an integer.  That is, of course, because
the tupdesc we derive from the plan output tlist fails to describe
the dropped column accurately, so that we'll do the wrong thing with
a tuple in which that column isn't NULL.

There is no bug in pre-v12 branches because they already did use
the table's real tuple descriptor for any trigger-returned tuple.
It seems that this set of bugs can be blamed on the changes that
removed es_trig_tuple_slot, though I've not attempted to pin that
down precisely.

Although there's no code change needed in HEAD, update the test case
to include a dropped column there too.

Discussion: https://postgr.es/m/db5d97c8-f48a-51e2-7b08-b73d5434d425@amazon.com
Discussion: https://postgr.es/m/16644-5da7ef98a7ac4545@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/94ec005f334e1ae740a04f4f8a14e3f7f934a346

Modified Files
--------------
src/backend/commands/trigger.c         | 38 +-------------------------
src/backend/executor/execJunk.c        | 42 ++++++++++++++++++++++------
src/backend/executor/nodeModifyTable.c | 22 +++++++++++----
src/include/executor/executor.h        |  3 ++
src/test/regress/expected/triggers.out | 50 ++++++++++++++++++++++++----------
src/test/regress/sql/triggers.sql      | 13 +++++++--
6 files changed, 102 insertions(+), 66 deletions(-)



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


end of thread, other threads:[~2020-11-08 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 15:37 pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe Tom Lane <tgl@sss.pgh.pa.us>
2020-11-08 18:08 pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe Tom Lane <tgl@sss.pgh.pa.us>
2020-11-08 18:08 pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe Tom Lane <tgl@sss.pgh.pa.us>
2020-11-08 18:08 pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe 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