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: Correctly update hasSubLinks while mutating a rule action.
Date: Tue, 13 Jun 2023 19:59:15 +0000
Message-ID: <E1q9AAc-001dud-Hy@gemulon.postgresql.org> (raw)

Correctly update hasSubLinks while mutating a rule action.

rewriteRuleAction neglected to check for SubLink nodes in the
securityQuals of range table entries.  This could lead to failing
to convert such a SubLink to a SubPlan, resulting in assertion
crashes or weird errors later in planning.

In passing, fix some poor coding in rewriteTargetView:
we should not pass the source parsetree's hasSubLinks
field to ReplaceVarsFromTargetList's outer_hasSubLinks.
ReplaceVarsFromTargetList knows enough to ignore that
when a Query node is passed, but it's still confusing
and bad precedent: if we did try to update that flag
we'd be updating a stale copy of the parsetree.

Per bug #17972 from Alexander Lakhin.  This has been broken since
we added RangeTblEntry.securityQuals (although the presented test
case only fails back to 215b43cdc), so back-patch all the way.

Discussion: https://postgr.es/m/17972-f422c094237847d0@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/792213f2e9f6d321d5a463f4a0fc263c2b770ac3

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c          |  4 +++-
src/test/regress/expected/updatable_views.out | 32 +++++++++++++++++++++++++++
src/test/regress/sql/updatable_views.sql      | 17 ++++++++++++++
3 files changed, 52 insertions(+), 1 deletion(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1q9AAc-001dud-Hy@gemulon.postgresql.org>
Permalink:  ../E1q9AAc-001dud-Hy@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1q9AAc-001dud-Hy@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Correctly update hasSubLinks while mutating a rule action.
  In-Reply-To: <E1q9AAc-001dud-Hy@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