aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2007-11-24 17:45:32 +0000
committerBruce Momjian <bruce@momjian.us>2007-11-24 17:45:32 +0000
commit7ebbc815d994393c4315ef02fe66622e0089f972 (patch)
treef95265a3f6c18645ec81cd404e5ce75862c2087d
parent8a52d0c94d240cf386966fa8207a75a52fd82dfb (diff)
downloadpostgresql-7ebbc815d994393c4315ef02fe66622e0089f972.tar.gz
postgresql-7ebbc815d994393c4315ef02fe66622e0089f972.zip
If pg_dump drops a schema, make sure 'search_path' it SET the next time
it is needed --- basically don't remember the previous 'search_path' after a drop schema because it might have failed but be created later.
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 3f858a6b93d..32e172b133f 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.149 2007/11/15 21:14:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.150 2007/11/24 17:45:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -245,6 +245,21 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
_selectOutputSchema(AH, te->namespace);
/* Drop it */
ahprintf(AH, "%s", te->dropStmt);
+ if (strcmp(te->desc, "SCHEMA") == 0)
+ {
+ /*
+ * If we dropped a schema, we know we are going to be
+ * creating one later so don't remember the current one
+ * so we try later. The previous 'search_path' setting
+ * might have failed because the schema didn't exist
+ * (and now it certainly doesn't exist), so force
+ * search_path to be set as part of the next operation
+ * and it might succeed.
+ */
+ if (AH->currSchema)
+ free(AH->currSchema);
+ AH->currSchema = strdup("");
+ }
}
}
}