Thread: Fix for dumoing WITH/WITHOUT oids

Fix for dumoing WITH/WITHOUT oids

From
Bruce Momjian
Date:
The attached patch prevents WITH/WITHOUT OIDS from appearing in pg_dump
output.  Instead, it uses "SET default_with_oids" to control oid
creation, but only outputs it when the table characteristics change, not
for every table.

The patch basically add a withOids field to the table of contents
(TocEntry).  TocEntries are part of our binary dumps.  I updated the
pg_dump version number.  The code conditinally reads the TocEntry and
reads this field if the version is as new as the new 1.9 version.

The patch adds a new ArchiveHandle.currWithOids to track the current
backend default_with_oids setting.  This boolean variable is set to -1
on new connection so it will trigger a SET when first used.

The majority of the patch is adding withOids to all the ArchiveEntry
calls, even though it is only used for the TABLE tag.

I have tested this patch in both binary and ASCII outputs.  Binary gets
the OID setting from the TocEntry, while ASCII keeps track of the OID
setting.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/bin/pg_dump/pg_backup.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_backup.h,v
retrieving revision 1.28
diff -c -c -r1.28 pg_backup.h
*** src/bin/pg_dump/pg_backup.h    6 Dec 2003 03:00:11 -0000    1.28
--- src/bin/pg_dump/pg_backup.h    23 Mar 2004 20:00:36 -0000
***************
*** 130,136 ****
  extern void ArchiveEntry(Archive *AHX,
               CatalogId catalogId, DumpId dumpId,
               const char *tag,
!              const char *namespace, const char *owner,
               const char *desc, const char *defn,
               const char *dropStmt, const char *copyStmt,
               const DumpId *deps, int nDeps,
--- 130,136 ----
  extern void ArchiveEntry(Archive *AHX,
               CatalogId catalogId, DumpId dumpId,
               const char *tag,
!              const char *namespace, const char *owner, bool withOids,
               const char *desc, const char *defn,
               const char *dropStmt, const char *copyStmt,
               const DumpId *deps, int nDeps,
Index: src/bin/pg_dump/pg_backup_archiver.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_backup_archiver.c,v
retrieving revision 1.84
diff -c -c -r1.84 pg_backup_archiver.c
*** src/bin/pg_dump/pg_backup_archiver.c    3 Mar 2004 21:28:54 -0000    1.84
--- src/bin/pg_dump/pg_backup_archiver.c    23 Mar 2004 20:00:38 -0000
***************
*** 53,58 ****
--- 53,59 ----
                               RestoreOptions *ropt);
  static void _doSetFixedOutputState(ArchiveHandle *AH);
  static void _doSetSessionAuth(ArchiveHandle *AH, const char *user);
+ static void _doSetWithOids(ArchiveHandle *AH, const bool withOids);
  static void _reconnectToDB(ArchiveHandle *AH, const char *dbname, const char *user);
  static void _becomeUser(ArchiveHandle *AH, const char *user);
  static void _becomeOwner(ArchiveHandle *AH, TocEntry *te);
***************
*** 254,259 ****
--- 255,261 ----
          if ((reqs & REQ_SCHEMA) != 0)    /* We want the schema */
          {
              ahlog(AH, 1, "creating %s %s\n", te->desc, te->tag);
+
              _printTocEntry(AH, te, ropt, false);
              defnDumped = true;

***************
*** 559,565 ****
  ArchiveEntry(Archive *AHX,
               CatalogId catalogId, DumpId dumpId,
               const char *tag,
!              const char *namespace, const char *owner,
               const char *desc, const char *defn,
               const char *dropStmt, const char *copyStmt,
               const DumpId *deps, int nDeps,
--- 561,567 ----
  ArchiveEntry(Archive *AHX,
               CatalogId catalogId, DumpId dumpId,
               const char *tag,
!              const char *namespace, const char *owner, bool withOids,
               const char *desc, const char *defn,
               const char *dropStmt, const char *copyStmt,
               const DumpId *deps, int nDeps,
***************
*** 587,592 ****
--- 589,595 ----
      newToc->tag = strdup(tag);
      newToc->namespace = namespace ? strdup(namespace) : NULL;
      newToc->owner = strdup(owner);
+     newToc->withOids = withOids;
      newToc->desc = strdup(desc);
      newToc->defn = strdup(defn);
      newToc->dropStmt = strdup(dropStmt);
***************
*** 1597,1603 ****
      AH->currUser = strdup("");    /* So it's valid, but we can free() it
                                   * later if necessary */
      AH->currSchema = strdup("");    /* ditto */
!
      AH->toc = (TocEntry *) calloc(1, sizeof(TocEntry));
      if (!AH->toc)
          die_horribly(AH, modulename, "out of memory\n");
--- 1600,1607 ----
      AH->currUser = strdup("");    /* So it's valid, but we can free() it
                                   * later if necessary */
      AH->currSchema = strdup("");    /* ditto */
!     AH->currWithOids = -1;        /* force SET */
!
      AH->toc = (TocEntry *) calloc(1, sizeof(TocEntry));
      if (!AH->toc)
          die_horribly(AH, modulename, "out of memory\n");
***************
*** 1727,1732 ****
--- 1731,1737 ----
          WriteStr(AH, te->copyStmt);
          WriteStr(AH, te->namespace);
          WriteStr(AH, te->owner);
+         WriteStr(AH, te->withOids ? "true" : "false");

          /* Dump list of dependencies */
          for (i = 0; i < te->nDeps; i++)
***************
*** 1795,1801 ****
              te->namespace = ReadStr(AH);

          te->owner = ReadStr(AH);
!
          /* Read TOC entry dependencies */
          if (AH->version >= K_VERS_1_5)
          {
--- 1800,1815 ----
              te->namespace = ReadStr(AH);

          te->owner = ReadStr(AH);
!         if (AH->version >= K_VERS_1_9)
!         {
!             if (strcmp(ReadStr(AH), "true") == 0)
!                 te->withOids = true;
!             else
!                 te->withOids = false;
!         }
!         else
!             te->withOids = true;
!
          /* Read TOC entry dependencies */
          if (AH->version >= K_VERS_1_5)
          {
***************
*** 2010,2015 ****
--- 2024,2060 ----


  /*
+  * Issue a SET default_with_oids command.  Caller is responsible
+  * for updating state if appropriate.
+  */
+ static void
+ _doSetWithOids(ArchiveHandle *AH, const bool withOids)
+ {
+     PQExpBuffer cmd = createPQExpBuffer();
+
+     appendPQExpBuffer(cmd, "SET default_with_oids = %s;", withOids ?
+             "true" : "false");
+
+     if (RestoringToDB(AH))
+     {
+         PGresult   *res;
+
+         res = PQexec(AH->connection, cmd->data);
+
+         if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
+             die_horribly(AH, modulename, "could not set default_with_oids: %s",
+                          PQerrorMessage(AH->connection));
+
+         PQclear(res);
+     }
+     else
+         ahprintf(AH, "%s\n\n", cmd->data);
+
+     destroyPQExpBuffer(cmd);
+ }
+
+
+ /*
   * Issue the commands to connect to the specified database
   * as the specified user.
   *
***************
*** 2049,2055 ****
      if (AH->currSchema)
          free(AH->currSchema);
      AH->currSchema = strdup("");
!
      /* re-establish fixed state */
      _doSetFixedOutputState(AH);
  }
--- 2094,2101 ----
      if (AH->currSchema)
          free(AH->currSchema);
      AH->currSchema = strdup("");
!     AH->currWithOids = -1;
!
      /* re-establish fixed state */
      _doSetFixedOutputState(AH);
  }
***************
*** 2095,2100 ****
--- 2141,2161 ----


  /*
+  * Become the owner of the the given TOC entry object.  If
+  * changes in ownership are not allowed, this doesn't do anything.
+  */
+ static void
+ _setWithOids(ArchiveHandle *AH, TocEntry *te)
+ {
+     if (AH->currWithOids != te->withOids)
+     {
+         _doSetWithOids(AH, te->withOids);
+         AH->currWithOids = te->withOids;
+     }
+ }
+
+
+ /*
   * Issue the commands to select the specified schema as the current schema
   * in the target database.
   */
***************
*** 2146,2151 ****
--- 2207,2214 ----
      /* Select owner and schema as necessary */
      _becomeOwner(AH, te);
      _selectOutputSchema(AH, te->namespace);
+     if (strcmp(te->desc, "TABLE") == 0)
+         _setWithOids(AH, te);

      if (isData)
          pfx = "Data for ";
Index: src/bin/pg_dump/pg_backup_archiver.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_backup_archiver.h,v
retrieving revision 1.56
diff -c -c -r1.56 pg_backup_archiver.h
*** src/bin/pg_dump/pg_backup_archiver.h    24 Feb 2004 03:35:19 -0000    1.56
--- src/bin/pg_dump/pg_backup_archiver.h    23 Mar 2004 20:00:39 -0000
***************
*** 62,68 ****
  #endif

  #define K_VERS_MAJOR 1
! #define K_VERS_MINOR 8
  #define K_VERS_REV 0

  /* Data block types */
--- 62,68 ----
  #endif

  #define K_VERS_MAJOR 1
! #define K_VERS_MINOR 9
  #define K_VERS_REV 0

  /* Data block types */
***************
*** 80,87 ****
  #define K_VERS_1_7 (( (1 * 256 + 7) * 256 + 0) * 256 + 0)        /* File Offset size in
                                                                   * header */
  #define K_VERS_1_8 (( (1 * 256 + 8) * 256 + 0) * 256 + 0)        /* change interpretation of ID numbers and
dependencies*/ 

! #define K_VERS_MAX (( (1 * 256 + 8) * 256 + 255) * 256 + 0)

  /* No of BLOBs to restore in 1 TX */
  #define BLOB_BATCH_SIZE 100
--- 80,88 ----
  #define K_VERS_1_7 (( (1 * 256 + 7) * 256 + 0) * 256 + 0)        /* File Offset size in
                                                                   * header */
  #define K_VERS_1_8 (( (1 * 256 + 8) * 256 + 0) * 256 + 0)        /* change interpretation of ID numbers and
dependencies*/ 
+ #define K_VERS_1_9 (( (1 * 256 + 9) * 256 + 0) * 256 + 0)        /* add default_with_oids tracking */

! #define K_VERS_MAX (( (1 * 256 + 9) * 256 + 255) * 256 + 0)

  /* No of BLOBs to restore in 1 TX */
  #define BLOB_BATCH_SIZE 100
***************
*** 245,251 ****
      /* these vars track state to avoid sending redundant SET commands */
      char       *currUser;        /* current username */
      char       *currSchema;        /* current schema */
!
      void       *lo_buf;
      size_t        lo_buf_used;
      size_t        lo_buf_size;
--- 246,253 ----
      /* these vars track state to avoid sending redundant SET commands */
      char       *currUser;        /* current username */
      char       *currSchema;        /* current schema */
!     bool        currWithOids;    /* current default_with_oids setting */
!
      void       *lo_buf;
      size_t        lo_buf_used;
      size_t        lo_buf_size;
***************
*** 262,267 ****
--- 264,270 ----
      char       *tag;            /* index tag */
      char       *namespace;        /* null or empty string if not in a schema */
      char       *owner;
+     bool        withOids;        /* Used only by "TABLE" tags */
      char       *desc;
      char       *defn;
      char       *dropStmt;
Index: src/bin/pg_dump/pg_dump.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.368
diff -c -c -r1.368 pg_dump.c
*** src/bin/pg_dump/pg_dump.c    20 Mar 2004 20:09:45 -0000    1.368
--- src/bin/pg_dump/pg_dump.c    23 Mar 2004 20:00:45 -0000
***************
*** 1086,1092 ****
      ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId,
                   tbinfo->dobj.name,
                   tbinfo->dobj.namespace->dobj.name,
!                  tbinfo->usename,
                   "TABLE DATA", "", "", copyStmt,
                   tdinfo->dobj.dependencies, tdinfo->dobj.nDeps,
                   dumpFn, tdinfo);
--- 1086,1092 ----
      ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId,
                   tbinfo->dobj.name,
                   tbinfo->dobj.namespace->dobj.name,
!                  tbinfo->usename, false,
                   "TABLE DATA", "", "", copyStmt,
                   tdinfo->dobj.dependencies, tdinfo->dobj.nDeps,
                   dumpFn, tdinfo);
***************
*** 1255,1260 ****
--- 1255,1261 ----
                   datname,        /* Name */
                   NULL,            /* Namespace */
                   dba,            /* Owner */
+                  false,            /* with oids */
                   "DATABASE",    /* Desc */
                   creaQry->data, /* Create */
                   delQry->data,    /* Del */
***************
*** 1310,1316 ****

      ArchiveEntry(AH, nilCatalogId, createDumpId(),
                   "ENCODING", NULL, "",
!                  "ENCODING", qry->data, "", NULL,
                   NULL, 0,
                   NULL, NULL);

--- 1311,1317 ----

      ArchiveEntry(AH, nilCatalogId, createDumpId(),
                   "ENCODING", NULL, "",
!                  false, "ENCODING", qry->data, "", NULL,
                   NULL, 0,
                   NULL, NULL);

***************
*** 3922,3928 ****
          appendPQExpBuffer(query, ";\n");

          ArchiveEntry(fout, nilCatalogId, createDumpId(),
!                      target, namespace, owner,
                       "COMMENT", query->data, "", NULL,
                       &(dumpId), 1,
                       NULL, NULL);
--- 3923,3929 ----
          appendPQExpBuffer(query, ";\n");

          ArchiveEntry(fout, nilCatalogId, createDumpId(),
!                      target, namespace, owner, false,
                       "COMMENT", query->data, "", NULL,
                       &(dumpId), 1,
                       NULL, NULL);
***************
*** 3982,3988 ****
              ArchiveEntry(fout, nilCatalogId, createDumpId(),
                           target->data,
                           tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                          "COMMENT", query->data, "", NULL,
                           &(tbinfo->dobj.dumpId), 1,
                           NULL, NULL);
          }
--- 3983,3989 ----
              ArchiveEntry(fout, nilCatalogId, createDumpId(),
                           target->data,
                           tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                          false, "COMMENT", query->data, "", NULL,
                           &(tbinfo->dobj.dumpId), 1,
                           NULL, NULL);
          }
***************
*** 4002,4008 ****
              ArchiveEntry(fout, nilCatalogId, createDumpId(),
                           target->data,
                           tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                          "COMMENT", query->data, "", NULL,
                           &(tbinfo->dobj.dumpId), 1,
                           NULL, NULL);
          }
--- 4003,4009 ----
              ArchiveEntry(fout, nilCatalogId, createDumpId(),
                           target->data,
                           tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                          false, "COMMENT", query->data, "", NULL,
                           &(tbinfo->dobj.dumpId), 1,
                           NULL, NULL);
          }
***************
*** 4251,4257 ****
          case DO_BLOBS:
              ArchiveEntry(fout, dobj->catId, dobj->dumpId,
                           dobj->name, NULL, "",
!                          "BLOBS", "", "", NULL,
                           NULL, 0,
                           dumpBlobs, NULL);
              break;
--- 4252,4258 ----
          case DO_BLOBS:
              ArchiveEntry(fout, dobj->catId, dobj->dumpId,
                           dobj->name, NULL, "",
!                          false, "BLOBS", "", "", NULL,
                           NULL, 0,
                           dumpBlobs, NULL);
              break;
***************
*** 4305,4311 ****
          ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
                       nspinfo->dobj.name,
                       NULL, "",
!                      "SCHEMA", q->data, delq->data, NULL,
                       nspinfo->dobj.dependencies, nspinfo->dobj.nDeps,
                       NULL, NULL);
      }
--- 4306,4312 ----
          ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
                       nspinfo->dobj.name,
                       NULL, "",
!                      false, "SCHEMA", q->data, delq->data, NULL,
                       nspinfo->dobj.dependencies, nspinfo->dobj.nDeps,
                       NULL, NULL);
      }
***************
*** 4596,4602 ****
      ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
                   tinfo->dobj.name,
                   tinfo->dobj.namespace->dobj.name,
!                  tinfo->usename,
                   "TYPE", q->data, delq->data, NULL,
                   tinfo->dobj.dependencies, tinfo->dobj.nDeps,
                   NULL, NULL);
--- 4597,4603 ----
      ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
                   tinfo->dobj.name,
                   tinfo->dobj.namespace->dobj.name,
!                  tinfo->usename, false,
                   "TYPE", q->data, delq->data, NULL,
                   tinfo->dobj.dependencies, tinfo->dobj.nDeps,
                   NULL, NULL);
***************
*** 4702,4708 ****
      ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
                   tinfo->dobj.name,
                   tinfo->dobj.namespace->dobj.name,
!                  tinfo->usename,
                   "DOMAIN", q->data, delq->data, NULL,
                   tinfo->dobj.dependencies, tinfo->dobj.nDeps,
                   NULL, NULL);
--- 4703,4709 ----
      ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
                   tinfo->dobj.name,
                   tinfo->dobj.namespace->dobj.name,
!                  tinfo->usename, false,
                   "DOMAIN", q->data, delq->data, NULL,
                   tinfo->dobj.dependencies, tinfo->dobj.nDeps,
                   NULL, NULL);
***************
*** 4795,4801 ****
      ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
                   tinfo->dobj.name,
                   tinfo->dobj.namespace->dobj.name,
!                  tinfo->usename,
                   "TYPE", q->data, delq->data, NULL,
                   tinfo->dobj.dependencies, tinfo->dobj.nDeps,
                   NULL, NULL);
--- 4796,4802 ----
      ArchiveEntry(fout, tinfo->dobj.catId, tinfo->dobj.dumpId,
                   tinfo->dobj.name,
                   tinfo->dobj.namespace->dobj.name,
!                  tinfo->usename, false,
                   "TYPE", q->data, delq->data, NULL,
                   tinfo->dobj.dependencies, tinfo->dobj.nDeps,
                   NULL, NULL);
***************
*** 4888,4894 ****
      ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,
                   plang->dobj.name,
                   funcInfo->dobj.namespace->dobj.name, "",
!                  "PROCEDURAL LANGUAGE",
                   defqry->data, delqry->data, NULL,
                   plang->dobj.dependencies, plang->dobj.nDeps,
                   NULL, NULL);
--- 4889,4895 ----
      ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,
                   plang->dobj.name,
                   funcInfo->dobj.namespace->dobj.name, "",
!                  false, "PROCEDURAL LANGUAGE",
                   defqry->data, delqry->data, NULL,
                   plang->dobj.dependencies, plang->dobj.nDeps,
                   NULL, NULL);
***************
*** 5149,5155 ****
      ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId,
                   funcsig_tag,
                   finfo->dobj.namespace->dobj.name,
!                  finfo->usename,
                   "FUNCTION", q->data, delqry->data, NULL,
                   finfo->dobj.dependencies, finfo->dobj.nDeps,
                   NULL, NULL);
--- 5150,5156 ----
      ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId,
                   funcsig_tag,
                   finfo->dobj.namespace->dobj.name,
!                  finfo->usename, false,
                   "FUNCTION", q->data, delqry->data, NULL,
                   finfo->dobj.dependencies, finfo->dobj.nDeps,
                   NULL, NULL);
***************
*** 5289,5295 ****
      ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
                   castsig->data,
                   "pg_catalog", "",
!                  "CAST", defqry->data, delqry->data, NULL,
                   cast->dobj.dependencies, cast->dobj.nDeps,
                   NULL, NULL);

--- 5290,5296 ----
      ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
                   castsig->data,
                   "pg_catalog", "",
!                  false, "CAST", defqry->data, delqry->data, NULL,
                   cast->dobj.dependencies, cast->dobj.nDeps,
                   NULL, NULL);

***************
*** 5542,5548 ****
      ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId,
                   oprinfo->dobj.name,
                   oprinfo->dobj.namespace->dobj.name, oprinfo->usename,
!                  "OPERATOR", q->data, delq->data, NULL,
                   oprinfo->dobj.dependencies, oprinfo->dobj.nDeps,
                   NULL, NULL);

--- 5543,5549 ----
      ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId,
                   oprinfo->dobj.name,
                   oprinfo->dobj.namespace->dobj.name, oprinfo->usename,
!                  false, "OPERATOR", q->data, delq->data, NULL,
                   oprinfo->dobj.dependencies, oprinfo->dobj.nDeps,
                   NULL, NULL);

***************
*** 5849,5855 ****
      ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
                   opcinfo->dobj.name,
                   opcinfo->dobj.namespace->dobj.name, opcinfo->usename,
!                  "OPERATOR CLASS", q->data, delq->data, NULL,
                   opcinfo->dobj.dependencies, opcinfo->dobj.nDeps,
                   NULL, NULL);

--- 5850,5856 ----
      ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
                   opcinfo->dobj.name,
                   opcinfo->dobj.namespace->dobj.name, opcinfo->usename,
!                  false, "OPERATOR CLASS", q->data, delq->data, NULL,
                   opcinfo->dobj.dependencies, opcinfo->dobj.nDeps,
                   NULL, NULL);

***************
*** 5959,5965 ****
      ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
                   convinfo->dobj.name,
                   convinfo->dobj.namespace->dobj.name, convinfo->usename,
!                  "CONVERSION", q->data, delq->data, NULL,
                   convinfo->dobj.dependencies, convinfo->dobj.nDeps,
                   NULL, NULL);

--- 5960,5966 ----
      ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
                   convinfo->dobj.name,
                   convinfo->dobj.namespace->dobj.name, convinfo->usename,
!                  false, "CONVERSION", q->data, delq->data, NULL,
                   convinfo->dobj.dependencies, convinfo->dobj.nDeps,
                   NULL, NULL);

***************
*** 6194,6200 ****
      ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
                   aggsig_tag,
                   agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
!                  "AGGREGATE", q->data, delq->data, NULL,
                   agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps,
                   NULL, NULL);

--- 6195,6201 ----
      ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
                   aggsig_tag,
                   agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.usename,
!                  false, "AGGREGATE", q->data, delq->data, NULL,
                   agginfo->aggfn.dobj.dependencies, agginfo->aggfn.dobj.nDeps,
                   NULL, NULL);

***************
*** 6273,6279 ****
          ArchiveEntry(fout, nilCatalogId, createDumpId(),
                       tag, nspname,
                       owner ? owner : "",
!                      "ACL", sql->data, "", NULL,
                       &(objDumpId), 1,
                       NULL, NULL);

--- 6274,6280 ----
          ArchiveEntry(fout, nilCatalogId, createDumpId(),
                       tag, nspname,
                       owner ? owner : "",
!                      false, "ACL", sql->data, "", NULL,
                       &(objDumpId), 1,
                       NULL, NULL);

***************
*** 6509,6516 ****
              appendPQExpBuffer(q, ")");
          }

-         appendPQExpBuffer(q, tbinfo->hasoids ? " WITH OIDS" : " WITHOUT OIDS");
-
          appendPQExpBuffer(q, ";\n");

          /* Loop dumping statistics and storage statements */
--- 6510,6515 ----
***************
*** 6577,6582 ****
--- 6576,6582 ----
      ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
                   tbinfo->dobj.name,
                   tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
+                  (strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false,
                   reltypename, q->data, delq->data, NULL,
                   tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
                   NULL, NULL);
***************
*** 6631,6637 ****
      ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId,
                   tbinfo->attnames[adnum - 1],
                   tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                  "DEFAULT", q->data, delq->data, NULL,
                   adinfo->dobj.dependencies, adinfo->dobj.nDeps,
                   NULL, NULL);

--- 6631,6637 ----
      ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId,
                   tbinfo->attnames[adnum - 1],
                   tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                  false, "DEFAULT", q->data, delq->data, NULL,
                   adinfo->dobj.dependencies, adinfo->dobj.nDeps,
                   NULL, NULL);

***************
*** 6721,6727 ****
          ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId,
                       indxinfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name,
!                      tbinfo->usename,
                       "INDEX", q->data, delq->data, NULL,
                       indxinfo->dobj.dependencies, indxinfo->dobj.nDeps,
                       NULL, NULL);
--- 6721,6727 ----
          ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId,
                       indxinfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name,
!                      tbinfo->usename, false,
                       "INDEX", q->data, delq->data, NULL,
                       indxinfo->dobj.dependencies, indxinfo->dobj.nDeps,
                       NULL, NULL);
***************
*** 6819,6825 ****
          ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
                       coninfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name,
!                      tbinfo->usename,
                       "CONSTRAINT", q->data, delq->data, NULL,
                       coninfo->dobj.dependencies, coninfo->dobj.nDeps,
                       NULL, NULL);
--- 6819,6825 ----
          ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
                       coninfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name,
!                      tbinfo->usename, false,
                       "CONSTRAINT", q->data, delq->data, NULL,
                       coninfo->dobj.dependencies, coninfo->dobj.nDeps,
                       NULL, NULL);
***************
*** 6850,6856 ****
          ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
                       coninfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name,
!                      tbinfo->usename,
                       "FK CONSTRAINT", q->data, delq->data, NULL,
                       coninfo->dobj.dependencies, coninfo->dobj.nDeps,
                       NULL, NULL);
--- 6850,6856 ----
          ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
                       coninfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name,
!                      tbinfo->usename, false,
                       "FK CONSTRAINT", q->data, delq->data, NULL,
                       coninfo->dobj.dependencies, coninfo->dobj.nDeps,
                       NULL, NULL);
***************
*** 6883,6889 ****
              ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
                           coninfo->dobj.name,
                           tbinfo->dobj.namespace->dobj.name,
!                          tbinfo->usename,
                           "CHECK CONSTRAINT", q->data, delq->data, NULL,
                           coninfo->dobj.dependencies, coninfo->dobj.nDeps,
                           NULL, NULL);
--- 6883,6889 ----
              ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
                           coninfo->dobj.name,
                           tbinfo->dobj.namespace->dobj.name,
!                          tbinfo->usename, false,
                           "CHECK CONSTRAINT", q->data, delq->data, NULL,
                           coninfo->dobj.dependencies, coninfo->dobj.nDeps,
                           NULL, NULL);
***************
*** 6917,6923 ****
              ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
                           coninfo->dobj.name,
                           tinfo->dobj.namespace->dobj.name,
!                          tinfo->usename,
                           "CHECK CONSTRAINT", q->data, delq->data, NULL,
                           coninfo->dobj.dependencies, coninfo->dobj.nDeps,
                           NULL, NULL);
--- 6917,6923 ----
              ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
                           coninfo->dobj.name,
                           tinfo->dobj.namespace->dobj.name,
!                          tinfo->usename, false,
                           "CHECK CONSTRAINT", q->data, delq->data, NULL,
                           coninfo->dobj.dependencies, coninfo->dobj.nDeps,
                           NULL, NULL);
***************
*** 6984,6990 ****

      ArchiveEntry(fout, nilCatalogId, createDumpId(),
                   "Max OID", NULL, "",
!                  "<Init>", sql, "", NULL,
                   NULL, 0,
                   NULL, NULL);
  }
--- 6984,6990 ----

      ArchiveEntry(fout, nilCatalogId, createDumpId(),
                   "Max OID", NULL, "",
!                  false, "<Init>", sql, "", NULL,
                   NULL, 0,
                   NULL, NULL);
  }
***************
*** 7181,7187 ****
          ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
                       tbinfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                      "SEQUENCE", query->data, delqry->data, NULL,
                       tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
                       NULL, NULL);
      }
--- 7181,7187 ----
          ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
                       tbinfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                      false, "SEQUENCE", query->data, delqry->data, NULL,
                       tbinfo->dobj.dependencies, tbinfo->dobj.nDeps,
                       NULL, NULL);
      }
***************
*** 7197,7203 ****
          ArchiveEntry(fout, nilCatalogId, createDumpId(),
                       tbinfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                      "SEQUENCE SET", query->data, "", NULL,
                       &(tbinfo->dobj.dumpId), 1,
                       NULL, NULL);
      }
--- 7197,7203 ----
          ArchiveEntry(fout, nilCatalogId, createDumpId(),
                       tbinfo->dobj.name,
                       tbinfo->dobj.namespace->dobj.name, tbinfo->usename,
!                      false, "SEQUENCE SET", query->data, "", NULL,
                       &(tbinfo->dobj.dumpId), 1,
                       NULL, NULL);
      }
***************
*** 7362,7368 ****
      ArchiveEntry(fout, tginfo->dobj.catId, tginfo->dobj.dumpId,
                   tginfo->dobj.name,
                   tbinfo->dobj.namespace->dobj.name,
!                  tbinfo->usename,
                   "TRIGGER", query->data, delqry->data, NULL,
                   tginfo->dobj.dependencies, tginfo->dobj.nDeps,
                   NULL, NULL);
--- 7362,7368 ----
      ArchiveEntry(fout, tginfo->dobj.catId, tginfo->dobj.dumpId,
                   tginfo->dobj.name,
                   tbinfo->dobj.namespace->dobj.name,
!                  tbinfo->usename, false,
                   "TRIGGER", query->data, delqry->data, NULL,
                   tginfo->dobj.dependencies, tginfo->dobj.nDeps,
                   NULL, NULL);
***************
*** 7456,7462 ****
      ArchiveEntry(fout, rinfo->dobj.catId, rinfo->dobj.dumpId,
                   rinfo->dobj.name,
                   tbinfo->dobj.namespace->dobj.name,
!                  tbinfo->usename,
                   "RULE", cmd->data, delcmd->data, NULL,
                   rinfo->dobj.dependencies, rinfo->dobj.nDeps,
                   NULL, NULL);
--- 7456,7462 ----
      ArchiveEntry(fout, rinfo->dobj.catId, rinfo->dobj.dumpId,
                   rinfo->dobj.name,
                   tbinfo->dobj.namespace->dobj.name,
!                  tbinfo->usename, false,
                   "RULE", cmd->data, delcmd->data, NULL,
                   rinfo->dobj.dependencies, rinfo->dobj.nDeps,
                   NULL, NULL);

Re: Fix for dumoing WITH/WITHOUT oids

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
>   /*
> +  * Become the owner of the the given TOC entry object.  If
> +  * changes in ownership are not allowed, this doesn't do anything.
> +  */
> + static void
> + _setWithOids(ArchiveHandle *AH, TocEntry *te)

Cutting and pasting our comments, are we?

            regards, tom lane

Re: Fix for dumoing WITH/WITHOUT oids

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> >   /*
> > +  * Become the owner of the the given TOC entry object.  If
> > +  * changes in ownership are not allowed, this doesn't do anything.
> > +  */
> > + static void
> > + _setWithOids(ArchiveHandle *AH, TocEntry *te)
>
> Cutting and pasting our comments, are we?

Thanks.  Fixed.  :-)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Fix for dumoing WITH/WITHOUT oids

From
Neil Conway
Date:
On 23-Mar-04, at 3:02 PM, Bruce Momjian wrote:
> The attached patch prevents WITH/WITHOUT OIDS from appearing in pg_dump
> output.  Instead, it uses "SET default_with_oids" to control oid
> creation, but only outputs it when the table characteristics change,
> not
> for every table.

Thank you for doing this, Bruce. My apologies for not getting it done
fast enough myself.

-Neil


Re: Fix for dumoing WITH/WITHOUT oids

From
Bruce Momjian
Date:
Neil Conway wrote:
> On 23-Mar-04, at 3:02 PM, Bruce Momjian wrote:
> > The attached patch prevents WITH/WITHOUT OIDS from appearing in pg_dump
> > output.  Instead, it uses "SET default_with_oids" to control oid
> > creation, but only outputs it when the table characteristics change,
> > not
> > for every table.
>
> Thank you for doing this, Bruce. My apologies for not getting it done
> fast enough myself.

No problem.  I think we are better leaving you the more complex stuff.  :-)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073