pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid trying to lock OLD/NEW in a rule with FOR UPDATE.
Date: Thu, 19 Aug 2021 16:12:59 +0000
Message-ID: <E1mGkf5-0004CM-Hi@gemulon.postgresql.org> (raw)

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

Branch
------
REL_13_STABLE

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

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(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1mGkf5-0004CM-Hi@gemulon.postgresql.org>
Permalink:  ../E1mGkf5-0004CM-Hi@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mGkf5-0004CM-Hi@gemulon.postgresql.org

 · 

reply

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: Avoid trying to lock OLD/NEW in a rule with FOR UPDATE.
  In-Reply-To: <E1mGkf5-0004CM-Hi@gemulon.postgresql.org>
  References: <E1mGkf5-0004CM-Hi@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