Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd365ce1

Browse files
committed
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 factthat we don't track the grantor as a shared dependency.
1 parent0f77636 commitd365ce1

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
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 $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -702,8 +702,8 @@ dumpRoleMembership(PGconn *conn)
702702

703703
res=executeQuery(conn,"SELECT ur.rolname AS roleid, "
704704
"um.rolname AS member, "
705-
"ug.rolname AS grantor, "
706-
"a.admin_option "
705+
"a.admin_option, "
706+
"ug.rolname AS grantor "
707707
"FROM pg_auth_members a "
708708
"LEFT JOIN pg_authid ur on ur.oid = a.roleid "
709709
"LEFT JOIN pg_authid um on um.oid = a.member "
@@ -717,14 +717,24 @@ dumpRoleMembership(PGconn *conn)
717717
{
718718
char*roleid=PQgetvalue(res,i,0);
719719
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);
722721

723722
fprintf(OPF,"GRANT %s",fmtId(roleid));
724723
fprintf(OPF," TO %s",fmtId(member));
725724
if (*option=='t')
726725
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");
728738
}
729739

730740
PQclear(res);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp