Skip to content

Commit 7e65ad1

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 485f0aa commit 7e65ad1

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
@@ -769,39 +769,42 @@ dumpRoles(PGconn *conn)
769769
i_is_current_user;
770770
int i;
771771

772-
/* note: rolconfig is dumped later */
772+
/*
773+
* Notes: rolconfig is dumped later, and pg_authid must be used for
774+
* extracting rolcomment regardless of role_catalog.
775+
*/
773776
if (server_version >= 90600)
774777
printfPQExpBuffer(buf,
775778
"SELECT oid, rolname, rolsuper, rolinherit, "
776779
"rolcreaterole, rolcreatedb, "
777780
"rolcanlogin, rolconnlimit, rolpassword, "
778781
"rolvaliduntil, rolreplication, rolbypassrls, "
779-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
782+
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
780783
"rolname = current_user AS is_current_user "
781784
"FROM %s "
782785
"WHERE rolname !~ '^pg_' "
783-
"ORDER BY 2", role_catalog, role_catalog);
786+
"ORDER BY 2", role_catalog);
784787
else if (server_version >= 90500)
785788
printfPQExpBuffer(buf,
786789
"SELECT oid, rolname, rolsuper, rolinherit, "
787790
"rolcreaterole, rolcreatedb, "
788791
"rolcanlogin, rolconnlimit, rolpassword, "
789792
"rolvaliduntil, rolreplication, rolbypassrls, "
790-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
793+
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
791794
"rolname = current_user AS is_current_user "
792795
"FROM %s "
793-
"ORDER BY 2", role_catalog, role_catalog);
796+
"ORDER BY 2", role_catalog);
794797
else
795798
printfPQExpBuffer(buf,
796799
"SELECT oid, rolname, rolsuper, rolinherit, "
797800
"rolcreaterole, rolcreatedb, "
798801
"rolcanlogin, rolconnlimit, rolpassword, "
799802
"rolvaliduntil, rolreplication, "
800803
"false as rolbypassrls, "
801-
"pg_catalog.shobj_description(oid, '%s') as rolcomment, "
804+
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, "
802805
"rolname = current_user AS is_current_user "
803806
"FROM %s "
804-
"ORDER BY 2", role_catalog, role_catalog);
807+
"ORDER BY 2", role_catalog);
805808

806809
res = executeQuery(conn, buf->data);
807810

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy