]> granicus.if.org Git - postgresql/commitdiff
pg_basebackup: stylistic adjustments
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 31 Jul 2012 14:09:16 +0000 (10:09 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 31 Jul 2012 15:02:21 +0000 (11:02 -0400)
The most user-visible part of this is to change the long options
--statusint and --noloop to --status-interval and --no-loop,
respectively, per discussion.

Also, consistently enclose file names in double quotes, per our
conventions; and consistently use the term "transaction log file" to
talk about WAL segments.  (Someday we may need to go over this
terminology and make it consistent across the whole source code.)

Finally, reflow the code to better fit in 80 columns, and have pgindent
fix it up some more.

doc/src/sgml/ref/pg_basebackup.sgml
doc/src/sgml/ref/pg_receivexlog.sgml
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_basebackup/pg_receivexlog.c
src/bin/pg_basebackup/receivelog.c
src/bin/pg_basebackup/streamutil.c

index d22c0c5eb0ec0daf4592118dbccef1ef4baffd17..cec66559ce3bfe7260a86e807a8078704f6cf104 100644 (file)
@@ -346,7 +346,7 @@ PostgreSQL documentation
     <variablelist>
      <varlistentry>
       <term><option>-s <replaceable class="parameter">interval</replaceable></option></term>
-      <term><option>--statusint=<replaceable class="parameter">interval</replaceable></option></term>
+      <term><option>--status-interval=<replaceable class="parameter">interval</replaceable></option></term>
       <listitem>
        <para>
         Specifies the number of seconds between status packets sent back to the
index 63cff4788036c93a09482eb295456a326154d971..64cb81d2ef86e2d4ba5cbcc8b5909a93dd836637 100644 (file)
@@ -96,7 +96,7 @@ PostgreSQL documentation
     <variablelist>
      <varlistentry>
       <term><option>-n</option></term>
-      <term><option>--noloop</option></term>
+      <term><option>--no-loop</option></term>
       <listitem>
        <para>
         Don't loop on connection errors. Instead, exit right away with
@@ -124,7 +124,7 @@ PostgreSQL documentation
     <variablelist>
      <varlistentry>
       <term><option>-s <replaceable class="parameter">interval</replaceable></option></term>
-      <term><option>--statusint=<replaceable class="parameter">interval</replaceable></option></term>
+      <term><option>--status-interval=<replaceable class="parameter">interval</replaceable></option></term>
       <listitem>
        <para>
         Specifies the number of seconds between status packets sent back to the
index bc67a3cb4d4ae21151a6025567a37eba8f99d8c6..a7063a80e8eac66797b340ab1c0103cec57cda22 100644 (file)
@@ -79,7 +79,8 @@ static void ReceiveTarFile(PGconn *conn, PGresult *res, int rownum);
 static void ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum);
 static void BaseBackup(void);
 
-static bool reached_end_position(XLogRecPtr segendpos, uint32 timeline, bool segment_finished);
+static bool reached_end_position(XLogRecPtr segendpos, uint32 timeline,
+                                        bool segment_finished);
 
 #ifdef HAVE_LIBZ
 static const char *
@@ -96,7 +97,6 @@ get_gz_error(gzFile gzf)
 }
 #endif
 
-
 static void
 usage(void)
 {
@@ -105,28 +105,29 @@ usage(void)
        printf(_("Usage:\n"));
        printf(_("  %s [OPTION]...\n"), progname);
        printf(_("\nOptions controlling the output:\n"));
-       printf(_("  -D, --pgdata=DIRECTORY   receive base backup into directory\n"));
-       printf(_("  -F, --format=p|t         output format (plain (default), tar)\n"));
-       printf(_("  -x, --xlog               include required WAL files in backup (fetch mode)\n"));
+       printf(_("  -D, --pgdata=DIRECTORY receive base backup into directory\n"));
+       printf(_("  -F, --format=p|t       output format (plain (default), tar)\n"));
+       printf(_("  -x, --xlog             include required WAL files in backup (fetch mode)\n"));
        printf(_("  -X, --xlog-method=fetch|stream\n"
-                  "                           include required WAL files with specified method\n"));
-       printf(_("  -z, --gzip               compress tar output\n"));
-       printf(_("  -Z, --compress=0-9       compress tar output with given compression level\n"));
+                        "                         include required WAL files with specified method\n"));
+       printf(_("  -z, --gzip             compress tar output\n"));
+       printf(_("  -Z, --compress=0-9     compress tar output with given compression level\n"));
        printf(_("\nGeneral options:\n"));
        printf(_("  -c, --checkpoint=fast|spread\n"
-                  "                           set fast or spread checkpointing\n"));
-       printf(_("  -l, --label=LABEL        set backup label\n"));
-       printf(_("  -P, --progress           show progress information\n"));
-       printf(_("  -v, --verbose            output verbose messages\n"));
-       printf(_("  -V, --version            output version information, then exit\n"));
-       printf(_("  -?, --help               show this help, then exit\n"));
+                        "                         set fast or spread checkpointing\n"));
+       printf(_("  -l, --label=LABEL      set backup label\n"));
+       printf(_("  -P, --progress         show progress information\n"));
+       printf(_("  -v, --verbose          output verbose messages\n"));
+       printf(_("  -V, --version          output version information, then exit\n"));
+       printf(_("  -?, --help             show this help, then exit\n"));
        printf(_("\nConnection options:\n"));
