ACL dump ordering broken as well for tablespaces
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Cc: bossartn@amazon.com, Stephen Frost <sfrost@snowman.net>, kommi.haribabu@gmail.com
Date: 2019-05-22T07:15:55Z
Lists: pgsql-hackers
Attachments
- dump-tbspcs-acls-v1.patch (text/x-diff) patch v1
Hi all, As some may have noticed, I have been looking at the ACL dump ordering for databases, and I have noticed the same issue with tablespaces: https://www.postgresql.org/message-id/20190522062626.GC1486@paquier.xyz For the sake of avoiding looking at the other email, here is how to reproduce the issue: 1) First issue those SQLs: \! rm -rf /tmp/tbspc/ \! mkdir -p /tmp/tbspc/ CREATE ROLE a_user; CREATE ROLE b_user WITH SUPERUSER; CREATE ROLE c_user; CREATE TABLESPACE poo LOCATION '/tmp/tbspc/'; SET SESSION AUTHORIZATION b_user; REVOKE ALL ON TABLESPACE poo FROM public; GRANT CREATE ON TABLESPACE poo TO c_user WITH GRANT OPTION; SET SESSION AUTHORIZATION c_user; GRANT CREATE ON TABLESPACE poo TO a_user 2) Use pg_dumpall -g, where you would notice the following set of GRANT queries: CREATE TABLESPACE poo OWNER postgres LOCATION '/tmp/tbspc'; SET SESSION AUTHORIZATION c_user; GRANT ALL ON TABLESPACE poo TO a_user; RESET SESSION AUTHORIZATION; GRANT ALL ON TABLESPACE poo TO c_user WITH GRANT OPTION; 3) Trying to restore results in a failure for the first GRANT query, as the second one has not set yet the authorizations for c_user. Attached is a patch to fix that, so as pg_dumpall does not complain when piling up GRANT commands using WITH GRANT OPTION. Are there any complains to apply that down to 9.6? When applying the patch, the set of GRANT queries is reordered: CREATE TABLESPACE poo OWNER postgres LOCATION '/tmp/tbspc'; +GRANT ALL ON TABLESPACE poo TO c_user WITH GRANT OPTION; SET SESSION AUTHORIZATION c_user; GRANT ALL ON TABLESPACE poo TO a_user; RESET SESSION AUTHORIZATION; -GRANT ALL ON TABLESPACE poo TO c_user WITH GRANT OPTION; As the problem is kind of different than the database case, I wanted to spawn anyway a new thread, but I got a bonus question: what would it take to support pg_init_privs for databases and tablespaces? If we could get that to work, then all the ACL-related queries built for all objects could make use of buildACLQueries(), which would avoid extra diffs in the dump code for dbs and tbspaces. Thoughts? -- Michael
Commits
-
Fix ordering of GRANT commands in pg_dumpall for tablespaces
- c82e8ba00163 9.6.14 landed
- 2ccebcd23689 10.9 landed
- a7b2fca15b25 11.4 landed
- 156c0c2dff40 12.0 landed
-
Correctly dump database and tablespace ACLs
- 47f5bb9f539a 9.6.0 cited