pgsql: Use checkAsUser for selectivity estimator checks, if it's set.

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема pgsql: Use checkAsUser for selectivity estimator checks, if it's set.
Дата
Msg-id E1hNbUb-0004oQ-S3@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3c09999098519da6b601df878e326eed701201ba

Modified Files
--------------
src/backend/utils/adt/selfuncs.c         | 34 +++++++++++----
src/test/regress/expected/privileges.out | 71 ++++++++++++++++++++++++++++----
src/test/regress/sql/privileges.sql      | 25 +++++++++--
3 files changed, 112 insertions(+), 18 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Dean Rasheed
Дата:
Сообщение: pgsql: Fix security checks for selectivity estimation functions withRL
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Fix tuple printing in error message of tuple routing forpartiti