]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid trying to lock OLD/NEW in a rule with FOR UPDATE.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Aug 2021 16:12:36 +0000 (12:12 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Aug 2021 16:12:36 +0000 (12:12 -0400)
commitcc7fae5c2d9effad8a907ffacb4190aca136f87b
tree2fa392c3c2a92e469306006c7fa14a9eaf356e2a
parentc09f56fedc73d66758d202f6c40fb3b70c80751e
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/17151-c03a3e6e4ec9aadb@postgresql.org
src/backend/parser/analyze.c
src/include/nodes/parsenodes.h
src/test/regress/expected/rules.out
src/test/regress/sql/rules.sql