pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix corner case for a BEFORE ROW UPDATE trigger returning OLD.
3+ messages / 1 participants
[nested] [flat]

* pgsql: Fix corner case for a BEFORE ROW UPDATE trigger returning OLD.
@ 2020-10-25 17:57  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2020-10-25 17:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix corner case for a BEFORE ROW UPDATE trigger returning OLD.

If the old row has any "missing" attributes that are supposed to
be retrieved from an associated tuple descriptor, the wrong things
happened because the trigger result is shoved directly into an
executor slot that lacks the missing-attribute data.  Notably,
CHECK-constraint verification would incorrectly see those columns
as NULL, and so would RETURNING-list evaluation.

Band-aid around this by forcibly expanding the tuple before passing
it to the trigger function.  (IMO it was a fundamental misdesign to
put the missing-attribute data into tuple constraints, which so
much of the system considers to be optional.  But we're probably
stuck with that now, and will have to continue to apply band-aids
as we find other places with similar issues.)

Back-patch to v12.  v11 would also have the issue, except that
commit 920311ab1 already applied a similar band-aid.  That forced
expansion in more cases than seem really necessary, though, so
this isn't a directly equivalent fix.

Amit Langote, with some cosmetic changes by me

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

Branch
------
REL_12_STABLE

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

Modified Files
--------------
src/backend/commands/trigger.c         | 41 +++++++++++++++++++++++++++++++++-
src/test/regress/expected/triggers.out | 32 ++++++++++++++++++++++++++
src/test/regress/sql/triggers.sql      | 18 +++++++++++++++
3 files changed, 90 insertions(+), 1 deletion(-)



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

* pgsql: Fix corner case for a BEFORE ROW UPDATE trigger returning OLD.
@ 2020-10-25 17:57  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2020-10-25 17:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix corner case for a BEFORE ROW UPDATE trigger returning OLD.

If the old row has any "missing" attributes that are supposed to
be retrieved from an associated tuple descriptor, the wrong things
happened because the trigger result is shoved directly into an
executor slot that lacks the missing-attribute data.  Notably,
CHECK-constraint verification would incorrectly see those columns
as NULL, and so would RETURNING-list evaluation.

Band-aid around this by forcibly expanding the tuple before passing
it to the trigger function.  (IMO it was a fundamental misdesign to
put the missing-attribute data into tuple constraints, which so
much of the system considers to be optional.  But we're probably
stuck with that now, and will have to continue to apply band-aids
as we find other places with similar issues.)

Back-patch to v12.  v11 would also have the issue, except that
commit 920311ab1 already applied a similar band-aid.  That forced
expansion in more cases than seem really necessary, though, so
this isn't a directly equivalent fix.

Amit Langote, with some cosmetic changes by me

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

Branch
------
REL_13_STABLE

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

Modified Files
--------------
src/backend/commands/trigger.c         | 41 +++++++++++++++++++++++++++++++++-
src/test/regress/expected/triggers.out | 32 ++++++++++++++++++++++++++
src/test/regress/sql/triggers.sql      | 18 +++++++++++++++
3 files changed, 90 insertions(+), 1 deletion(-)



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

* pgsql: Fix corner case for a BEFORE ROW UPDATE trigger returning OLD.
@ 2020-10-25 17:57  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2020-10-25 17:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix corner case for a BEFORE ROW UPDATE trigger returning OLD.

If the old row has any "missing" attributes that are supposed to
be retrieved from an associated tuple descriptor, the wrong things
happened because the trigger result is shoved directly into an
executor slot that lacks the missing-attribute data.  Notably,
CHECK-constraint verification would incorrectly see those columns
as NULL, and so would RETURNING-list evaluation.

Band-aid around this by forcibly expanding the tuple before passing
it to the trigger function.  (IMO it was a fundamental misdesign to
put the missing-attribute data into tuple constraints, which so
much of the system considers to be optional.  But we're probably
stuck with that now, and will have to continue to apply band-aids
as we find other places with similar issues.)

Back-patch to v12.  v11 would also have the issue, except that
commit 920311ab1 already applied a similar band-aid.  That forced
expansion in more cases than seem really necessary, though, so
this isn't a directly equivalent fix.

Amit Langote, with some cosmetic changes by me

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

Branch
------
master

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

Modified Files
--------------
src/backend/commands/trigger.c         | 41 +++++++++++++++++++++++++++++++++-
src/test/regress/expected/triggers.out | 32 ++++++++++++++++++++++++++
src/test/regress/sql/triggers.sql      | 18 +++++++++++++++
3 files changed, 90 insertions(+), 1 deletion(-)



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


end of thread, other threads:[~2020-10-25 17:57 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-10-25 17:57 pgsql: Fix corner case for a BEFORE ROW UPDATE trigger returning OLD. Tom Lane <tgl@sss.pgh.pa.us>
2020-10-25 17:57 pgsql: Fix corner case for a BEFORE ROW UPDATE trigger returning OLD. Tom Lane <tgl@sss.pgh.pa.us>
2020-10-25 17:57 pgsql: Fix corner case for a BEFORE ROW UPDATE trigger returning OLD. 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