From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use checkAsUser for selectivity estimator checks, if it's set.
Date: Mon, 06 May 2019 11:09:09 +0000
Message-ID: <E1hNbUb-0004oL-RW@gemulon.postgresql.org> (raw)
Use checkAsUser for selectivity estimator checks, if it's set.
In examine_variable() and examine_simple_variable(), when checking the
user's table and column privileges to determine whether to grant
access to the pg_statistic data, use checkAsUser for the privilege
checks, if it's set. This will be the case if we're accessing the
table via a view, to indicate that we should perform privilege checks
as the view owner rather than the current user.
This change makes this planner check consistent with the check in the
executor, so the planner will be able to make use of statistics if the
table is accessible via the view. This fixes a performance regression
introduced by commit e2d4ef8de8, which affects queries against
non-security barrier views in the case where the user doesn't have
privileges on the underlying table, but the view owner does.
Note that it continues to provide the same safeguards controlling
access to pg_statistic for direct table access (in which case
checkAsUser won't be set) and for security barrier views, because of
the nearby checks on rte->security_barrier and rte->securityQuals.
Back-patch to all supported branches because e2d4ef8de8 was.
Dean Rasheed, reviewed by Jonathan Katz and Stephen Frost.
Branch
------
REL_10_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/ca74e3e0faadd5731c1bd9e6da21f11162a125f2
Modified Files
--------------
src/backend/utils/adt/selfuncs.c | 20 +++++++--
src/test/regress/expected/privileges.out | 71 ++++++++++++++++++++++++++++----
src/test/regress/sql/privileges.sql | 25 +++++++++--
3 files changed, 101 insertions(+), 15 deletions(-)
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: Use checkAsUser for selectivity estimator checks, if it's set.
In-Reply-To: <E1hNbUb-0004oL-RW@gemulon.postgresql.org>
References: <E1hNbUb-0004oL-RW@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