Reintroduce MAINTAIN privilege and pg_maintain predefined role.

Nathan Bossart <nathan@postgresql.org>

Commit: ecb0fd33720fab91df1207e85704f382f55e1eb7
Author: Nathan Bossart <nathan@postgresql.org>
Date: 2024-03-13T19:49:26Z
Releases: 17.0
Reintroduce MAINTAIN privilege and pg_maintain predefined role.

Roles with MAINTAIN on a relation may run VACUUM, ANALYZE, REINDEX,
REFRESH MATERIALIZE VIEW, CLUSTER, and LOCK TABLE on the relation.
Roles with privileges of pg_maintain may run those same commands on
all relations.

This was previously committed for v16, but it was reverted in
commit 151c22deee due to concerns about search_path tricks that
could be used to escalate privileges to the table owner.  Commits
2af07e2f74, 59825d1639, and c7ea3f4229 resolved these concerns by
restricting search_path when running maintenance commands.

Bumps catversion.

Reviewed-by: Jeff Davis
Discussion: https://postgr.es/m/20240305161235.GA3478007%40nathanxps13

Files

PathChange+/−
doc/src/sgml/ddl.sgml modified +26 −9
doc/src/sgml/func.sgml modified +1 −1
doc/src/sgml/ref/alter_default_privileges.sgml modified +2 −2
doc/src/sgml/ref/analyze.sgml modified +2 −4
doc/src/sgml/ref/cluster.sgml modified +7 −3
doc/src/sgml/ref/grant.sgml modified +2 −1
doc/src/sgml/ref/lock.sgml modified +2 −2
doc/src/sgml/ref/refresh_materialized_view.sgml modified +3 −2
doc/src/sgml/ref/reindex.sgml modified +14 −9
doc/src/sgml/ref/revoke.sgml modified +1 −1
doc/src/sgml/ref/vacuum.sgml modified +2 −4
doc/src/sgml/user-manag.sgml modified +12 −0
src/backend/catalog/aclchk.c modified +15 −0
src/backend/commands/analyze.c modified +6 −7
src/backend/commands/cluster.c modified +32 −11
src/backend/commands/indexcmds.c modified +20 −14
src/backend/commands/lockcmds.c modified +1 −1
src/backend/commands/matview.c modified +2 −1
src/backend/commands/tablecmds.c modified +11 −7
src/backend/commands/vacuum.c modified +46 −30
src/backend/postmaster/autovacuum.c modified +1 −0
src/backend/utils/adt/acl.c modified +8 −0
src/bin/pg_dump/dumputils.c modified +1 −0
src/bin/pg_dump/t/002_pg_dump.pl modified +1 −1
src/bin/psql/tab-complete.c modified +3 −3
src/include/catalog/catversion.h modified +1 −1
src/include/catalog/pg_authid.dat modified +5 −0
src/include/commands/tablecmds.h modified +3 −2
src/include/commands/vacuum.h modified +3 −2
src/include/nodes/parsenodes.h modified +2 −1
src/include/utils/acl.h modified +3 −2
src/test/isolation/expected/cluster-conflict-partition.out modified +4 −4
src/test/isolation/specs/cluster-conflict-partition.spec modified +1 −1
src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm modified +11 −0
src/test/regress/expected/cluster.out modified +7 −0
src/test/regress/expected/create_index.out modified +2 −2
src/test/regress/expected/dependency.out modified +11 −11
src/test/regress/expected/privileges.out modified +93 −23
src/test/regress/expected/rowsecurity.out modified +17 −17
src/test/regress/sql/cluster.sql modified +5 −0
src/test/regress/sql/dependency.sql modified +1 −1
src/test/regress/sql/privileges.sql modified +67 −0

Documentation touched

Discussion