Skip to content

Commit 7ebbc81

Browse files
committed
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.
1 parent 8a52d0c commit 7ebbc81

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.149 2007/11/15 21:14:41 momjian Exp $
18+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.150 2007/11/24 17:45:32 momjian Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -245,6 +245,21 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
245245
_selectOutputSchema(AH, te->namespace);
246246
/* Drop it */
247247
ahprintf(AH, "%s", te->dropStmt);
248+
if (strcmp(te->desc, "SCHEMA") == 0)
249+
{
250+
/*
251+
* If we dropped a schema, we know we are going to be
252+
* creating one later so don't remember the current one
253+
* so we try later. The previous 'search_path' setting
254+
* might have failed because the schema didn't exist
255+
* (and now it certainly doesn't exist), so force
256+
* search_path to be set as part of the next operation
257+
* and it might succeed.
258+
*/
259+
if (AH->currSchema)
260+
free(AH->currSchema);
261+
AH->currSchema = strdup("");
262+
}
248263
}
249264
}
250265
}

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