From: Tom Lane Date: Thu, 4 Jan 2007 17:49:42 +0000 (+0000) Subject: Tweak pg_dumpall to add GRANT CONNECT ON DATABASE ... TO PUBLIC when dumping X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=eaf193ea4439b3dedbcc04af1dab6832d3ad0fc7;p=users%2Fbernd%2Fpostgres.git Tweak pg_dumpall to add GRANT CONNECT ON DATABASE ... TO PUBLIC when dumping database privileges from a pre-8.2 server. This ensures that the reloaded database will maintain the same behavior it had in the previous installation, ie, everybody has connect privilege. Per gripe from L Bayuk. --- diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index a0e6fa3411..c0edad3639 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -438,6 +438,20 @@ buildACLCommands(const char *name, const char *type, appendPQExpBuffer(firstsql, "REVOKE ALL ON %s %s FROM PUBLIC;\n", type, name); + /* + * We still need some hacking though to cover the case where new default + * public privileges are added in new versions: the REVOKE ALL will revoke + * them, leading to behavior different from what the old version had, + * which is generally not what's wanted. So add back default privs if + * the source database is too old to have had that particular priv. + */ + if (remoteVersion < 80200 && strcmp(type, "DATABASE") == 0) + { + /* database CONNECT priv didn't exist before 8.2 */ + appendPQExpBuffer(firstsql, "GRANT CONNECT ON %s %s TO PUBLIC;\n", + type, name); + } + /* Scan individual ACL items */ for (i = 0; i < naclitems; i++) {