Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c2a5a8

Browse files
committed
Fix ordering of GRANT commands in pg_dumpall for database creation
This uses a method similar to68a7c24, which guarantees that GRANTcommands using the WITH GRANT OPTION are dumped in a way so as cascadingdependencies are respected. As databases do not have support forinitial privileges via pg_init_privs, we need to repeat again the sameACL reordering method.ACL for databases have been moved from pg_dumpall to pg_dump in v11, sothis impacts pg_dump for v11 and above, and pg_dumpall for v9.6 andv10.Discussion:https://postgr.es/m/15788-4e18847520ebcc75@postgresql.orgAuthor: Nathan BossartReviewed-by: Haribabu KommiBackpatch-through: 9.6
1 parent7f920b8 commit0c2a5a8

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

‎src/bin/pg_dump/pg_dumpall.c‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,8 +1349,13 @@ dumpCreateDB(PGconn *conn)
13491349
*
13501350
* See buildACLQueries() and buildACLCommands().
13511351
*
1352+
* The order in which privileges are in the ACL string (the order they
1353+
* have been GRANT'd in, which the backend maintains) must be preserved to
1354+
* ensure that GRANTs WITH GRANT OPTION and subsequent GRANTs based on
1355+
* those are dumped in the correct order.
1356+
*
13521357
* Note that we do not support initial privileges (pg_init_privs) on
1353-
* databases.
1358+
* databases, so this logic cannot make use of buildACLQueries().
13541359
*/
13551360
if (server_version >=90600)
13561361
printfPQExpBuffer(buf,
@@ -1359,14 +1364,26 @@ dumpCreateDB(PGconn *conn)
13591364
"pg_encoding_to_char(d.encoding), "
13601365
"datcollate, datctype, datfrozenxid, datminmxid, "
13611366
"datistemplate, "
1362-
"(SELECT pg_catalog.array_agg(acl ORDER BY acl::text COLLATE \"C\") FROM ( "
1363-
" SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba))) AS acl "
1364-
" EXCEPT SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba))) as datacls)"
1365-
"AS datacl, "
1366-
"(SELECT pg_catalog.array_agg(acl ORDER BY acl::text COLLATE \"C\") FROM ( "
1367-
" SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba)) AS acl "
1368-
" EXCEPT SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba)))) as rdatacls)"
1369-
"AS rdatacl, "
1367+
"(SELECT array_agg(acl ORDER BY row_n) FROM "
1368+
" (SELECT acl, row_n FROM "
1369+
" unnest(coalesce(datacl,acldefault('d',datdba))) "
1370+
" WITH ORDINALITY AS perm(acl,row_n) "
1371+
" WHERE NOT EXISTS ( "
1372+
" SELECT 1 "
1373+
" FROM unnest(acldefault('d',datdba)) "
1374+
" AS init(init_acl) "
1375+
" WHERE acl = init_acl)) AS datacls) "
1376+
" AS datacl, "
1377+
"(SELECT array_agg(acl ORDER BY row_n) FROM "
1378+
" (SELECT acl, row_n FROM "
1379+
" unnest(acldefault('d',datdba)) "
1380+
" WITH ORDINALITY AS initp(acl,row_n) "
1381+
" WHERE NOT EXISTS ( "
1382+
" SELECT 1 "
1383+
" FROM unnest(coalesce(datacl,acldefault('d',datdba))) "
1384+
" AS permp(orig_acl) "
1385+
" WHERE acl = orig_acl)) AS rdatacls) "
1386+
" AS rdatacl, "
13701387
"datconnlimit, "
13711388
"(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
13721389
"FROM pg_database d LEFT JOIN %s u ON (datdba = u.oid) "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp