From: Robert Haas Date: Fri, 14 Oct 2011 18:16:02 +0000 (-0400) Subject: Dump all roles first, then all config settings on roles. X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=dea95c7a7beb5ef66ce89269dd0e84d0c26e5523;p=users%2Fkgrittn%2Fpostgres.git Dump all roles first, then all config settings on roles. This way, if a role's config setting uses the name of another role, the validity of the dump isn't dependent on the order in which those two roles are dumped. Code by Phil Sorber, comment by me. --- diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index b5f64e8d68..0022d2d74e 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -804,11 +804,17 @@ dumpRoles(PGconn *conn) buf, "ROLE", rolename); fprintf(OPF, "%s", buf->data); - - if (server_version >= 70300) - dumpUserConfig(conn, rolename); } + /* + * Dump configuration settings for roles after all roles have been dumped. + * We do it this way because config settings for roles could mention the + * names of other roles. + */ + if (server_version >= 70300) + for (i = 0; i < PQntuples(res); i++) + dumpUserConfig(conn, PQgetvalue(res, i, i_rolname)); + PQclear(res); fprintf(OPF, "\n\n");