From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Relax INSERT privilege requirement for CTAS and matviews WITH NO
Date: Mon, 16 Nov 2020 03:00:42 +0000
Message-ID: <E1keUl0-0008OJ-83@gemulon.postgresql.org> (raw)
Relax INSERT privilege requirement for CTAS and matviews WITH NO DATA
When specified, WITH NO DATA does not insert any data into the relation
created, so skip checking for the insert permissions. With WITH DATA or
WITH NO DATA, it is always required for the user to have CREATE
privileges on the schema targeted for the relation.
Note that plain CREATE TABLE AS or CREATE MATERIALIZED VIEW queries have
begun to work accidentally without INSERT privilege checks as of
874fe3ae, while using EXECUTE or EXPLAIN ANALYZE would fail with the ACL
check, so this makes the behavior for all the command flavors consistent
with each other. This is arguably a bug fix, but there have been no
complaints about the current behavior either so stable branches are not
changed.
While on it, document properly the privileges requirements for each
commands with more tests for all the scenarios possible, and avoid a
useless bulk-insert allocation when using WITH NO DATA.
Author: Bharath Rupireddy
Reviewed-by: Anastasia Lubennikova, Michael Paquier
Discussion: https://postgr.es/m/CALj2ACWc3N8j0_9nMPz9wcAUnVcdKHzFdDZJ3hVFNEbqtcyG9w@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/846005e4f3829c3eafe1f8441b80ff90657d0a29
Modified Files
--------------
doc/src/sgml/ref/create_materialized_view.sgml | 7 +++
doc/src/sgml/ref/create_table_as.sgml | 7 +++
src/backend/commands/createas.c | 84 ++++++++++++++++----------
src/test/regress/expected/matview.out | 35 +++++++++++
src/test/regress/expected/select_into.out | 62 ++++++++++++++++---
src/test/regress/sql/matview.sql | 28 +++++++++
src/test/regress/sql/select_into.sql | 37 ++++++++++--
7 files changed, 212 insertions(+), 48 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: michael@paquier.xyz
Subject: Re: pgsql: Relax INSERT privilege requirement for CTAS and matviews WITH NO
In-Reply-To: <E1keUl0-0008OJ-83@gemulon.postgresql.org>
References: <E1keUl0-0008OJ-83@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