Applied patch to add start/stop times for pg_dump/pg_dumpall when
verbose output is used.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  [EMAIL PROTECTED]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/ref/pg_dump.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/ref/pg_dump.sgml,v
retrieving revision 1.70
diff -c -c -r1.70 pg_dump.sgml
*** doc/src/sgml/ref/pg_dump.sgml       31 May 2004 13:37:52 -0000      1.70
--- doc/src/sgml/ref/pg_dump.sgml       7 Jun 2004 16:27:05 -0000
***************
*** 403,409 ****
         <para>
        Specifies verbose mode.  This will cause
        <application>pg_dump</application> to output detailed object
!         comments in the dump file, and progress messages to standard error.
         </para>
        </listitem>
       </varlistentry>
--- 403,410 ----
         <para>
        Specifies verbose mode.  This will cause
        <application>pg_dump</application> to output detailed object
!         comments and start/stop times to the dump file, and progress 
!         messages to standard error.
         </para>
        </listitem>
       </varlistentry>
Index: doc/src/sgml/ref/pg_dumpall.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/ref/pg_dumpall.sgml,v
retrieving revision 1.43
diff -c -c -r1.43 pg_dumpall.sgml
*** doc/src/sgml/ref/pg_dumpall.sgml    29 Nov 2003 19:51:39 -0000      1.43
--- doc/src/sgml/ref/pg_dumpall.sgml    7 Jun 2004 16:27:05 -0000
***************
*** 192,199 ****
        <listitem>
         <para>
        Specifies verbose mode.  This will cause
!       <application>pg_dumpall</application> to print progress
!       messages to standard error.
         </para>
        </listitem>
       </varlistentry>
--- 192,200 ----
        <listitem>
         <para>
        Specifies verbose mode.  This will cause
!       <application>pg_dumpall</application> to output start/stop
!         times to the dump file, and progress messages to standard error.
!         It will also enable verbose output in <application>pg_dump</>.
         </para>
        </listitem>
       </varlistentry>
Index: src/bin/pg_dump/pg_dump.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.373
diff -c -c -r1.373 pg_dump.c
*** src/bin/pg_dump/pg_dump.c   3 Jun 2004 00:07:36 -0000       1.373
--- src/bin/pg_dump/pg_dump.c   7 Jun 2004 16:27:12 -0000
***************
*** 32,37 ****
--- 32,38 ----
  #ifdef HAVE_TERMIOS_H
  #include <termios.h>
  #endif
+ #include <time.h>
  
  #ifndef HAVE_STRDUP
  #include "strdup.h"
***************
*** 163,168 ****
--- 164,170 ----
  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);
***************
*** 598,603 ****
--- 600,608 ----
         * in a safe order.
         */
  
+       if (g_fout->verbose)
+               dumpTimestamp(g_fout, "Started on");
+ 
        /* First the special encoding entry. */
        dumpEncoding(g_fout);
  
***************
*** 615,620 ****
--- 620,628 ----
                dumpDumpableObject(g_fout, dobjs[i]);
        }
  
+       if (g_fout->verbose)
+               dumpTimestamp(g_fout, "Completed on");
+ 
        /*
         * And finally we can do the actual output.
         */
***************
*** 1280,1285 ****
--- 1288,1322 ----
        destroyPQExpBuffer(dbQry);
        destroyPQExpBuffer(delQry);
        destroyPQExpBuffer(creaQry);
+ }
+ 
+ 
+ /*
+  * 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, "",
+                                        false, "DUMP TIMESTAMP", qry->data, "", NULL,
+                                        NULL, 0,
+                                        NULL, NULL);
+               destroyPQExpBuffer(qry);
+       }
  }
  
  
Index: src/bin/pg_dump/pg_dumpall.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_dump/pg_dumpall.c,v
retrieving revision 1.37
diff -c -c -r1.37 pg_dumpall.c
*** src/bin/pg_dump/pg_dumpall.c        5 Jun 2004 04:27:48 -0000       1.37
--- src/bin/pg_dump/pg_dumpall.c        7 Jun 2004 16:27:13 -0000
***************
*** 50,55 ****
--- 50,56 ----
  static void dumpUserConfig(PGconn *conn, const char *username);
  static void makeAlterConfigCommand(const char *arrayitem, const char *type, const 
char *name);
  static void dumpDatabases(PGconn *conn);
+ static void dumpTimestamp(char *msg);
  
  static int    runPgDump(const char *dbname);
  static PGconn *connectDatabase(const char *dbname, const char *pghost, const char 
*pgport,
***************
*** 220,225 ****
--- 221,229 ----
        conn = connectDatabase("template1", pghost, pgport, pguser, force_password);
  
        printf("--\n-- PostgreSQL database cluster dump\n--\n\n");
+       if (verbose)
+                       dumpTimestamp("Started on");
+ 
        printf("\\connect \"template1\"\n\n");
  
        if (!data_only)
***************
*** 237,242 ****
--- 241,248 ----
  
        PQfinish(conn);
  
+       if (verbose)
+               dumpTimestamp("Completed on");
        printf("--\n-- PostgreSQL database cluster dump complete\n--\n\n");
  
        exit(0);
***************
*** 807,810 ****
--- 813,830 ----
        }
  
        return res;
+ }
+ 
+ 
+ /*
+  * dumpTimestamp
+  */
+ static void
+ dumpTimestamp(char *msg)
+ {
+       char buf[256];
+       time_t now = time(NULL);
+ 
+       if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&now)) != 0)
+               printf("-- %s %s\n\n", msg, buf);
  }
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to