-       printf(_("  -s, --statusint=INTERVAL time between status packets sent to server (in seconds)\n"));
-       printf(_("  -h, --host=HOSTNAME      database server host or socket directory\n"));
-       printf(_("  -p, --port=PORT          database server port number\n"));
-       printf(_("  -U, --username=NAME      connect as specified database user\n"));
-       printf(_("  -w, --no-password        never prompt for password\n"));
-       printf(_("  -W, --password           force password prompt (should happen automatically)\n"));
+       printf(_("  -s, --status-interval=INTERVAL\n"
+                        "                         time between status packets sent to server (in seconds)\n"));
+       printf(_("  -h, --host=HOSTNAME    database server host or socket directory\n"));
+       printf(_("  -p, --port=PORT        database server port number\n"));
+       printf(_("  -U, --username=NAME    connect as specified database user\n"));
+       printf(_("  -w, --no-password      never prompt for password\n"));
+       printf(_("  -W, --password         force password prompt (should happen automatically)\n"));
        printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
 }
 
@@ -140,7 +141,8 @@ usage(void)
  * time to stop.
  */
 static bool
-reached_end_position(XLogRecPtr segendpos, uint32 timeline, bool segment_finished)
+reached_end_position(XLogRecPtr segendpos, uint32 timeline,
+                                        bool segment_finished)
 {
        if (!has_xlogendptr)
        {
@@ -174,7 +176,8 @@ reached_end_position(XLogRecPtr segendpos, uint32 timeline, bool segment_finishe
 
                        if (sscanf(xlogend, "%X/%X", &xlogendptr.xlogid, &xlogendptr.xrecoff) != 2)
                        {
-                               fprintf(stderr, _("%s: could not parse xlog end position \"%s\"\n"),
+                               fprintf(stderr,
+                                 _("%s: could not parse transaction log location \"%s\"\n"),
                                                progname, xlogend);
                                exit(1);
                        }
@@ -233,7 +236,8 @@ LogStreamerMain(logstreamer_param *param)
 {
        if (!ReceiveXlogStream(param->bgconn, param->startptr, param->timeline,
                                                   param->sysidentifier, param->xlogdir,
-                                               reached_end_position, standby_message_timeout, true))
+                                                  reached_end_position, standby_message_timeout,
+                                                  true))
 
                /*
                 * Any errors will already have been reported in the function process,
@@ -263,7 +267,8 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier)
        /* Convert the starting position */
        if (sscanf(startpos, "%X/%X", &param->startptr.xlogid, &param->startptr.xrecoff) != 2)
        {
-               fprintf(stderr, _("%s: invalid format of xlog location: %s\n"),
+               fprintf(stderr,
+                               _("%s: could not parse transaction log location \"%s\"\n"),
                                progname, startpos);
                disconnect_and_exit(1);
        }
@@ -274,7 +279,8 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier)
        /* Create our background pipe */
        if (pipe(bgpipe) < 0)
        {
-               fprintf(stderr, _("%s: could not create pipe for background process: %s\n"),
+               fprintf(stderr,
+                               _("%s: could not create pipe for background process: %s\n"),
                                progname, strerror(errno));
                disconnect_and_exit(1);
        }
@@ -403,7 +409,8 @@ progress_report(int tablespacenum, const char *filename)
         * translatable strings.  And we only test for INT64_FORMAT availability
         * in snprintf, not fprintf.
         */
-       snprintf(totaldone_str, sizeof(totaldone_str), INT64_FORMAT, totaldone / 1024);
+       snprintf(totaldone_str, sizeof(totaldone_str), INT64_FORMAT,
+                        totaldone / 1024);
        snprintf(totalsize_str, sizeof(totalsize_str), INT64_FORMAT, totalsize);
 
        if (verbose)
@@ -418,20 +425,23 @@ progress_report(int tablespacenum, const char *filename)
                                        ngettext("%s/%s kB (100%%), %d/%d tablespace %35s",
                                                         "%s/%s kB (100%%), %d/%d tablespaces %35s",
                                                         tablespacecount),
-                       totaldone_str, totalsize_str, tablespacenum, tablespacecount, "");
+                                       totaldone_str, totalsize_str,
+                                       tablespacenum, tablespacecount, "");
                else
                        fprintf(stderr,
                                        ngettext("%s/%s kB (%d%%), %d/%d tablespace (%-30.30s)",
                                                         "%s/%s kB (%d%%), %d/%d tablespaces (%-30.30s)",
                                                         tablespacecount),
-                                       totaldone_str, totalsize_str, percent, tablespacenum, tablespacecount, filename);
+                                       totaldone_str, totalsize_str, percent,
+                                       tablespacenum, tablespacecount, filename);
        }
        else
                fprintf(stderr,
                                ngettext("%s/%s kB (%d%%), %d/%d tablespace",
                                                 "%s/%s kB (%d%%), %d/%d tablespaces",
                                                 tablespacecount),
-                               totaldone_str, totalsize_str, percent, tablespacenum, tablespacecount);
+                               totaldone_str, totalsize_str, percent,
+                               tablespacenum, tablespacecount);
 
        fprintf(stderr, "\r");
 }
@@ -459,7 +469,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
 #endif
 
        if (PQgetisnull(res, rownum, 0))
