postgresql/src/backend/commands
Michael Paquier 846005e4f3 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
2020-11-16 11:52:40 +09:00
..
Makefile Revert 0f5ca02f53 2020-04-08 11:37:27 +03:00
aggregatecmds.c Move catalog index declarations 2020-11-07 12:26:24 +01:00
alter.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
amcmds.c Unify drop-by-OID functions 2020-06-09 09:39:46 +02:00
analyze.c snapshot scalability: Don't compute global horizons while building snapshots. 2020-08-12 16:03:49 -07:00
async.c Defer flushing of SLRU files. 2020-09-25 19:00:15 +12:00
cluster.c Centralize horizon determination for temp tables, fixing bug due to skew. 2020-10-28 18:02:31 -07:00
collationcmds.c Track collation versions for indexes. 2020-11-03 01:19:50 +13:00
comment.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
constraint.c Fix bogus CALLED_AS_TRIGGER() defenses. 2020-04-03 11:24:56 -04:00
conversioncmds.c Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
copy.c Fix some grammar and typos in comments and docs 2020-11-02 15:14:41 +09:00
createas.c Relax INSERT privilege requirement for CTAS and matviews WITH NO DATA 2020-11-16 11:52:40 +09:00
dbcommands.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
define.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
discard.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
dropcmds.c Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
event_trigger.c Don't use custom OID symbols in pg_type.dat, either. 2020-10-29 13:33:38 -04:00
explain.c Fix broken XML formatting in EXPLAIN output for incremental sorts. 2020-10-23 11:32:33 -04:00
extension.c Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
foreigncmds.c Unify drop-by-OID functions 2020-06-09 09:39:46 +02:00
functioncmds.c Support for OUT parameters in procedures 2020-10-05 09:21:43 +02:00
indexcmds.c Fix fuzzy thinking about amcanmulticol versus amcaninclude. 2020-11-15 16:10:58 -05:00
lockcmds.c Fix cases of discarding result from list API functions 2020-11-11 08:03:51 +01:00
matview.c pg_stat_statements: track number of rows processed by REFRESH MATERIALIZED VIEW. 2020-11-12 11:26:55 +09:00
opclasscmds.c Message fixes and style improvements 2020-09-14 06:42:30 +02:00
operatorcmds.c Remove support for postfix (right-unary) operators. 2020-09-17 19:38:05 -04:00
policy.c Revise RelationBuildRowSecurity() to avoid memory leaks. 2020-09-26 16:04:06 -04:00
portalcmds.c In security-restricted operations, block enqueue of at-commit user code. 2020-11-09 07:32:09 -08:00
prepare.c Add generic_plans and custom_plans fields into pg_prepared_statements. 2020-07-20 11:55:50 +09:00
proclang.c Switch to multi-inserts when registering dependencies for many code paths 2020-09-05 21:33:53 +09:00
publicationcmds.c Unify drop-by-OID functions 2020-06-09 09:39:46 +02:00
schemacmds.c Unify drop-by-OID functions 2020-06-09 09:39:46 +02:00
seclabel.c Grammar object type refactoring 2020-06-13 09:19:30 +02:00
sequence.c Minor mop-up for List improvements. 2020-09-27 22:30:52 -04:00
statscmds.c Replace remaining StrNCpy() by strlcpy() 2020-08-10 23:20:37 +02:00
subscriptioncmds.c Add support for streaming to built-in logical replication. 2020-09-03 07:54:07 +05:30
tablecmds.c Provide the OR REPLACE option for CREATE TRIGGER. 2020-11-14 17:05:34 -05:00
tablespace.c Fix temporary tablespaces for shared filesets some more. 2020-07-03 17:01:34 -04:00
trigger.c Provide the OR REPLACE option for CREATE TRIGGER. 2020-11-14 17:05:34 -05:00
tsearchcmds.c Switch to multi-inserts when registering dependencies for many code paths 2020-09-05 21:33:53 +09:00
typecmds.c Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
user.c Improve error messages around REPLICATION and BYPASSRLS properties. 2020-11-03 15:49:05 -05:00
vacuum.c Centralize horizon determination for temp tables, fixing bug due to skew. 2020-10-28 18:02:31 -07:00
variable.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
view.c Restructure ALTER TABLE execution to fix assorted bugs. 2020-01-15 18:49:24 -05:00