mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Tweak pg_dump to say GRANT ALL when appropriate, rather than enumerating
the individual privilege bits. I regard this as an important change for cross-version compatibility: without this, a 7.1 dump loaded into 7.2 is likely to be short a few privileges.
This commit is contained in:
parent
06f08209a9
commit
1b68bcfad3
@ -22,7 +22,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.238 2002/01/18 19:17:05 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.239 2002/01/25 18:49:31 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -3885,47 +3885,53 @@ AddAcl(char *aclbuf, const char *keyword)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This will take a string of 'arwR' and return a malloced,
|
* This will take a string of privilege code letters and return a malloced,
|
||||||
* comma delimited string of SELECT,INSERT,UPDATE,DELETE,RULE
|
* comma delimited string of keywords for GRANT.
|
||||||
|
*
|
||||||
|
* Note: for cross-version compatibility, it's important to use ALL when
|
||||||
|
* appropriate.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
GetPrivileges(Archive *AH, const char *s)
|
GetPrivileges(Archive *AH, const char *s)
|
||||||
{
|
{
|
||||||
char aclbuf[100];
|
char aclbuf[100];
|
||||||
|
bool all = true;
|
||||||
|
|
||||||
aclbuf[0] = '\0';
|
aclbuf[0] = '\0';
|
||||||
|
|
||||||
if (strchr(s, 'a'))
|
#define CONVERT_PRIV(code,keywd) \
|
||||||
AddAcl(aclbuf, "INSERT");
|
if (strchr(s, code)) \
|
||||||
|
AddAcl(aclbuf, keywd); \
|
||||||
|
else \
|
||||||
|
all = false
|
||||||
|
|
||||||
if (strchr(s, 'r'))
|
CONVERT_PRIV('a', "INSERT");
|
||||||
AddAcl(aclbuf, "SELECT");
|
CONVERT_PRIV('r', "SELECT");
|
||||||
|
CONVERT_PRIV('R', "RULE");
|
||||||
if (strchr(s, 'R'))
|
|
||||||
AddAcl(aclbuf, "RULE");
|
|
||||||
|
|
||||||
if (AH->remoteVersion >= 70200)
|
if (AH->remoteVersion >= 70200)
|
||||||
{
|
{
|
||||||
if (strchr(s, 'w'))
|
CONVERT_PRIV('w', "UPDATE");
|
||||||
AddAcl(aclbuf, "UPDATE");
|
CONVERT_PRIV('d', "DELETE");
|
||||||
if (strchr(s, 'd'))
|
CONVERT_PRIV('x', "REFERENCES");
|
||||||
AddAcl(aclbuf, "DELETE");
|
CONVERT_PRIV('t', "TRIGGER");
|
||||||
if (strchr(s, 'x'))
|
|
||||||
AddAcl(aclbuf, "REFERENCES");
|
|
||||||
if (strchr(s, 't'))
|
|
||||||
AddAcl(aclbuf, "TRIGGER");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (strchr(s, 'w'))
|
/* 7.0 and 7.1 have a simpler worldview */
|
||||||
AddAcl(aclbuf, "UPDATE,DELETE");
|
CONVERT_PRIV('w', "UPDATE,DELETE");
|
||||||
}
|
}
|
||||||
|
|
||||||
return strdup(aclbuf);
|
#undef CONVERT_PRIV
|
||||||
|
|
||||||
|
if (all)
|
||||||
|
return strdup("ALL");
|
||||||
|
else
|
||||||
|
return strdup(aclbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The name says it all; a function to append a string is the dest
|
* The name says it all; a function to append a string if the dest
|
||||||
* is big enough. If not, it does a realloc.
|
* is big enough. If not, it does a realloc.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user