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

Commit1b68bcf

Browse files
committed
Tweak pg_dump to say GRANT ALL when appropriate, rather than enumerating
the individual privilege bits. I regard this as an important change forcross-version compatibility: without this, a 7.1 dump loaded into 7.2is likely to be short a few privileges.
1 parent06f0820 commit1b68bcf

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.238 2002/01/18 19:17:05 momjian Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.239 2002/01/25 18:49:31 tgl Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -3885,47 +3885,53 @@ AddAcl(char *aclbuf, const char *keyword)
38853885
}
38863886

38873887
/*
3888-
* This will take a string of 'arwR' and return a malloced,
3889-
* comma delimited string of SELECT,INSERT,UPDATE,DELETE,RULE
3888+
* This will take a string of privilege code letters and return a malloced,
3889+
* comma delimited string of keywords for GRANT.
3890+
*
3891+
* Note: for cross-version compatibility, it's important to use ALL when
3892+
* appropriate.
38903893
*/
38913894
staticchar*
38923895
GetPrivileges(Archive*AH,constchar*s)
38933896
{
38943897
characlbuf[100];
3898+
boolall= true;
38953899

38963900
aclbuf[0]='\0';
38973901

3898-
if (strchr(s,'a'))
3899-
AddAcl(aclbuf,"INSERT");
3900-
3901-
if (strchr(s,'r'))
3902-
AddAcl(aclbuf,"SELECT");
3902+
#defineCONVERT_PRIV(code,keywd) \
3903+
if (strchr(s, code)) \
3904+
AddAcl(aclbuf, keywd); \
3905+
else \
3906+
all = false
39033907

3904-
if (strchr(s,'R'))
3905-
AddAcl(aclbuf,"RULE");
3908+
CONVERT_PRIV('a',"INSERT");
3909+
CONVERT_PRIV('r',"SELECT");
3910+
CONVERT_PRIV('R',"RULE");
39063911

39073912
if (AH->remoteVersion >=70200)
39083913
{
3909-
if (strchr(s,'w'))
3910-
AddAcl(aclbuf,"UPDATE");
3911-
if (strchr(s,'d'))
3912-
AddAcl(aclbuf,"DELETE");
3913-
if (strchr(s,'x'))
3914-
AddAcl(aclbuf,"REFERENCES");
3915-
if (strchr(s,'t'))
3916-
AddAcl(aclbuf,"TRIGGER");
3914+
CONVERT_PRIV('w',"UPDATE");
3915+
CONVERT_PRIV('d',"DELETE");
3916+
CONVERT_PRIV('x',"REFERENCES");
3917+
CONVERT_PRIV('t',"TRIGGER");
39173918
}
39183919
else
39193920
{
3920-
if (strchr(s,'w'))
3921-
AddAcl(aclbuf,"UPDATE,DELETE");
3921+
/* 7.0 and 7.1 have a simpler worldview */
3922+
CONVERT_PRIV('w',"UPDATE,DELETE");
39223923
}
39233924

3924-
returnstrdup(aclbuf);
3925+
#undef CONVERT_PRIV
3926+
3927+
if (all)
3928+
returnstrdup("ALL");
3929+
else
3930+
returnstrdup(aclbuf);
39253931
}
39263932

39273933
/*
3928-
* The name says it all; a function to append a stringis the dest
3934+
* The name says it all; a function to append a stringif the dest
39293935
* is big enough. If not, it does a realloc.
39303936
*/
39313937
staticvoid

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp