Skip to content

Commit 2ee56b6

Browse files
committed
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.
1 parent 7c8927b commit 2ee56b6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/bin/pg_dump/dumputils.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.33 2006/10/09 23:30:33 tgl Exp $
11+
* $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.34 2007/01/04 17:49:37 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -438,6 +438,20 @@ buildACLCommands(const char *name, const char *type,
438438
appendPQExpBuffer(firstsql, "REVOKE ALL ON %s %s FROM PUBLIC;\n",
439439
type, name);
440440

441+
/*
442+
* We still need some hacking though to cover the case where new default
443+
* public privileges are added in new versions: the REVOKE ALL will revoke
444+
* them, leading to behavior different from what the old version had,
445+
* which is generally not what's wanted. So add back default privs if
446+
* the source database is too old to have had that particular priv.
447+
*/
448+
if (remoteVersion < 80200 && strcmp(type, "DATABASE") == 0)
449+
{
450+
/* database CONNECT priv didn't exist before 8.2 */
451+
appendPQExpBuffer(firstsql, "GRANT CONNECT ON %s %s TO PUBLIC;\n",
452+
type, name);
453+
}
454+
441455
/* Scan individual ACL items */
442456
for (i = 0; i < naclitems; i++)
443457
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy