Use just NULL not NULL::TEXT --- the latter coding is unnecessary and
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 7 Jun 2005 14:05:01 +0000 (14:05 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 7 Jun 2005 14:05:01 +0000 (14:05 +0000)
not schema-safe.  Per report from Jochem van Dieten.

src/bin/pg_dump/pg_dump.c

index 309f1bdf5791e4d7007c6accaa6813a6273c3346..696e7262bfdd19fdcc28ddb1c3206f7642dfdb26 100644 (file)
@@ -32,7 +32,6 @@
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
 #endif
-#include <time.h>
 
 #ifndef HAVE_STRDUP
 #include "strdup.h"
@@ -165,7 +164,6 @@ static char *myFormatType(const char *typname, int32 typmod);
 static const char *fmtQualifiedId(const char *schema, const char *id);
 static int     dumpBlobs(Archive *AH, void *arg);
 static void dumpDatabase(Archive *AH);
-static void dumpTimestamp(Archive *AH, char *msg);
 static void dumpEncoding(Archive *AH);
 static const char *getAttrName(int attrnum, TableInfo *tblInfo);
 static const char *fmtCopyColumnList(const TableInfo *ti);
@@ -602,9 +600,6 @@ main(int argc, char **argv)
         * safe order.
         */
 
-       if (g_fout->verbose)
-               dumpTimestamp(g_fout, "Started on");
-
        /* First the special encoding entry. */
        dumpEncoding(g_fout);
 
@@ -620,9 +615,6 @@ main(int argc, char **argv)
        for (i = 0; i < numObjs; i++)
                dumpDumpableObject(g_fout, dobjs[i]);
 
-       if (g_fout->verbose)
-               dumpTimestamp(g_fout, "Completed on");
-
        /*
         * And finally we can do the actual output.
         */
@@ -637,6 +629,7 @@ main(int argc, char **argv)
                ropt->noOwner = outputNoOwner;
                ropt->disable_triggers = disable_triggers;
                ropt->use_setsessauth = use_setsessauth;
+               ropt->dataOnly = dataOnly;
 
                if (compressLevel == -1)
                        ropt->compression = 0;
@@ -982,10 +975,10 @@ dumpTableData_insert(Archive *fout, void *dcontext)
                                {
                                        if (field > 0)
                                                appendPQExpBuffer(q, ", ");
-                                       appendPQExpBuffer(q, fmtId(PQfname(res, field)));
+                                       appendPQExpBufferStr(q, fmtId(PQfname(res, field)));
                                }
                                appendPQExpBuffer(q, ") ");
-                               archprintf(fout, "%s", q->data);
+                               archputs(q->data, fout);
                        }
                        archprintf(fout, "VALUES (");
                        for (field = 0; field < nfields; field++)
@@ -1047,7 +1040,7 @@ dumpTableData_insert(Archive *fout, void *dcontext)
                                                /* All other types are printed as string literals. */
                                                resetPQExpBuffer(q);
                                                appendStringLiteral(q, PQgetvalue(res, tuple, field), false);
-                                               archprintf(fout, "%s", q->data);
+                                               archputs(q->data, fout);
                                                break;
                                }
                        }
@@ -1299,35 +1292,6 @@ dumpDatabase(Archive *AH)
 }
 
 
-/*
- * dumpTimestamp
- */
-static void
-dumpTimestamp(Archive *AH, char *msg)
-{
-       char            buf[256];
-       time_t          now = time(NULL);
-
-       if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&now)) != 0)
-       {
-               PQExpBuffer qry = createPQExpBuffer();
-
-               appendPQExpBuffer(qry, "-- ");
-               appendPQExpBuffer(qry, msg);
-               appendPQExpBuffer(qry, " ");
-               appendPQExpBuffer(qry, buf);
-               appendPQExpBuffer(qry, "\n");
-
-               ArchiveEntry(AH, nilCatalogId, createDumpId(),
-                                        "DUMP TIMESTAMP", NULL, NULL, "",
-                                        false, "DUMP TIMESTAMP", qry->data, "", NULL,
-                                        NULL, 0,
-                                        NULL, NULL);
-               destroyPQExpBuffer(qry);
-       }
-}
-
-
 /*
  * dumpEncoding: put the correct encoding into the archive
  */
@@ -5151,7 +5115,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
        {
                appendPQExpBuffer(query,
                                                  "SELECT proretset, prosrc, probin, "
-                                                 "null::text as proargnames, "
+                                                 "null as proargnames, "
                                                  "provolatile, proisstrict, prosecdef, "
                                                  "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname "
                                                  "FROM pg_catalog.pg_proc "
@@ -5162,7 +5126,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
        {
                appendPQExpBuffer(query,
                                                  "SELECT proretset, prosrc, probin, "
-                                                 "null::text as proargnames, "
+                                                 "null as proargnames, "
                 "case when proiscachable then 'i' else 'v' end as provolatile, "
                                                  "proisstrict, "
                                                  "'f'::boolean as prosecdef, "
@@ -5175,7 +5139,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
        {
                appendPQExpBuffer(query,
                                                  "SELECT proretset, prosrc, probin, "
-                                                 "null::text as proargnames, "
+                                                 "null as proargnames, "
                 "case when proiscachable then 'i' else 'v' end as provolatile, "
                                                  "'f'::boolean as proisstrict, "
                                                  "'f'::boolean as prosecdef, "
@@ -6899,7 +6863,7 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
                ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId,
                                         indxinfo->dobj.name,
                                         tbinfo->dobj.namespace->dobj.name,
-                                        tbinfo->reltablespace,
+                                        indxinfo->tablespace,
                                         tbinfo->usename, false,
                                         "INDEX", q->data, delq->data, NULL,
                                         indxinfo->dobj.dependencies, indxinfo->dobj.nDeps,
@@ -7475,12 +7439,12 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
        if (tginfo->tgisconstraint)
        {
                appendPQExpBuffer(query, "CREATE CONSTRAINT TRIGGER ");
-               appendPQExpBuffer(query, fmtId(tginfo->tgconstrname));
+               appendPQExpBufferStr(query, fmtId(tginfo->tgconstrname));
        }
        else
        {
                appendPQExpBuffer(query, "CREATE TRIGGER ");
-               appendPQExpBuffer(query, fmtId(tginfo->dobj.name));
+               appendPQExpBufferStr(query, fmtId(tginfo->dobj.name));
        }
        appendPQExpBuffer(query, "\n    ");