]> granicus.if.org Git - postgresql/commitdiff
Fix bug in checking of IDENTIFY_SYSTEM result.
authorFujii Masao <fujii@postgresql.org>
Tue, 19 Aug 2014 08:26:07 +0000 (17:26 +0900)
committerFujii Masao <fujii@postgresql.org>
Tue, 19 Aug 2014 08:26:43 +0000 (17:26 +0900)
5a991ef8692ed0d170b44958a81a6bd70e90585 added new column into
the result of IDENTIFY_SYSTEM command. But it was not reflected into
several codes checking that result. Specifically though the number of
columns in the result was increased to 4, it was still compared with 3
in some replication codes.

Back-patch to 9.4 where the number of columns in IDENTIFY_SYSTEM
result was increased.

Report from Michael Paquier

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_basebackup/pg_receivexlog.c
src/bin/pg_basebackup/receivelog.c

index 65e95c59f02f9b88cfc07b43eb88bc607e12a7d8..7049f12296bf9f2659a296fdaa406bb42c52d6ec 100644 (file)
@@ -131,7 +131,7 @@ libpqrcv_identify_system(TimeLineID *primary_tli)
                                                "the primary server: %s",
                                                PQerrorMessage(streamConn))));
        }
-       if (PQnfields(res) < 3 || PQntuples(res) != 1)
+       if (PQnfields(res) < 4 || PQntuples(res) != 1)
        {
                int                     ntuples = PQntuples(res);
                int                     nfields = PQnfields(res);
@@ -140,7 +140,7 @@ libpqrcv_identify_system(TimeLineID *primary_tli)
                ereport(ERROR,
                                (errmsg("invalid response from primary server"),
                                 errdetail("Could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields.",
-                                                  ntuples, nfields, 3, 1)));
+                                                  ntuples, nfields, 4, 1)));
        }
        primary_sysid = PQgetvalue(res, 0, 0);
        *primary_tli = pg_atoi(PQgetvalue(res, 0, 1), 4, 0);
index 85f18a89820a672a12887f4a9990ba8c6d056df0..4d6e6c08a02165ff7831a1baf4f6930e6c3206a2 100644 (file)
@@ -1644,11 +1644,11 @@ BaseBackup(void)
                                progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
                disconnect_and_exit(1);
        }
-       if (PQntuples(res) != 1 || PQnfields(res) < 3)
+       if (PQntuples(res) != 1 || PQnfields(res) < 4)
        {
                fprintf(stderr,
                                _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
-                               progname, PQntuples(res), PQnfields(res), 1, 3);
+                               progname, PQntuples(res), PQnfields(res), 1, 4);
                disconnect_and_exit(1);
        }
        sysidentifier = pg_strdup(PQgetvalue(res, 0, 0));
index ba635f2b86fbbfe0da11982032a9e88ef757a69d..05e5087f610393b2406e4ca9d506c5ddaa30d44b 100644 (file)
@@ -287,11 +287,11 @@ StreamLog(void)
                                progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
                disconnect_and_exit(1);
        }
-       if (PQntuples(res) != 1 || PQnfields(res) < 3)
+       if (PQntuples(res) != 1 || PQnfields(res) < 4)
        {
                fprintf(stderr,
                                _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
-                               progname, PQntuples(res), PQnfields(res), 1, 3);
+                               progname, PQntuples(res), PQnfields(res), 1, 4);
                disconnect_and_exit(1);
        }
        servertli = atoi(PQgetvalue(res, 0, 1));
index 8f360ec3e4607003a85863d974b75832eb5d9bb6..7c67d06cf6348ca0bf28c6ce63c49c4a5a845d30 100644 (file)
@@ -472,11 +472,11 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
                        PQclear(res);
                        return false;
                }
-               if (PQntuples(res) != 1 || PQnfields(res) < 3)
+               if (PQntuples(res) != 1 || PQnfields(res) < 4)
                {
                        fprintf(stderr,
                                        _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
-                                       progname, PQntuples(res), PQnfields(res), 1, 3);
+                                       progname, PQntuples(res), PQnfields(res), 1, 4);
                        PQclear(res);
                        return false;
                }