diff options
author | Magnus Hagander <magnus@hagander.net> | 2012-01-20 13:57:02 +0100 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2012-01-20 13:57:02 +0100 |
commit | c14534957bb93df76bc66516aa03476de0069213 (patch) | |
tree | f85903f5a89b1ad400de5c3a5f4406b9b40365bb /src | |
parent | 356fddfa0ff612a40cc85f8374f9cd058585687f (diff) | |
download | postgresql-c14534957bb93df76bc66516aa03476de0069213.tar.gz postgresql-c14534957bb93df76bc66516aa03476de0069213.zip |
Check number of fields in IDENTIFY_SYSTEM response
Jaime Casanova
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_basebackup/pg_basebackup.c | 9 | ||||
-rw-r--r-- | src/bin/pg_basebackup/pg_receivexlog.c | 6 | ||||
-rw-r--r-- | src/bin/pg_basebackup/receivelog.c | 7 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 40076802e5f..aabbdac8d00 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -918,10 +918,10 @@ BaseBackup(void) progname, PQerrorMessage(conn)); disconnect_and_exit(1); } - if (PQntuples(res) != 1) + if (PQntuples(res) != 1 || PQnfields(res) != 3) { - fprintf(stderr, _("%s: could not identify system, got %i rows\n"), - progname, PQntuples(res)); + fprintf(stderr, _("%s: could not identify system, got %i rows and %i fields\n"), + progname, PQntuples(res), PQnfields(res)); disconnect_and_exit(1); } sysidentifier = strdup(PQgetvalue(res, 0, 0)); @@ -1130,7 +1130,7 @@ BaseBackup(void) { fprintf(stderr, _("%s: could not parse xlog end position \"%s\"\n"), progname, xlogend); - exit(1); + disconnect_and_exit(1); } InterlockedIncrement(&has_xlogendptr); @@ -1162,6 +1162,7 @@ BaseBackup(void) /* * End of copy data. Final result is already checked inside the loop. */ + PQclear(res); PQfinish(conn); if (verbose) diff --git a/src/bin/pg_basebackup/pg_receivexlog.c b/src/bin/pg_basebackup/pg_receivexlog.c index e698b06b7d3..fe9e39bb214 100644 --- a/src/bin/pg_basebackup/pg_receivexlog.c +++ b/src/bin/pg_basebackup/pg_receivexlog.c @@ -235,10 +235,10 @@ StreamLog(void) progname, PQerrorMessage(conn)); disconnect_and_exit(1); } - if (PQntuples(res) != 1) + if (PQntuples(res) != 1 || PQnfields(res) != 3) { - fprintf(stderr, _("%s: could not identify system, got %i rows\n"), - progname, PQntuples(res)); + fprintf(stderr, _("%s: could not identify system, got %i rows and %i fields\n"), + progname, PQntuples(res), PQnfields(res)); disconnect_and_exit(1); } timeline = atoi(PQgetvalue(res, 0, 1)); diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index c390cbf13df..8ca3882a729 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -235,6 +235,13 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi PQclear(res); return false; } + if (PQnfields(res) != 3 || PQntuples(res) != 1) + { + fprintf(stderr, _("%s: could not identify system, got %i rows and %i fields\n"), + progname, PQntuples(res), PQnfields(res)); + 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); |