summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_archiver.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-05-28 22:26:57 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-05-28 22:26:57 +0000
commit36a1e732a6b8dcaae06235601797c90a0cc4481c (patch)
tree1e25b708ff9a2d72e4b44b7a90091dc3cfe21f21 /src/bin/pg_dump/pg_backup_archiver.c
parent5a8ab29adf36afd7bcd61cd57f9e3ba4336e7947 (diff)
Rework pg_dump namespace search criteria so that dumping of user objects
having names conflicting with system objects will work --- the search path is now user-schema, pg_catalog rather than implicitly the other way around. Note this requires being careful to explicitly qualify references to system names whenever pg_catalog is not first in the search path. Also, add support for dumping ACLs of schemas.
Diffstat (limited to 'src/bin/pg_dump/pg_backup_archiver.c')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 272b98cecef..0236a54478f 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.46 2002/05/10 22:36:26 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.47 2002/05/28 22:26:56 tgl Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
@@ -2097,17 +2097,23 @@ _reconnectAsOwner(ArchiveHandle *AH, const char *dbname, TocEntry *te)
static void
_selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
{
+ PQExpBuffer qry;
+
if (!schemaName || *schemaName == '\0' ||
strcmp(AH->currSchema, schemaName) == 0)
return; /* no need to do anything */
+ qry = createPQExpBuffer();
+
+ appendPQExpBuffer(qry, "SET search_path = %s",
+ fmtId(schemaName, false));
+ if (strcmp(schemaName, "pg_catalog") != 0)
+ appendPQExpBuffer(qry, ", pg_catalog");
+
if (RestoringToDB(AH))
{
- PQExpBuffer qry = createPQExpBuffer();
PGresult *res;
- appendPQExpBuffer(qry, "SET search_path = %s;",
- fmtId(schemaName, false));
res = PQexec(AH->connection, qry->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
@@ -2115,15 +2121,15 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
schemaName, PQerrorMessage(AH->connection));
PQclear(res);
- destroyPQExpBuffer(qry);
}
else
- ahprintf(AH, "SET search_path = %s;\n\n",
- fmtId(schemaName, false));
+ ahprintf(AH, "%s;\n\n", qry->data);
if (AH->currSchema)
free(AH->currSchema);
AH->currSchema = strdup(schemaName);
+
+ destroyPQExpBuffer(qry);
}