Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitef88199

Browse files
committed
Issue 'SET check_function_bodies = false' to suppress possible restore
failures in SQL functions, due to forward references or unqualifiedreferences to objects in other schemas. Per recent discussion.
1 parent15c194c commitef88199

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.77 2003/09/23 23:31:52 tgl Exp $
18+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.78 2003/10/03 20:10:59 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1708,6 +1708,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
17081708
AH->currUser=strdup("");/* So it's valid, but we can free() it
17091709
* later if necessary */
17101710
AH->currSchema=strdup("");/* ditto */
1711+
AH->chk_fn_bodies= true;/* assumed default state */
17111712

17121713
AH->toc= (TocEntry*)calloc(1,sizeof(TocEntry));
17131714
if (!AH->toc)
@@ -2103,6 +2104,8 @@ _reconnectToDB(ArchiveHandle *AH, const char *dbname, const char *user)
21032104
if (AH->currSchema)
21042105
free(AH->currSchema);
21052106
AH->currSchema=strdup("");
2107+
2108+
AH->chk_fn_bodies= true;/* assumed default state */
21062109
}
21072110

21082111
/*
@@ -2198,6 +2201,13 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
21982201
_becomeOwner(AH,te);
21992202
_selectOutputSchema(AH,te->namespace);
22002203

2204+
/* If it's a function, make sure function checking is disabled */
2205+
if (AH->chk_fn_bodies&&strcmp(te->desc,"FUNCTION")==0)
2206+
{
2207+
ahprintf(AH,"SET check_function_bodies = false;\n\n");
2208+
AH->chk_fn_bodies= false;
2209+
}
2210+
22012211
if (isData)
22022212
pfx="Data for ";
22032213
else

‎src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*
1919
* IDENTIFICATION
20-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.51 2003/08/04 00:43:27 momjian Exp $
20+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.52 2003/10/03 20:10:59 tgl Exp $
2121
*
2222
*-------------------------------------------------------------------------
2323
*/
@@ -231,14 +231,18 @@ typedef struct _archiveHandle
231231
struct_tocEntry*toc;/* List of TOC entries */
232232
inttocCount;/* Number of TOC entries */
233233
struct_tocEntry*currToc;/* Used when dumping data */
234-
char*currUser;/* Restore: current username in script */
235-
char*currSchema;/* Restore: current schema in script */
236234
intcompression;/* Compression requested on open */
237235
ArchiveModemode;/* File mode - r or w */
238236
void*formatData;/* Header data specific to file format */
239237

240238
RestoreOptions*ropt;/* Used to check restore options in
241239
* ahwrite etc */
240+
241+
/* these vars track state to avoid sending redundant SET commands */
242+
char*currUser;/* current username */
243+
char*currSchema;/* current schema */
244+
boolchk_fn_bodies;/* current state of check_function_bodies */
245+
242246
void*lo_buf;
243247
size_tlo_buf_used;
244248
size_tlo_buf_size;

‎src/bin/pg_dump/pg_backup_db.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*Implements the basic DB functions used by the archiver.
66
*
77
* IDENTIFICATION
8-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.49 2003/07/23 08:47:30 petere Exp $
8+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.50 2003/10/03 20:10:59 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -116,11 +116,6 @@ ReconnectToServer(ArchiveHandle *AH, const char *dbname, const char *username)
116116
PQfinish(AH->connection);
117117
AH->connection=newConn;
118118

119-
/* don't assume we still know the output schema */
120-
if (AH->currSchema)
121-
free(AH->currSchema);
122-
AH->currSchema=strdup("");
123-
124119
return1;
125120
}
126121

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp