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

Commita7b2fca

Browse files
committed
Fix ordering of GRANT commands in pg_dumpall for tablespaces
This uses a method similar to68a7c24 and nowb8c6014 (applied fordatabase creation), which guarantees that GRANT commands using the WITHGRANT OPTION are dumped in a way so as cascading dependencies arerespected. Note that tablespaces do not have support for initialprivileges via pg_init_privs, so the same method needs to be appliedagain. It would be nice to merge all the logic generating ACL queriesin dumps under the same banner, but this requires extending the supportof pg_init_privs to objects that cannot use it yet, so this is left asfuture work.Discussion:https://postgr.es/m/20190522071555.GB1278@paquier.xyzAuthor: Michael PaquierReviewed-by: Nathan BossartBackpatch-through: 9.6
1 parent8357a41 commita7b2fca

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,19 +1134,38 @@ dumpTablespaces(PGconn *conn)
11341134
*
11351135
* See buildACLQueries() and buildACLCommands().
11361136
*
1137+
* The order in which privileges are in the ACL string (the order they
1138+
* have been GRANT'd in, which the backend maintains) must be preserved to
1139+
* ensure that GRANTs WITH GRANT OPTION and subsequent GRANTs based on
1140+
* those are dumped in the correct order.
1141+
*
11371142
* Note that we do not support initial privileges (pg_init_privs) on
1138-
* tablespaces.
1143+
* tablespaces, so this logic cannot make use of buildACLQueries().
11391144
*/
11401145
if (server_version >=90600)
11411146
res=executeQuery(conn,"SELECT oid, spcname, "
11421147
"pg_catalog.pg_get_userbyid(spcowner) AS spcowner, "
11431148
"pg_catalog.pg_tablespace_location(oid), "
1144-
"(SELECT pg_catalog.array_agg(acl) FROM (SELECT pg_catalog.unnest(coalesce(spcacl,pg_catalog.acldefault('t',spcowner))) AS acl "
1145-
"EXCEPT SELECT pg_catalog.unnest(pg_catalog.acldefault('t',spcowner))) as foo)"
1146-
"AS spcacl,"
1147-
"(SELECT pg_catalog.array_agg(acl) FROM (SELECT pg_catalog.unnest(pg_catalog.acldefault('t',spcowner)) AS acl "
1148-
"EXCEPT SELECT pg_catalog.unnest(coalesce(spcacl,pg_catalog.acldefault('t',spcowner)))) as foo)"
1149-
"AS rspcacl,"
1149+
"(SELECT array_agg(acl ORDER BY row_n) FROM "
1150+
" (SELECT acl, row_n FROM "
1151+
" unnest(coalesce(spcacl,acldefault('t',spcowner))) "
1152+
" WITH ORDINALITY AS perm(acl,row_n) "
1153+
" WHERE NOT EXISTS ( "
1154+
" SELECT 1 "
1155+
" FROM unnest(acldefault('t',spcowner)) "
1156+
" AS init(init_acl) "
1157+
" WHERE acl = init_acl)) AS spcacls) "
1158+
" AS spcacl, "
1159+
"(SELECT array_agg(acl ORDER BY row_n) FROM "
1160+
" (SELECT acl, row_n FROM "
1161+
" unnest(acldefault('t',spcowner)) "
1162+
" WITH ORDINALITY AS initp(acl,row_n) "
1163+
" WHERE NOT EXISTS ( "
1164+
" SELECT 1 "
1165+
" FROM unnest(coalesce(spcacl,acldefault('t',spcowner))) "
1166+
" AS permp(orig_acl) "
1167+
" WHERE acl = orig_acl)) AS rspcacls) "
1168+
" AS rspcacl, "
11501169
"array_to_string(spcoptions, ', '),"
11511170
"pg_catalog.shobj_description(oid, 'pg_tablespace') "
11521171
"FROM pg_catalog.pg_tablespace "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp