pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix mishandling of OLD/NEW references in subqueries in rule acti
Date: Sat, 25 Feb 2023 14:51:12 +0000
Message-ID: <E1pVvtH-000exu-RQ@gemulon.postgresql.org> (raw)

Fix mishandling of OLD/NEW references in subqueries in rule actions.

If a rule action contains a subquery that refers to columns from OLD
or NEW, then those are really lateral references, and the planner will
complain if it sees such things in a subquery that isn't marked as
lateral. However, at rule-definition time, the user isn't required to
mark the subquery with LATERAL, and so it can fail when the rule is
used.

Fix this by marking such subqueries as lateral in the rewriter, at the
point where they're used.

Dean Rasheed and Tom Lane, per report from Alexander Lakhin.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/5e09da43-aaba-7ea7-0a51-a2eb981b058b%40gmail.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8e5b4e0013a8a24644243cdb9516ac52287a81c8

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 22 ++++++++++++++++++----
src/test/regress/expected/rules.out  | 25 +++++++++++++++++++++++++
src/test/regress/sql/rules.sql       | 17 +++++++++++++++++
3 files changed, 60 insertions(+), 4 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1pVvtH-000exu-RQ@gemulon.postgresql.org>
Permalink:  ../E1pVvtH-000exu-RQ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pVvtH-000exu-RQ@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: dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Fix mishandling of OLD/NEW references in subqueries in rule acti
  In-Reply-To: <E1pVvtH-000exu-RQ@gemulon.postgresql.org>
  References: <E1pVvtH-000exu-RQ@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