pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix cache lookup hazards introduced by ff9618e82a.
Date: Thu, 22 Jun 2023 22:49:28 +0000
Message-ID: <E1qCT7H-0038ei-Uh@gemulon.postgresql.org> (raw)

Fix cache lookup hazards introduced by ff9618e82a.

ff9618e82a introduced has_partition_ancestor_privs(), which is used
to check whether a user has MAINTAIN on any partition ancestors.
This involves syscache lookups, and presently this function does
not take any relation locks, so it is likely subject to the same
kind of cache lookup failures that were fixed by 19de0ab23c.

To fix this problem, this commit partially reverts ff9618e82a.
Specifically, it removes the partition-related changes, including
the has_partition_ancestor_privs() function mentioned above.  This
means that MAINTAIN on a partitioned table is no longer sufficient
to perform maintenance commands on its partitions.  This is more
like how privileges for maintenance commands work on supported
versions.  Privileges are checked for each partition, so a command
that flows down to all partitions might refuse to process them
(e.g., if the current user doesn't have MAINTAIN on the partition).

In passing, adjust a few related comments and error messages, and
add a test for the privilege checks for CLUSTER on a partitioned
table.

Reviewed-by: Michael Paquier, Jeff Davis
Discussion: https://postgr.es/m/20230613211246.GA219055%40nathanxps13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4dbdb82513b65ab3a29e431f0233009c8a0fa890

Modified Files
--------------
doc/src/sgml/ref/analyze.sgml                      |  5 +---
doc/src/sgml/ref/cluster.sgml                      |  5 +---
doc/src/sgml/ref/lock.sgml                         |  5 +---
doc/src/sgml/ref/reindex.sgml                      |  6 +---
doc/src/sgml/ref/vacuum.sgml                       |  5 +---
src/backend/commands/cluster.c                     | 12 ++++----
src/backend/commands/indexcmds.c                   | 27 ++++++++---------
src/backend/commands/lockcmds.c                    |  8 -----
src/backend/commands/tablecmds.c                   | 34 +++-------------------
src/backend/commands/vacuum.c                      | 10 ++-----
src/include/commands/tablecmds.h                   |  1 -
.../expected/cluster-conflict-partition.out        | 14 ++++-----
.../specs/cluster-conflict-partition.spec          |  7 +++--
src/test/regress/expected/cluster.out              |  7 ++++-
src/test/regress/expected/create_index.out         |  4 +--
src/test/regress/expected/privileges.out           |  8 ++---
src/test/regress/expected/vacuum.out               | 18 ++++++++++++
src/test/regress/sql/cluster.sql                   |  3 ++
18 files changed, 74 insertions(+), 105 deletions(-)



Message-ID: <E1qCT7H-0038ei-Uh@gemulon.postgresql.org>
Permalink:  ../E1qCT7H-0038ei-Uh@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qCT7H-0038ei-Uh@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: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix cache lookup hazards introduced by ff9618e82a.
  In-Reply-To: <E1qCT7H-0038ei-Uh@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