pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Correctly set userid of subquery relations' child rels
Date: Mon, 20 Feb 2023 15:15:20 +0000
Message-ID: <E1pU7su-0026K0-6e@gemulon.postgresql.org> (raw)

Correctly set userid of subquery relations' child rels

The RelOptInfo->userid field (the user ID to check permissions as) of an
"otherrel" relation was being copied from its parent relation, which is
correct in most cases but wrong when the parent is a subquery.  In that
case, using the value from the RTEPermissionInfo of the child itself is
the appropriate thing to do.

Coming up with a test case where user-visible behavior changes proves
hard enough, so we don't add one here.

Bug introduced by a61b1f74823c, discovered by Amit while reviewing
nearby code.

Author: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CA+HiwqE0WY_AhLnGtTsY7eYebG212XWbM-D8gr2A_ToOHyCywQ@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/util/relnode.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)



Message-ID: <E1pU7su-0026K0-6e@gemulon.postgresql.org>
Permalink:  ../E1pU7su-0026K0-6e@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pU7su-0026K0-6e@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: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Correctly set userid of subquery relations' child rels
  In-Reply-To: <E1pU7su-0026K0-6e@gemulon.postgresql.org>
  References: <E1pU7su-0026K0-6e@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