Alvaro Herrera wrote:

> 2. decide that the standard is braindead and just omit dumping the
>    grantor when it's no longer available, but don't remove
>    pg_auth_members.grantor
> 
> Which do people feel should be implemented?  I can do whatever we
> decide; if no one has a strong opinion on the matter, my opinion is we
> do (2) which is the easiest.

Here is a patch implementing this idea, vaguely based on Russell's.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
Index: src/bin/pg_dump/pg_dumpall.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/bin/pg_dump/pg_dumpall.c,v
retrieving revision 1.90
diff -c -p -r1.90 pg_dumpall.c
*** src/bin/pg_dump/pg_dumpall.c	10 Feb 2007 14:58:55 -0000	1.90
--- src/bin/pg_dump/pg_dumpall.c	14 May 2007 23:13:43 -0000
*************** dumpRoleMembership(PGconn *conn)
*** 702,709 ****
  
  	res = executeQuery(conn, "SELECT ur.rolname AS roleid, "
  					   "um.rolname AS member, "
! 					   "ug.rolname AS grantor, "
! 					   "a.admin_option "
  					   "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 "
--- 702,709 ----
  
  	res = executeQuery(conn, "SELECT ur.rolname AS roleid, "
  					   "um.rolname AS member, "
! 					   "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 "
*************** dumpRoleMembership(PGconn *conn)
*** 717,730 ****
  	{
  		char	   *roleid = PQgetvalue(res, i, 0);
  		char	   *member = PQgetvalue(res, i, 1);
! 		char	   *grantor = PQgetvalue(res, i, 2);
! 		char	   *option = PQgetvalue(res, i, 3);
  
  		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));
  	}
  
  	PQclear(res);
--- 717,740 ----
  	{
  		char	   *roleid = PQgetvalue(res, i, 0);
  		char	   *member = PQgetvalue(res, i, 1);
! 		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");
! 
! 		/*
! 		 * 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);
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to