mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Issue 'SET check_function_bodies = false' to suppress possible restore
failures in SQL functions, due to forward references or unqualified references to objects in other schemas. Per recent discussion.
This commit is contained in:
parent
15c194c1d5
commit
ef88199f61
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.77 2003/09/23 23:31:52 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.78 2003/10/03 20:10:59 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1708,6 +1708,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
|
||||
AH->currUser = strdup(""); /* So it's valid, but we can free() it
|
||||
* later if necessary */
|
||||
AH->currSchema = strdup(""); /* ditto */
|
||||
AH->chk_fn_bodies = true; /* assumed default state */
|
||||
|
||||
AH->toc = (TocEntry *) calloc(1, sizeof(TocEntry));
|
||||
if (!AH->toc)
|
||||
@ -2103,6 +2104,8 @@ _reconnectToDB(ArchiveHandle *AH, const char *dbname, const char *user)
|
||||
if (AH->currSchema)
|
||||
free(AH->currSchema);
|
||||
AH->currSchema = strdup("");
|
||||
|
||||
AH->chk_fn_bodies = true; /* assumed default state */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2198,6 +2201,13 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
|
||||
_becomeOwner(AH, te);
|
||||
_selectOutputSchema(AH, te->namespace);
|
||||
|
||||
/* If it's a function, make sure function checking is disabled */
|
||||
if (AH->chk_fn_bodies && strcmp(te->desc, "FUNCTION") == 0)
|
||||
{
|
||||
ahprintf(AH, "SET check_function_bodies = false;\n\n");
|
||||
AH->chk_fn_bodies = false;
|
||||
}
|
||||
|
||||
if (isData)
|
||||
pfx = "Data for ";
|
||||
else
|
||||
|
@ -17,7 +17,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.51 2003/08/04 00:43:27 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.52 2003/10/03 20:10:59 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -231,14 +231,18 @@ typedef struct _archiveHandle
|
||||
struct _tocEntry *toc; /* List of TOC entries */
|
||||
int tocCount; /* Number of TOC entries */
|
||||
struct _tocEntry *currToc; /* Used when dumping data */
|
||||
char *currUser; /* Restore: current username in script */
|
||||
char *currSchema; /* Restore: current schema in script */
|
||||
int compression; /* Compression requested on open */
|
||||
ArchiveMode mode; /* File mode - r or w */
|
||||
void *formatData; /* Header data specific to file format */
|
||||
|
||||
RestoreOptions *ropt; /* Used to check restore options in
|
||||
* ahwrite etc */
|
||||
|
||||
/* these vars track state to avoid sending redundant SET commands */
|
||||
char *currUser; /* current username */
|
||||
char *currSchema; /* current schema */
|
||||
bool chk_fn_bodies; /* current state of check_function_bodies */
|
||||
|
||||
void *lo_buf;
|
||||
size_t lo_buf_used;
|
||||
size_t lo_buf_size;
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Implements the basic DB functions used by the archiver.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.49 2003/07/23 08:47:30 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.50 2003/10/03 20:10:59 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -116,11 +116,6 @@ ReconnectToServer(ArchiveHandle *AH, const char *dbname, const char *username)
|
||||
PQfinish(AH->connection);
|
||||
AH->connection = newConn;
|
||||
|
||||
/* don't assume we still know the output schema */
|
||||
if (AH->currSchema)
|
||||
free(AH->currSchema);
|
||||
AH->currSchema = strdup("");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user