6
6
* Portions Copyright (c) 1994, Regents of the University of California
7
7
*
8
8
*
9
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.90 2007/02/10 14:58:55 petere Exp $
9
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.91 2007/05/15 20:20:21 alvherre Exp $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
@@ -702,8 +702,8 @@ dumpRoleMembership(PGconn *conn)
702
702
703
703
res = executeQuery (conn , "SELECT ur.rolname AS roleid, "
704
704
"um.rolname AS member, "
705
- "ug.rolname AS grantor , "
706
- "a.admin_option "
705
+ "a.admin_option , "
706
+ "ug.rolname AS grantor "
707
707
"FROM pg_auth_members a "
708
708
"LEFT JOIN pg_authid ur on ur.oid = a.roleid "
709
709
"LEFT JOIN pg_authid um on um.oid = a.member "
@@ -717,14 +717,24 @@ dumpRoleMembership(PGconn *conn)
717
717
{
718
718
char * roleid = PQgetvalue (res , i , 0 );
719
719
char * member = PQgetvalue (res , i , 1 );
720
- char * grantor = PQgetvalue (res , i , 2 );
721
- char * option = PQgetvalue (res , i , 3 );
720
+ char * option = PQgetvalue (res , i , 2 );
722
721
723
722
fprintf (OPF , "GRANT %s" , fmtId (roleid ));
724
723
fprintf (OPF , " TO %s" , fmtId (member ));
725
724
if (* option == 't' )
726
725
fprintf (OPF , " WITH ADMIN OPTION" );
727
- fprintf (OPF , " GRANTED BY %s;\n" , fmtId (grantor ));
726
+
727
+ /*
728
+ * We don't track the grantor very carefully in the backend, so cope
729
+ * with the possibility that it has been dropped.
730
+ */
731
+ if (!PQgetisnull (res , i , 3 ))
732
+ {
733
+ char * grantor = PQgetvalue (res , i , 3 );
734
+
735
+ fprintf (OPF , " GRANTED BY %s" , fmtId (grantor ));
736
+ }
737
+ fprintf (OPF , ";\n" );
728
738
}
729
739
730
740
PQclear (res );
0 commit comments