pgsql: Avoid trying to lock OLD/NEW in a rule with FOR UPDATE.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid trying to lock OLD/NEW in a rule with FOR UPDATE.
Date: 2021-08-19 16:12:59
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid trying to lock OLD/NEW in a rule with FOR UPDATE.

transformLockingClause neglected to exclude the pseudo-RTEs for
OLD/NEW when processing a rule's query. This led to odd errors
or even crashes later on. This bug is very ancient, but it's
not terribly surprising that nobody noticed, since the use-case
for SELECT FOR UPDATE in a non-view rule is somewhere between
thin and non-existent. Still, crashing is not OK.

Per bug #17151 from Zhiyong Wu. Thanks to Masahiko Sawada
for analysis of the problem.

Discussion: https://postgr.es/m/[email protected]

Branch
------
REL9_6_STABLE

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

Modified Files
--------------
src/backend/parser/analyze.c | 19 +++++++++++++++++--
src/include/nodes/parsenodes.h | 8 ++++----
src/test/regress/expected/rules.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/rules.sql | 14 ++++++++++++++
4 files changed, 60 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2021-08-20 09:05:59 pgsql: pg_resetwal: Improve numeric command-line argument parsing
Previous Message Andres Freund 2021-08-19 12:20:30 pgsql: Unset MyBEEntry, making elog.c's call to pgstat_get_my_query_id(