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

Commit 5863bac

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 e6c4e01 commit 5863bac

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/bin/pg_dump/pg_dumpall.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -761,39 +761,42 @@ dumpRoles(PGconn *conn)
761761
i_is_current_user;
762762
int i;
763763

764-
/* note: rolconfig is dumped later */
764+
/*
765+
* Notes: rolconfig is dumped later, and pg_authid must be used for
766+
* extracting rolcomment regardless of role_catalog.
767+
*/
765768
if (server_version >= 90600)
766769
printfPQExpBuffer(buf,
767770
"SELECT oid, rolname, rolsuper, rolinherit, "
768771
"rolcreaterole, rolcreatedb, "
769772
"rolcanlogin, rolconnlimit, rolpassword, "
770773
"rolvaliduntil, rolreplication, rolbypassrls, "
771-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
774+
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
772775
"rolname = current_user AS is_current_user "
773776
"FROM %s "
774777
"WHERE rolname !~ '^pg_' "
775-
"ORDER BY 2", role_catalog, role_catalog);
778+
"ORDER BY 2", role_catalog);
776779
else if (server_version >= 90500)
777780
printfPQExpBuffer(buf,
778781
"SELECT oid, rolname, rolsuper, rolinherit, "
779782
"rolcreaterole, rolcreatedb, "
780783
"rolcanlogin, rolconnlimit, rolpassword, "
781784
"rolvaliduntil, rolreplication, rolbypassrls, "
782-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
785+
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
783786
"rolname = current_user AS is_current_user "
784787
"FROM %s "
785-
"ORDER BY 2", role_catalog, role_catalog);
788+
"ORDER BY 2", role_catalog);
786789
else
787790
printfPQExpBuffer(buf,
788791
"SELECT oid, rolname, rolsuper, rolinherit, "
789792
"rolcreaterole, rolcreatedb, "
790793
"rolcanlogin, rolconnlimit, rolpassword, "
791794
"rolvaliduntil, rolreplication, "
792795
"false as rolbypassrls, "
793-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
796+
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
794797
"rolname = current_user AS is_current_user "
795798
"FROM %s "
796-
"ORDER BY 2", role_catalog, role_catalog);
799+
"ORDER BY 2", role_catalog);
797800

798801
res = executeQuery(conn, buf->data);
799802

0 commit comments

Comments
 (0)