From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe
Date: Sun, 08 Nov 2020 18:08:54 +0000
Message-ID: <E1kbp7W-0004Kz-Od@gemulon.postgresql.org> (raw)
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(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: In INSERT/UPDATE, use the table's real tuple descriptor as targe
In-Reply-To: <E1kbp7W-0004Kz-Od@gemulon.postgresql.org>
References: <E1kbp7W-0004Kz-Od@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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