Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d82cb46

Browse files
Fix dumping role comments when using --no-role-passwords
Commit 9a83d56 added support for allowing pg_dumpall to dump roles without including passwords, which accidentally made dumps omit COMMENTs on roles. This fixes it by using pg_authid to get the comment. Backpatch to all supported versions. Patch simultaneously written independently by Álvaro and myself. Author: Álvaro Herrera <alvherre@alvh.no-ip.org> Author: Daniel Gustafsson <daniel@yesql.se> Reported-by: Bartosz Chroł <bartosz.chrol@handen.pl> Discussion: https://postgr.es/m/AS8P194MB1271CDA0ADCA7B75FCD8E767F7332@AS8P194MB1271.EURP194.PROD.OUTLOOK.COM Discussion: https://postgr.es/m/CAEP4nAz9V4H41_4ESJd1Gf0v%3DdevkqO1%3Dpo91jUw-GJSx8Hxqg%40mail.gmail.com Backpatch-through: v12
1 parent 58efabd commit d82cb46

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/bin/pg_dump/pg_dumpall.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -754,50 +754,53 @@ dumpRoles(PGconn *conn)
754754
i_is_current_user;
755755
int i;
756756

757-
/* note: rolconfig is dumped later */
757+
/*
758+
* Notes: rolconfig is dumped later, and pg_authid must be used for
759+
* extracting rolcomment regardless of role_catalog.
760+
*/
758761
if (server_version >= 90600)
759762
printfPQExpBuffer(buf,
760763
"SELECT oid, rolname, rolsuper, rolinherit, "
761764
"rolcreaterole, rolcreatedb, "
762765
"rolcanlogin, rolconnlimit, rolpassword, "
763766
"rolvaliduntil, rolreplication, rolbypassrls, "
764-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
767+
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
765768
"rolname = current_user AS is_current_user "
766769
"FROM %s "
767770
"WHERE rolname !~ '^pg_' "
768-
"ORDER BY 2", role_catalog, role_catalog);
771+
"ORDER BY 2", role_catalog);
769772
else if (server_version >= 90500)
770773
printfPQExpBuffer(buf,
771774
"SELECT oid, rolname, rolsuper, rolinherit, "
772775
"rolcreaterole, rolcreatedb, "
773776
"rolcanlogin, rolconnlimit, rolpassword, "
774777
"rolvaliduntil, rolreplication, rolbypassrls, "
775-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
778+
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
776779
"rolname = current_user AS is_current_user "
777780
"FROM %s "
778-
"ORDER BY 2", role_catalog, role_catalog);
781+
"ORDER BY 2", role_catalog);
779782
else if (server_version >= 90100)
780783
printfPQExpBuffer(buf,
781784
"SELECT oid, rolname, rolsuper, rolinherit, "
782785
"rolcreaterole, rolcreatedb, "
783786
"rolcanlogin, rolconnlimit, rolpassword, "
784787
"rolvaliduntil, rolreplication, "
785788
"false as rolbypassrls, "
786-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
789+
"pg_catalog.shobj_description(oid, pg_authid') as rolcomment, "
787790
"rolname = current_user AS is_current_user "
788791
"FROM %s "
789-
"ORDER BY 2", role_catalog, role_catalog);
792+
"ORDER BY 2", role_catalog);
790793
else if (server_version >= 80200)
791794
printfPQExpBuffer(buf,
792795
"SELECT oid, rolname, rolsuper, rolinherit, "
793796
"rolcreaterole, rolcreatedb, "
794797
"rolcanlogin, rolconnlimit, rolpassword, "
795798
"rolvaliduntil, false as rolreplication, "
796799
"false as rolbypassrls, "
797-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
800+
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
798801
"rolname = current_user AS is_current_user "
799802
"FROM %s "
800-
"ORDER BY 2", role_catalog, role_catalog);
803+
"ORDER BY 2", role_catalog);
801804
else if (server_version >= 80100)
802805
printfPQExpBuffer(buf,
803806
"SELECT oid, rolname, rolsuper, rolinherit, "

0 commit comments

Comments
 (0)