aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2007-05-15 20:20:21 +0000
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2007-05-15 20:20:21 +0000
commitd365ce1f5c90278c577ffe52a80adebee9cb3c33 (patch)
treece0ad361f64fd4ca9130db30ca1c563980a8016a /src
parent0f77636c2e3fd681707b447e9264e5d1f56ed2ef (diff)
downloadpostgresql-d365ce1f5c90278c577ffe52a80adebee9cb3c33.tar.gz
postgresql-d365ce1f5c90278c577ffe52a80adebee9cb3c33.zip
Avoid emitting empty role names in the GRANTED BY clause of GRANT ROLE
when the grantor has been dropped. This is a workaround for the fact that we don't track the grantor as a shared dependency.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dumpall.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 0540969e84b..a8883484276 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.90 2007/02/10 14:58:55 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.91 2007/05/15 20:20:21 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -702,8 +702,8 @@ dumpRoleMembership(PGconn *conn)
res = executeQuery(conn, "SELECT ur.rolname AS roleid, "
"um.rolname AS member, "
- "ug.rolname AS grantor, "
- "a.admin_option "
+ "a.admin_option, "
+ "ug.rolname AS grantor "
"FROM pg_auth_members a "
"LEFT JOIN pg_authid ur on ur.oid = a.roleid "
"LEFT JOIN pg_authid um on um.oid = a.member "
@@ -717,14 +717,24 @@ dumpRoleMembership(PGconn *conn)
{
char *roleid = PQgetvalue(res, i, 0);
char *member = PQgetvalue(res, i, 1);
- char *grantor = PQgetvalue(res, i, 2);
- char *option = PQgetvalue(res, i, 3);
+ char *option = PQgetvalue(res, i, 2);
fprintf(OPF, "GRANT %s", fmtId(roleid));
fprintf(OPF, " TO %s", fmtId(member));
if (*option == 't')
fprintf(OPF, " WITH ADMIN OPTION");
- fprintf(OPF, " GRANTED BY %s;\n", fmtId(grantor));
+
+ /*
+ * We don't track the grantor very carefully in the backend, so cope
+ * with the possibility that it has been dropped.
+ */
+ if (!PQgetisnull(res, i, 3))
+ {
+ char *grantor = PQgetvalue(res, i, 3);
+
+ fprintf(OPF, " GRANTED BY %s", fmtId(grantor));
+ }
+ fprintf(OPF, ";\n");
}
PQclear(res);