]> granicus.if.org Git - postgresql/commitdiff
Issue 'SET check_function_bodies = false' to suppress possible restore
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 3 Oct 2003 20:10:59 +0000 (20:10 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 3 Oct 2003 20:10:59 +0000 (20:10 +0000)
failures in SQL functions, due to forward references or unqualified
references to objects in other schemas.  Per recent discussion.

src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.h
src/bin/pg_dump/pg_backup_db.c

index a2181ce7724cff94a873b54b63b54d5ebea0a32f..7096df3b95692fd6522003b5215c5f7e0b6031df 100644 (file)
@@ -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
index f893a3ba7fd44cc9a8b03a73aa771c4c5a1bd008..fbfbba988e74e9a1688c662ffd67ff5b26555a07 100644 (file)
@@ -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;
index ae3d9cc14abe30bc4757667d07f40ee2ab77c2d7..cab9d7830ba9f6817ffcc4dfa70ba45f37d584aa 100644 (file)
@@ -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;
 }