-
+       {
                /*
                 * Base tablespaces
                 */
@@ -469,9 +479,11 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
                        if (compresslevel != 0)
                        {
                                ztarfile = gzdopen(dup(fileno(stdout)), "wb");
-                               if (gzsetparams(ztarfile, compresslevel, Z_DEFAULT_STRATEGY) != Z_OK)
+                               if (gzsetparams(ztarfile, compresslevel,
+                                                               Z_DEFAULT_STRATEGY) != Z_OK)
                                {
-                                       fprintf(stderr, _("%s: could not set compression level %d: %s\n"),
+                                       fprintf(stderr,
+                                                       _("%s: could not set compression level %d: %s\n"),
                                                        progname, compresslevel, get_gz_error(ztarfile));
                                        disconnect_and_exit(1);
                                }
@@ -487,9 +499,11 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
                        {
                                snprintf(filename, sizeof(filename), "%s/base.tar.gz", basedir);
                                ztarfile = gzopen(filename, "wb");
-                               if (gzsetparams(ztarfile, compresslevel, Z_DEFAULT_STRATEGY) != Z_OK)
+                               if (gzsetparams(ztarfile, compresslevel,
+                                                               Z_DEFAULT_STRATEGY) != Z_OK)
                                {
-                                       fprintf(stderr, _("%s: could not set compression level %d: %s\n"),
+                                       fprintf(stderr,
+                                                       _("%s: could not set compression level %d: %s\n"),
                                                        progname, compresslevel, get_gz_error(ztarfile));
                                        disconnect_and_exit(1);
                                }
@@ -501,6 +515,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
                                tarfile = fopen(filename, "wb");
                        }
                }
+       }
        else
        {
                /*
@@ -509,11 +524,14 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
 #ifdef HAVE_LIBZ
                if (compresslevel != 0)
                {
-                       snprintf(filename, sizeof(filename), "%s/%s.tar.gz", basedir, PQgetvalue(res, rownum, 0));
+                       snprintf(filename, sizeof(filename), "%s/%s.tar.gz", basedir,
+                                        PQgetvalue(res, rownum, 0));
                        ztarfile = gzopen(filename, "wb");
-                       if (gzsetparams(ztarfile, compresslevel, Z_DEFAULT_STRATEGY) != Z_OK)
+                       if (gzsetparams(ztarfile, compresslevel,
+                                                       Z_DEFAULT_STRATEGY) != Z_OK)
                        {
-                               fprintf(stderr, _("%s: could not set compression level %d: %s\n"),
+                               fprintf(stderr,
+                                               _("%s: could not set compression level %d: %s\n"),
                                                progname, compresslevel, get_gz_error(ztarfile));
                                disconnect_and_exit(1);
                        }
@@ -521,7 +539,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
                else
 #endif
                {
-                       snprintf(filename, sizeof(filename), "%s/%s.tar", basedir, PQgetvalue(res, rownum, 0));
+                       snprintf(filename, sizeof(filename), "%s/%s.tar", basedir,
+                                        PQgetvalue(res, rownum, 0));
                        tarfile = fopen(filename, "wb");
                }
        }
@@ -532,7 +551,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
                if (!ztarfile)
                {
                        /* Compression is in use */
-                       fprintf(stderr, _("%s: could not create compressed file \"%s\": %s\n"),
+                       fprintf(stderr,
+                                       _("%s: could not create compressed file \"%s\": %s\n"),
                                        progname, filename, get_gz_error(ztarfile));
                        disconnect_and_exit(1);
                }
@@ -585,9 +605,11 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
 #ifdef HAVE_LIBZ
                        if (ztarfile != NULL)
                        {
-                               if (gzwrite(ztarfile, zerobuf, sizeof(zerobuf)) != sizeof(zerobuf))
+                               if (gzwrite(ztarfile, zerobuf, sizeof(zerobuf)) !=
+                                       sizeof(zerobuf))
                                {
-                                       fprintf(stderr, _("%s: could not write to compressed file \"%s\": %s\n"),
+                                       fprintf(stderr,
+                                       _("%s: could not write to compressed file \"%s\": %s\n"),
                                                        progname, filename, get_gz_error(ztarfile));
                                        disconnect_and_exit(1);
                                }
@@ -597,7 +619,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
                        {
                                if (fwrite(zerobuf, sizeof(zerobuf), 1, tarfile) != 1)
                                {
-                                       fprintf(stderr, _("%s: could not write to file \"%s\": %s\n"),
+                                       fprintf(stderr,
+                                                       _("%s: could not write to file \"%s\": %s\n"),
                                                        progname, filename, strerror(errno));
                                        disconnect_and_exit(1);
                                }
@@ -608,7 +631,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
                        {
                                if (gzclose(ztarfile) != 0)
                                {
-                                       fprintf(stderr, _("%s: could not close compressed file \"%s\": %s\n"),
+                                       fprintf(stderr,
+                                          _("%s: could not close compressed file \"%s\": %s\n"),
                                                        progname, filename, get_gz_error(ztarfile));
                                        disconnect_and_exit(1);
                                }
@@ -620,7 +644,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
                                {
                                        if (fclose(tarfile) != 0)
                                        {
-                                               fprintf(stderr, _("%s: could not close file \"%s\": %s\n"),
+                                               fprintf(stderr,
+                                                               _("%s: could not close file \"%s\": %s\n"),
                                                                progname, filename, strerror(errno));
                                                disconnect_and_exit(1);
                                        }
@@ -641,7 +666,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
                {
                        if (gzwrite(ztarfile, copybuf, r) != r)
                        {
-                               fprintf(stderr, _("%s: could not write to compressed file \"%s\": %s\n"),
+                               fprintf(stderr,
+                                       _("%s: could not write to compressed file \"%s\": %s\n"),
                                                progname, filename, get_gz_error(ztarfile));
                                disconnect_and_exit(1);
                        }
@@ -769,7 +795,8 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
                        /*
                         * First part of header is zero terminated filename
                         */
-                       snprintf(filename, sizeof(filename), "%s/%s", current_path, copybuf);
+                       snprintf(filename, sizeof(filename), "%s/%s", current_path,
+                                        copybuf);
                        if (filename[strlen(filename) - 1] == '/')
                        {
                                /*
@@ -798,7 +825,8 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
                                        }
 #ifndef WIN32
                                        if (chmod(filename, (mode_t) filemode))
-                                               fprintf(stderr, _("%s: could not set permissions on directory \"%s\": %s\n"),
+                                               fprintf(stderr,
+                                                               _("%s: could not set permissions on directory \"%s\": %s\n"),
                                                                progname, filename, strerror(errno));
 #endif
                                }
@@ -818,7 +846,8 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
                                }
                                else
                                {
-                                       fprintf(stderr, _("%s: unrecognized link indicator \"%c\"\n"),
+                                       fprintf(stderr,
+                                                       _("%s: unrecognized link indicator \"%c\"\n"),
                                                        progname, copybuf[156]);
                                        disconnect_and_exit(1);
                                }
@@ -896,7 +925,9 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
 
        if (file != NULL)
        {
-               fprintf(stderr, _("%s: COPY stream ended before last file was finished\n"), progname);
+               fprintf(stderr,
+                               _("%s: COPY stream ended before last file was finished\n"),
+                               progname);
                disconnect_and_exit(1);
        }
 
@@ -931,14 +962,15 @@ BaseBackup(void)
        res = PQexec(conn, "IDENTIFY_SYSTEM");
        if (PQresultStatus(res) != PGRES_TUPLES_OK)
        {
-               fprintf(stderr, _("%s: could not identify system: %s"),
-                               progname, PQerrorMessage(conn));
+               fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
+                               progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
                disconnect_and_exit(1);
        }
        if (PQntuples(res) != 1 || PQnfields(res) != 3)
        {
-               fprintf(stderr, _("%s: could not identify system, got %d rows and %d fields\n"),
-                               progname, PQntuples(res), PQnfields(res));
+               fprintf(stderr,
+                               _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d fields\n"),
+                               progname, PQntuples(res), PQnfields(res), 1, 3);
                disconnect_and_exit(1);
        }
        sysidentifier = strdup(PQgetvalue(res, 0, 0));
@@ -949,7 +981,8 @@ BaseBackup(void)
         * Start the actual backup
         */
        PQescapeStringConn(conn, escaped_label, label, sizeof(escaped_label), &i);
-       snprintf(current_path, sizeof(current_path), "BASE_BACKUP LABEL '%s' %s %s %s %s",
+       snprintf(current_path, sizeof(current_path),
+                        "BASE_BACKUP LABEL '%s' %s %s %s %s",
                         escaped_label,
                         showprogress ? "PROGRESS" : "",
                         includewal && !streamwal ? "WAL" : "",
@@ -958,8 +991,8 @@ BaseBackup(void)
 
        if (PQsendQuery(conn, current_path) == 0)
        {
-               fprintf(stderr, _("%s: could not send base backup command: %s"),
-                               progname, PQerrorMessage(conn));
+               fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
+                               progname, "BASE_BACKUP", PQerrorMessage(conn));
                disconnect_and_exit(1);
        }
 
@@ -981,7 +1014,7 @@ BaseBackup(void)
        }
        strcpy(xlogstart, PQgetvalue(res, 0, 0));
        if (verbose && includewal)
-               fprintf(stderr, "xlog start point: %s\n", xlogstart);
+               fprintf(stderr, "transaction log start point: %s\n", xlogstart);
        PQclear(res);
        MemSet(xlogend, 0, sizeof(xlogend));
 
@@ -1025,7 +1058,8 @@ BaseBackup(void)
         */
        if (format == 't' && strcmp(basedir, "-") == 0 && PQntuples(res) > 1)
        {
-               fprintf(stderr, _("%s: can only write single tablespace to stdout, database has %d\n"),
+               fprintf(stderr,
+                               _("%s: can only write single tablespace to stdout, database has %d\n"),
                                progname, PQntuples(res));
                disconnect_and_exit(1);
        }
@@ -1066,19 +1100,21 @@ BaseBackup(void)
        res = PQgetResult(conn);
        if (PQresultStatus(res) != PGRES_TUPLES_OK)
        {
-               fprintf(stderr, _("%s: could not get WAL end position from server: %s"),
+               fprintf(stderr,
+                _("%s: could not get transaction log end position from server: %s"),
                                progname, PQerrorMessage(conn));
                disconnect_and_exit(1);
        }
        if (PQntuples(res) != 1)
        {
-               fprintf(stderr, _("%s: no WAL end position returned from server\n"),
+               fprintf(stderr,
+                        _("%s: no transaction log end position returned from server\n"),
                                progname);
                disconnect_and_exit(1);
        }
        strcpy(xlogend, PQgetvalue(res, 0, 0));
        if (verbose && includewal)
-               fprintf(stderr, "xlog end point: %s\n", xlogend);
+               fprintf(stderr, "transaction log end point: %s\n", xlogend);
        PQclear(res);
 
        res = PQgetResult(conn);
@@ -1099,12 +1135,14 @@ BaseBackup(void)
 #endif
 
                if (verbose)
-                       fprintf(stderr, _("%s: waiting for background process to finish streaming...\n"), progname);
+                       fprintf(stderr,
+                                       _("%s: waiting for background process to finish streaming...\n"), progname);
 
 #ifndef WIN32
                if (write(bgpipe[1], xlogend, strlen(xlogend)) != strlen(xlogend))
                {
-                       fprintf(stderr, _("%s: could not send command to background pipe: %s\n"),
+                       fprintf(stderr,
+                                       _("%s: could not send command to background pipe: %s\n"),
                                        progname, strerror(errno));
                        disconnect_and_exit(1);
                }
@@ -1145,14 +1183,16 @@ BaseBackup(void)
                 */
                if (sscanf(xlogend, "%X/%X", &xlogendptr.xlogid, &xlogendptr.xrecoff) != 2)
                {
-                       fprintf(stderr, _("%s: could not parse xlog end position \"%s\"\n"),
+                       fprintf(stderr,
+                                 _("%s: could not parse transaction log location \"%s\"\n"),
                                        progname, xlogend);
                        disconnect_and_exit(1);
                }
                InterlockedIncrement(&has_xlogendptr);
 
                /* First wait for the thread to exit */
-               if (WaitForSingleObjectEx((HANDLE) bgchild, INFINITE, FALSE) != WAIT_OBJECT_0)
+               if (WaitForSingleObjectEx((HANDLE) bgchild, INFINITE, FALSE) !=
+                       WAIT_OBJECT_0)
                {
                        _dosmaperr(GetLastError());
                        fprintf(stderr, _("%s: could not wait for child thread: %s\n"),
@@ -1206,7 +1246,7 @@ main(int argc, char **argv)
                {"username", required_argument, NULL, 'U'},
                {"no-password", no_argument, NULL, 'w'},
                {"password", no_argument, NULL, 'W'},
-               {"statusint", required_argument, NULL, 's'},
+               {"status-interval", required_argument, NULL, 's'},
                {"verbose", no_argument, NULL, 'v'},
                {"progress", no_argument, NULL, 'P'},
                {NULL, 0, NULL, 0}
@@ -1248,7 +1288,8 @@ main(int argc, char **argv)
                                        format = 't';
                                else
                                {
-                                       fprintf(stderr, _("%s: invalid output format \"%s\", must be \"plain\" or \"tar\"\n"),
+                                       fprintf(stderr,
+                                                       _("%s: invalid output format \"%s\", must be \"plain\" or \"tar\"\n"),
                                                        progname, optarg);
                                        exit(1);
                                }
@@ -1256,7 +1297,8 @@ main(int argc, char **argv)
                        case 'x':
                                if (includewal)
                                {
-                                       fprintf(stderr, _("%s: cannot specify both --xlog and --xlog-method\n"),
+                                       fprintf(stderr,
+                                        _("%s: cannot specify both --xlog and --xlog-method\n"),
                                                        progname);
                                        exit(1);
                                }
@@ -1267,7 +1309,8 @@ main(int argc, char **argv)
                        case 'X':
                                if (includewal)
                                {
-                                       fprintf(stderr, _("%s: cannot specify both --xlog and --xlog-method\n"),
+                                       fprintf(stderr,
+                                        _("%s: cannot specify both --xlog and --xlog-method\n"),
                                                        progname);
                                        exit(1);
                                }
@@ -1281,7 +1324,8 @@ main(int argc, char **argv)
                                        streamwal = true;
                                else
                                {
-                                       fprintf(stderr, _("%s: invalid xlog-method option \"%s\", must be empty, \"fetch\", or \"stream\"\n"),
+                                       fprintf(stderr,
+                                                       _("%s: invalid xlog-method option \"%s\", must be empty, \"fetch\", or \"stream\"\n"),
                                                        progname, optarg);
                                        exit(1);
                                }
@@ -1423,7 +1467,6 @@ main(int argc, char **argv)
        if (format == 'p' || strcmp(basedir, "-") != 0)
                verify_dir_is_empty_or_create(basedir);
 
-
        BaseBackup();
 
        return 0;
index 20adb653cf1f16d60db3f30f925e77ecf4ed8449..df971b24f492ee0071d7456d5b85620674800a48 100644 (file)
@@ -45,9 +45,11 @@ volatile bool time_to_abort = false;
 
 
 static void usage(void);
-static XLogRecPtr FindStreamingStart(XLogRecPtr currentpos, uint32 currenttimeline);
+static XLogRecPtr FindStreamingStart(XLogRecPtr currentpos,
+                                  uint32 currenttimeline);
 static void StreamLog();
-static bool stop_streaming(XLogRecPtr segendpos, uint32 timeline, bool segment_finished);
+static bool stop_streaming(XLogRecPtr segendpos, uint32 timeline,
+                          bool segment_finished);
 
 static void
 usage(void)
@@ -57,18 +59,19 @@ usage(void)
        printf(_("Usage:\n"));
        printf(_("  %s [OPTION]...\n"), progname);
        printf(_("\nOptions:\n"));
-       printf(_("  -D, --directory=DIR      receive transaction log files into this directory\n"));
-       printf(_("  -n, --noloop             do not loop on connection lost\n"));
-       printf(_("  -v, --verbose            output verbose messages\n"));
-       printf(_("  -V, --version            output version information, then exit\n"));
-       printf(_("  -?, --help               show this help, then exit\n"));
+       printf(_("  -D, --directory=DIR    receive transaction log files into this directory\n"));
+       printf(_("  -n, --no-loop          do not loop on connection lost\n"));
+       printf(_("  -v, --verbose          output verbose messages\n"));
+       printf(_("  -V, --version          output version information, then exit\n"));
+       printf(_("  -?, --help             show this help, then exit\n"));
        printf(_("\nConnection options:\n"));
-       printf(_("  -s, --statusint=INTERVAL time between status packets sent to server (in seconds)\n"));
-       printf(_("  -h, --host=HOSTNAME      database server host or socket directory\n"));
-       printf(_("  -p, --port=PORT          database server port number\n"));
-       printf(_("  -U, --username=NAME      connect as specified database user\n"));
-       printf(_("  -w, --no-password        never prompt for password\n"));
-       printf(_("  -W, --password           force password prompt (should happen automatically)\n"));
+       printf(_("  -s, --status-interval=INTERVAL\n"
+                        "                         time between status packets sent to server (in seconds)\n"));
+       printf(_("  -h, --host=HOSTNAME    database server host or socket directory\n"));
+       printf(_("  -p, --port=PORT        database server port number\n"));
+       printf(_("  -U, --username=NAME    connect as specified database user\n"));
+       printf(_("  -w, --no-password      never prompt for password\n"));
+       printf(_("  -W, --password         force password prompt (should happen automatically)\n"));
        printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
 }
 
@@ -121,7 +124,8 @@ FindStreamingStart(XLogRecPtr currentpos, uint32 currenttimeline)
                                        log,
                                        seg;
 
-               if (strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0)
+               if (strcmp(dirent->d_name, ".") == 0 ||
+                       strcmp(dirent->d_name, "..") == 0)
                        continue;
 
                /* xlog files are always 24 characters */
@@ -147,7 +151,8 @@ FindStreamingStart(XLogRecPtr currentpos, uint32 currenttimeline)
                 */
                if (sscanf(dirent->d_name, "%08X%08X%08X", &tli, &log, &seg) != 3)
                {
-                       fprintf(stderr, _("%s: could not parse xlog filename \"%s\"\n"),
+                       fprintf(stderr,
+                                _("%s: could not parse transaction log file name \"%s\"\n"),
                                        progname, dirent->d_name);
                        disconnect_and_exit(1);
                }
@@ -178,7 +183,8 @@ FindStreamingStart(XLogRecPtr currentpos, uint32 currenttimeline)
                }
                else
                {
-                       fprintf(stderr, _("%s: segment file '%s' is incorrect size %d, skipping\n"),
+                       fprintf(stderr,
+                         _("%s: segment file \"%s\" has incorrect size %d, skipping\n"),
                                        progname, dirent->d_name, (int) statbuf.st_size);
                        continue;
                }
@@ -230,20 +236,24 @@ StreamLog(void)
        res = PQexec(conn, "IDENTIFY_SYSTEM");
        if (PQresultStatus(res) != PGRES_TUPLES_OK)
        {
-               fprintf(stderr, _("%s: could not identify system: %s\n"),
-                               progname, PQerrorMessage(conn));
+               fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
+                               progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
+
                disconnect_and_exit(1);
        }
        if (PQntuples(res) != 1 || PQnfields(res) != 3)
        {
-               fprintf(stderr, _("%s: could not identify system, got %d rows and %d fields\n"),
-                               progname, PQntuples(res), PQnfields(res));
+               fprintf(stderr,
+                               _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d fields\n"),
+                               progname, PQntuples(res), PQnfields(res), 1, 3);
+
                disconnect_and_exit(1);
        }
        timeline = atoi(PQgetvalue(res, 0, 1));
        if (sscanf(PQgetvalue(res, 0, 2), "%X/%X", &startpos.xlogid, &startpos.xrecoff) != 2)
        {
-               fprintf(stderr, _("%s: could not parse log start position from value \"%s\"\n"),
+               fprintf(stderr,
+                               _("%s: could not parse transaction log location \"%s\"\n"),
                                progname, PQgetvalue(res, 0, 2));
                disconnect_and_exit(1);
        }
@@ -263,12 +273,12 @@ StreamLog(void)
         * Start the replication
         */
        if (verbose)
-               fprintf(stderr, _("%s: starting log streaming at %X/%X (timeline %u)\n"),
+               fprintf(stderr,
+                               _("%s: starting log streaming at %X/%X (timeline %u)\n"),
                                progname, startpos.xlogid, startpos.xrecoff, timeline);
 
        ReceiveXlogStream(conn, startpos, timeline, NULL, basedir,
-                                         stop_streaming,
-                                         standby_message_timeout, false);
+                                         stop_streaming, standby_message_timeout, false);
 
        PQfinish(conn);
 }
@@ -296,15 +306,14 @@ main(int argc, char **argv)
                {"host", required_argument, NULL, 'h'},
                {"port", required_argument, NULL, 'p'},
                {"username", required_argument, NULL, 'U'},
-               {"noloop", no_argument, NULL, 'n'},
+               {"no-loop", no_argument, NULL, 'n'},
                {"no-password", no_argument, NULL, 'w'},
                {"password", no_argument, NULL, 'W'},
-               {"statusint", required_argument, NULL, 's'},
+               {"status-interval", required_argument, NULL, 's'},
                {"verbose", no_argument, NULL, 'v'},
                {NULL, 0, NULL, 0}
        };
        int                     c;
-
        int                     option_index;
 
        progname = get_progname(argv[0]);
@@ -317,8 +326,8 @@ main(int argc, char **argv)
                        usage();
                        exit(0);
                }
-               else if (strcmp(argv[1], "-V") == 0
-                                || strcmp(argv[1], "--version") == 0)
+               else if (strcmp(argv[1], "-V") == 0 ||
+                                strcmp(argv[1], "--version") == 0)
                {
                        puts("pg_receivexlog (PostgreSQL) " PG_VERSION);
                        exit(0);
@@ -412,12 +421,13 @@ main(int argc, char **argv)
        {
                StreamLog();
                if (time_to_abort)
-
+               {
                        /*
                         * We've been Ctrl-C'ed. That's not an error, so exit without an
                         * errorcode.
                         */
                        exit(0);
+               }
                else if (noloop)
                {
                        fprintf(stderr, _("%s: disconnected.\n"), progname);
@@ -425,7 +435,8 @@ main(int argc, char **argv)
                }
                else
                {
-                       fprintf(stderr, _("%s: disconnected. Waiting %d seconds to try again\n"),
+                       fprintf(stderr,
+                                       _("%s: disconnected. Waiting %d seconds to try again\n"),
                                        progname, RECONNECT_SLEEP_TIME);
                        pg_usleep(RECONNECT_SLEEP_TIME * 1000000);
                }
index c5b08fcc7ae2cb7824837231b99e391f0c9c4142..3b464123b34b904a3cb7da74d283dde997523364 100644 (file)
@@ -41,7 +41,7 @@
 const XLogRecPtr InvalidXLogRecPtr = {0, 0};
 
 /* fd for currently open WAL file */
-static int             walfile = -1;
+static int     walfile = -1;
 
 
 /*
@@ -52,7 +52,8 @@ static int            walfile = -1;
  * The file will be padded to 16Mb with zeroes.
  */
 static int
-open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir, char *namebuf)
+open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir,
+                        char *namebuf)
 {
        int                     f;
        char            fn[MAXPGPATH];
@@ -67,7 +68,8 @@ open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir, char *namebu
        f = open(fn, O_WRONLY | O_CREAT | PG_BINARY, S_IRUSR | S_IWUSR);
        if (f == -1)
        {
-               fprintf(stderr, _("%s: could not open WAL segment %s: %s\n"),
+               fprintf(stderr,
+                               _("%s: could not open transaction log file \"%s\": %s\n"),
                                progname, fn, strerror(errno));
                return -1;
        }
@@ -78,7 +80,8 @@ open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir, char *namebu
         */
        if (fstat(f, &statbuf) != 0)
        {
-               fprintf(stderr, _("%s: could not stat WAL segment %s: %s\n"),
+               fprintf(stderr,
+                               _("%s: could not stat transaction log file \"%s\": %s\n"),
                                progname, fn, strerror(errno));
                close(f);
                return -1;
@@ -87,7 +90,8 @@ open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir, char *namebu
                return f;                               /* File is open and ready to use */
        if (statbuf.st_size != 0)
        {
-               fprintf(stderr, _("%s: WAL segment %s is %d bytes, should be 0 or %d\n"),
+               fprintf(stderr,
+                               _("%s: transaction log file \"%s\" has %d bytes, should be 0 or %d\n"),
                                progname, fn, (int) statbuf.st_size, XLogSegSize);
                close(f);
                return -1;
@@ -99,7 +103,8 @@ open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir, char *namebu
        {
                if (write(f, zerobuf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
                {
-                       fprintf(stderr, _("%s: could not pad WAL segment %s: %s\n"),
+                       fprintf(stderr,
+                                       _("%s: could not pad transaction log file \"%s\": %s\n"),
                                        progname, fn, strerror(errno));
                        free(zerobuf);
                        close(f);
@@ -111,7 +116,8 @@ open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir, char *namebu
 
        if (lseek(f, SEEK_SET, 0) != 0)
        {
-               fprintf(stderr, _("%s: could not seek back to beginning of WAL segment %s: %s\n"),
+               fprintf(stderr,
+                               _("%s: could not seek to beginning of transaction log file \"%s\": %s\n"),
                                progname, fn, strerror(errno));
                close(f);
                return -1;
@@ -120,7 +126,8 @@ open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir, char *namebu
 }
 
 /*
- * Close the current WAL file, and rename it to the correct filename if it's complete.
+ * Close the current WAL file, and rename it to the correct filename if it's
+ * complete.
  *
  * If segment_complete is true, rename the current WAL file even if we've not
  * completed writing the whole segment.
@@ -132,21 +139,22 @@ close_walfile(char *basedir, char *walname, bool segment_complete)
 
        if (currpos == -1)
        {
-               fprintf(stderr, _("%s: could not get current position in file %s: %s\n"),
+               fprintf(stderr,
+                        _("%s: could not determine seek position in file \"%s\": %s\n"),
                                progname, walname, strerror(errno));
                return false;
        }
 
        if (fsync(walfile) != 0)
        {
-               fprintf(stderr, _("%s: could not fsync file %s: %s\n"),
+               fprintf(stderr, _("%s: could not fsync file \"%s\": %s\n"),
                                progname, walname, strerror(errno));
                return false;
        }
 
        if (close(walfile) != 0)
        {
-               fprintf(stderr, _("%s: could not close file %s: %s\n"),
+               fprintf(stderr, _("%s: could not close file \"%s\": %s\n"),
                                progname, walname, strerror(errno));
                walfile = -1;
                return false;
@@ -166,13 +174,14 @@ close_walfile(char *basedir, char *walname, bool segment_complete)
                snprintf(newfn, sizeof(newfn), "%s/%s", basedir, walname);
                if (rename(oldfn, newfn) != 0)
                {
-                       fprintf(stderr, _("%s: could not rename file %s: %s\n"),
+                       fprintf(stderr, _("%s: could not rename file \"%s\": %s\n"),
                                        progname, walname, strerror(errno));
                        return false;
                }
        }
        else
-               fprintf(stderr, _("%s: not renaming %s, segment is not complete.\n"),
+               fprintf(stderr,
+                               _("%s: not renaming \"%s\", segment is not complete.\n"),
                                progname, walname);
 
        return true;
@@ -272,7 +281,10 @@ localTimestampDifferenceExceeds(TimestampTz start_time,
  * Note: The log position *must* be at a log segment start!
  */
 bool
-ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysidentifier, char *basedir, stream_stop_callback stream_stop, int standby_message_timeout, bool rename_partial)
+ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
+                                 char *sysidentifier, char *basedir,
+                                 stream_stop_callback stream_stop,
+                                 int standby_message_timeout, bool rename_partial)
 {
        char            query[128];
        char            current_walfile_name[MAXPGPATH];
@@ -287,27 +299,33 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
                res = PQexec(conn, "IDENTIFY_SYSTEM");
                if (PQresultStatus(res) != PGRES_TUPLES_OK)
                {
-                       fprintf(stderr, _("%s: could not identify system: %s\n"),
-                                       progname, PQerrorMessage(conn));
+                       fprintf(stderr,
+                                       _("%s: could not send replication command \"%s\": %s"),
+                                       progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
                        PQclear(res);
                        return false;
                }
                if (PQnfields(res) != 3 || PQntuples(res) != 1)
                {
-                       fprintf(stderr, _("%s: could not identify system, got %d rows and %d fields\n"),
-                                       progname, PQntuples(res), PQnfields(res));
+                       fprintf(stderr,
+                                       _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d fields\n"),
+                                       progname, PQntuples(res), PQnfields(res), 1, 3);
                        PQclear(res);
                        return false;
                }
                if (strcmp(sysidentifier, PQgetvalue(res, 0, 0)) != 0)
                {
-                       fprintf(stderr, _("%s: system identifier does not match between base backup and streaming connection\n"), progname);
+                       fprintf(stderr,
+                                       _("%s: system identifier does not match between base backup and streaming connection\n"),
+                                       progname);
                        PQclear(res);
                        return false;
                }
                if (timeline != atoi(PQgetvalue(res, 0, 1)))
                {
-                       fprintf(stderr, _("%s: timeline does not match between base backup and streaming connection\n"), progname);
+                       fprintf(stderr,
+                                       _("%s: timeline does not match between base backup and streaming connection\n"),
+                                       progname);
                        PQclear(res);
                        return false;
                }
@@ -319,8 +337,8 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
        res = PQexec(conn, query);
        if (PQresultStatus(res) != PGRES_COPY_BOTH)
        {
-               fprintf(stderr, _("%s: could not start replication: %s\n"),
-                               progname, PQresultErrorMessage(res));
+               fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
+                               progname, "START_REPLICATION", PQresultErrorMessage(res));
                PQclear(res);
                return false;
        }
@@ -348,7 +366,8 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
                 */
                if (stream_stop && stream_stop(blockpos, timeline, false))
                {
-                       if (walfile != -1 && !close_walfile(basedir, current_walfile_name, rename_partial))
+                       if (walfile != -1 && !close_walfile(basedir, current_walfile_name,
+                                                                                               rename_partial))
                                /* Potential error message is written by close_walfile */
                                goto error;
                        return true;
@@ -364,8 +383,9 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
                {
                        /* Time to send feedback! */
                        char            replybuf[sizeof(StandbyReplyMessage) + 1];
-                       StandbyReplyMessage *replymsg = (StandbyReplyMessage *) (replybuf + 1);
+                       StandbyReplyMessage *replymsg;
 
+                       replymsg = (StandbyReplyMessage *) (replybuf + 1);
                        replymsg->write = blockpos;
                        replymsg->flush = InvalidXLogRecPtr;
                        replymsg->apply = InvalidXLogRecPtr;
@@ -433,7 +453,8 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
                        /* Else there is actually data on the socket */
                        if (PQconsumeInput(conn) == 0)
                        {
-                               fprintf(stderr, _("%s: could not receive data from WAL stream: %s\n"),
+                               fprintf(stderr,
+                                               _("%s: could not receive data from WAL stream: %s"),
                                                progname, PQerrorMessage(conn));
                                goto error;
                        }
@@ -444,7 +465,7 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
                        break;
                if (r == -2)
                {
-                       fprintf(stderr, _("%s: could not read copy data: %s\n"),
+                       fprintf(stderr, _("%s: could not read COPY data: %s"),
                                        progname, PQerrorMessage(conn));
                        goto error;
                }
@@ -456,7 +477,8 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
                         */
                        if (r != STREAMING_KEEPALIVE_SIZE)
                        {
-                               fprintf(stderr, _("%s: keepalive message is incorrect size: %d\n"),
+                               fprintf(stderr,
+                                               _("%s: keepalive message has incorrect size %d\n"),
                                                progname, r);
                                goto error;
                        }
@@ -488,7 +510,8 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
                        /* No file open yet */
                        if (xlogoff != 0)
                        {
-                               fprintf(stderr, _("%s: received xlog record for offset %u with no file open\n"),
+                               fprintf(stderr,
+                                               _("%s: received transaction log record for offset %u with no file open\n"),
                                                progname, xlogoff);
                                goto error;
                        }
@@ -499,7 +522,8 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
                        /* XXX: store seek value don't reseek all the time */
                        if (lseek(walfile, 0, SEEK_CUR) != xlogoff)
                        {
-                               fprintf(stderr, _("%s: got WAL data offset %08x, expected %08x\n"),
+                               fprintf(stderr,
+                                               _("%s: got WAL data offset %08x, expected %08x\n"),
                                                progname, xlogoff, (int) lseek(walfile, 0, SEEK_CUR));
                                goto error;
                        }
@@ -534,10 +558,9 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
                                          copybuf + STREAMING_HEADER_SIZE + bytes_written,
                                          bytes_to_write) != bytes_to_write)
                        {
-                               fprintf(stderr, _("%s: could not write %u bytes to WAL file %s: %s\n"),
-                                               progname,
-                                               bytes_to_write,
-                                               current_walfile_name,
+                               fprintf(stderr,
+                                 _("%s: could not write %u bytes to WAL file \"%s\": %s\n"),
+                                               progname, bytes_to_write, current_walfile_name,
                                                strerror(errno));
                                goto error;
                        }
@@ -581,7 +604,8 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
        res = PQgetResult(conn);
        if (PQresultStatus(res) != PGRES_COMMAND_OK)
        {
-               fprintf(stderr, _("%s: unexpected termination of replication stream: %s\n"),
+               fprintf(stderr,
+                               _("%s: unexpected termination of replication stream: %s"),
                                progname, PQresultErrorMessage(res));
                goto error;
        }
index 96311e07b31f4460664982ca5458df9afe54998b..c32c5acb2b9db58a7e0fa14dea0d42017e12058d 100644 (file)
@@ -184,7 +184,8 @@ GetConnection(void)
                tmpparam = PQparameterStatus(tmpconn, "integer_datetimes");
                if (!tmpparam)
                {
-                       fprintf(stderr, _("%s: could not determine server setting for integer_datetimes\n"),
+                       fprintf(stderr,
+                                       _("%s: could not determine server setting for integer_datetimes\n"),
                                        progname);
                        PQfinish(tmpconn);
                        exit(1);
@@ -196,7 +197,8 @@ GetConnection(void)
                if (strcmp(tmpparam, "off") != 0)
 #endif
                {
-                       fprintf(stderr, _("%s: integer_datetimes compile flag does not match server\n"),
+                       fprintf(stderr,
+                        _("%s: integer_datetimes compile flag does not match server\n"),
                                        progname);
                        PQfinish(tmpconn);
                        exit(1);