Commit 36a1e732 authored by Tom Lane's avatar Tom Lane

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.
parent 5a8ab29a
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * 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 * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -2097,17 +2097,23 @@ _reconnectAsOwner(ArchiveHandle *AH, const char *dbname, TocEntry *te) ...@@ -2097,17 +2097,23 @@ _reconnectAsOwner(ArchiveHandle *AH, const char *dbname, TocEntry *te)
static void static void
_selectOutputSchema(ArchiveHandle *AH, const char *schemaName) _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
{ {
PQExpBuffer qry;
if (!schemaName || *schemaName == '\0' || if (!schemaName || *schemaName == '\0' ||
strcmp(AH->currSchema, schemaName) == 0) strcmp(AH->currSchema, schemaName) == 0)
return; /* no need to do anything */ 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)) if (RestoringToDB(AH))
{ {
PQExpBuffer qry = createPQExpBuffer();
PGresult *res; PGresult *res;
appendPQExpBuffer(qry, "SET search_path = %s;",
fmtId(schemaName, false));
res = PQexec(AH->connection, qry->data); res = PQexec(AH->connection, qry->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
...@@ -2115,15 +2121,15 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName) ...@@ -2115,15 +2121,15 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
schemaName, PQerrorMessage(AH->connection)); schemaName, PQerrorMessage(AH->connection));
PQclear(res); PQclear(res);
destroyPQExpBuffer(qry);
} }
else else
ahprintf(AH, "SET search_path = %s;\n\n", ahprintf(AH, "%s;\n\n", qry->data);
fmtId(schemaName, false));
if (AH->currSchema) if (AH->currSchema)
free(AH->currSchema); free(AH->currSchema);
AH->currSchema = strdup(schemaName); AH->currSchema = strdup(schemaName);
destroyPQExpBuffer(qry);
} }
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_dump.h,v 1.86 2002/05/19 10:08:25 petere Exp $ * $Id: pg_dump.h,v 1.87 2002/05/28 22:26:57 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -70,10 +70,11 @@ typedef struct _aggInfo ...@@ -70,10 +70,11 @@ typedef struct _aggInfo
{ {
char *oid; char *oid;
char *aggname; char *aggname;
char *aggbasetype; char *aggbasetype; /* OID */
NamespaceInfo *aggnamespace; /* link to containing namespace */ NamespaceInfo *aggnamespace; /* link to containing namespace */
char *usename; char *usename;
char *aggacl; char *aggacl;
char *fmtbasetype; /* formatted type name */
} AggInfo; } AggInfo;
typedef struct _oprInfo typedef struct _oprInfo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment