mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
Remove pg_dump/pg_dumpall support for dumping from pre-8.0 servers.
The need for dumping from such ancient servers has decreased to about nil in the field, so let's remove all the code that catered to it. Aside from removing a lot of boilerplate variant queries, this allows us to not have to cope with servers that don't have (a) schemas or (b) pg_depend. That means we can get rid of assorted squishy code around that. There may be some nonobvious additional simplifications possible, but this patch already removes about 1500 lines of code. I did not remove the ability for pg_restore to read custom-format archives generated by these old versions (and light testing says that that does still work). If you have an old server, you probably also have a pg_dump that will work with it; but you have an old custom-format backup file, that might be all you have. It'd be possible at this point to remove fmtQualifiedId()'s version argument, but I refrained since that would affect code outside pg_dump. Discussion: <2661.1475849167@sss.pgh.pa.us>
This commit is contained in:
@ -18,8 +18,6 @@
|
||||
#include "fe_utils/string_utils.h"
|
||||
|
||||
|
||||
#define supports_grant_options(version) ((version) >= 70400)
|
||||
|
||||
static bool parseAclItem(const char *item, const char *type,
|
||||
const char *name, const char *subname, int remoteVersion,
|
||||
PQExpBuffer grantee, PQExpBuffer grantor,
|
||||
@ -246,11 +244,9 @@ buildACLCommands(const char *name, const char *subname,
|
||||
|
||||
/*
|
||||
* For the owner, the default privilege level is ALL WITH
|
||||
* GRANT OPTION (only ALL prior to 7.4).
|
||||
* GRANT OPTION.
|
||||
*/
|
||||
if (supports_grant_options(remoteVersion)
|
||||
? strcmp(privswgo->data, "ALL") != 0
|
||||
: strcmp(privs->data, "ALL") != 0)
|
||||
if (strcmp(privswgo->data, "ALL") != 0)
|
||||
{
|
||||
appendPQExpBuffer(firstsql, "%sREVOKE ALL", prefix);
|
||||
if (subname)
|
||||
@ -403,16 +399,19 @@ buildDefaultACLCommands(const char *type, const char *nspname,
|
||||
* username=privilegecodes/grantor
|
||||
* or
|
||||
* group groupname=privilegecodes/grantor
|
||||
* (the /grantor part will not be present if pre-7.4 database).
|
||||
* (the "group" case occurs only with servers before 8.1).
|
||||
*
|
||||
* Returns true on success, false on parse error. On success, the components
|
||||
* of the string are returned in the PQExpBuffer parameters.
|
||||
*
|
||||
* The returned grantee string will be the dequoted username or groupname
|
||||
* (preceded with "group " in the latter case). The returned grantor is
|
||||
* the dequoted grantor name or empty. Privilege characters are decoded
|
||||
* and split between privileges with grant option (privswgo) and without
|
||||
* (privs).
|
||||
* (preceded with "group " in the latter case). Note that a grant to PUBLIC
|
||||
* is represented by an empty grantee string. The returned grantor is the
|
||||
* dequoted grantor name. Privilege characters are decoded and split between
|
||||
* privileges with grant option (privswgo) and without (privs).
|
||||
*
|
||||
* Note: for cross-version compatibility, it's important to use ALL when
|
||||
* appropriate.
|
||||
* Note: for cross-version compatibility, it's important to use ALL to
|
||||
* represent the privilege sets whenever appropriate.
|
||||
*/
|
||||
static bool
|
||||
parseAclItem(const char *item, const char *type,
|
||||
@ -439,7 +438,7 @@ parseAclItem(const char *item, const char *type,
|
||||
return false;
|
||||
}
|
||||
|
||||
/* grantor may be listed after / */
|
||||
/* grantor should appear after / */
|
||||
slpos = strchr(eqpos + 1, '/');
|
||||
if (slpos)
|
||||
{
|
||||
@ -452,7 +451,10 @@ parseAclItem(const char *item, const char *type,
|
||||
}
|
||||
}
|
||||
else
|
||||
resetPQExpBuffer(grantor);
|
||||
{
|
||||
free(buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* privilege codes */
|
||||
#define CONVERT_PRIV(code, keywd) \
|
||||
@ -490,29 +492,19 @@ do { \
|
||||
{
|
||||
/* table only */
|
||||
CONVERT_PRIV('a', "INSERT");
|
||||
if (remoteVersion >= 70200)
|
||||
CONVERT_PRIV('x', "REFERENCES");
|
||||
CONVERT_PRIV('x', "REFERENCES");
|
||||
/* rest are not applicable to columns */
|
||||
if (subname == NULL)
|
||||
{
|
||||
if (remoteVersion >= 70200)
|
||||
{
|
||||
CONVERT_PRIV('d', "DELETE");
|
||||
CONVERT_PRIV('t', "TRIGGER");
|
||||
}
|
||||
CONVERT_PRIV('d', "DELETE");
|
||||
CONVERT_PRIV('t', "TRIGGER");
|
||||
if (remoteVersion >= 80400)
|
||||
CONVERT_PRIV('D', "TRUNCATE");
|
||||
}
|
||||
}
|
||||
|
||||
/* UPDATE */
|
||||
if (remoteVersion >= 70200 ||
|
||||
strcmp(type, "SEQUENCE") == 0 ||
|
||||
strcmp(type, "SEQUENCES") == 0)
|
||||
CONVERT_PRIV('w', "UPDATE");
|
||||
else
|
||||
/* 7.0 and 7.1 have a simpler worldview */
|
||||
CONVERT_PRIV('w', "UPDATE,DELETE");
|
||||
CONVERT_PRIV('w', "UPDATE");
|
||||
}
|
||||
else if (strcmp(type, "FUNCTION") == 0 ||
|
||||
strcmp(type, "FUNCTIONS") == 0)
|
||||
|
Reference in New Issue
Block a user