aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-11-24 20:26:49 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-11-24 20:26:49 +0000
commit229d406a9bb557da5c497c5ffea9f9f327222e17 (patch)
treedf799e7ebd40dd6b079705199b7c90b06a3e5598 /src
parent03debe19a79e661820e23ed13f579684aee5ef02 (diff)
downloadpostgresql-229d406a9bb557da5c497c5ffea9f9f327222e17.tar.gz
postgresql-229d406a9bb557da5c497c5ffea9f9f327222e17.zip
Move resetting of currSchema to a spot where it's not vulnerable to getting
missed in possible future partial-drop scenarios. Improve comment. Per report from Zoltan Boszormenyi.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 32e172b133f..a6364074310 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.150 2007/11/24 17:45:32 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.151 2007/11/24 20:26:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -245,23 +245,24 @@ 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("");
- }
}
}
+
+ /*
+ * _selectOutputSchema may have set currSchema to reflect the effect
+ * of a "SET search_path" command it emitted. However, by now we may
+ * have dropped that schema; or it might not have existed in the first
+ * place. In either case the effective value of search_path will not
+ * be what we think. Forcibly reset currSchema so that we will
+ * re-establish the search_path setting when needed (after creating
+ * the schema).
+ *
+ * If we treated users as pg_dump'able objects then we'd need to reset
+ * currUser here too.
+ */
+ if (AH->currSchema)
+ free(AH->currSchema);
+ AH->currSchema = strdup("");
}
/*