Skip to content

Commit 083d29c

Browse files
committed
Fix bug in checking of IDENTIFY_SYSTEM result.
5a991ef 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
1 parent 8605bc7 commit 083d29c

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ libpqrcv_identify_system(TimeLineID *primary_tli)
131131
"the primary server: %s",
132132
PQerrorMessage(streamConn))));
133133
}
134-
if (PQnfields(res) < 3 || PQntuples(res) != 1)
134+
if (PQnfields(res) < 4 || PQntuples(res) != 1)
135135
{
136136
int ntuples = PQntuples(res);
137137
int nfields = PQnfields(res);
@@ -140,7 +140,7 @@ libpqrcv_identify_system(TimeLineID *primary_tli)
140140
ereport(ERROR,
141141
(errmsg("invalid response from primary server"),
142142
errdetail("Could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields.",
143-
ntuples, nfields, 3, 1)));
143+
ntuples, nfields, 4, 1)));
144144
}
145145
primary_sysid = PQgetvalue(res, 0, 0);
146146
*primary_tli = pg_atoi(PQgetvalue(res, 0, 1), 4, 0);

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,11 +1644,11 @@ BaseBackup(void)
16441644
progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
16451645
disconnect_and_exit(1);
16461646
}
1647-
if (PQntuples(res) != 1 || PQnfields(res) < 3)
1647+
if (PQntuples(res) != 1 || PQnfields(res) < 4)
16481648
{
16491649
fprintf(stderr,
16501650
_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
1651-
progname, PQntuples(res), PQnfields(res), 1, 3);
1651+
progname, PQntuples(res), PQnfields(res), 1, 4);
16521652
disconnect_and_exit(1);
16531653
}
16541654
sysidentifier = pg_strdup(PQgetvalue(res, 0, 0));

src/bin/pg_basebackup/pg_receivexlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ StreamLog(void)
290290
progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
291291
disconnect_and_exit(1);
292292
}
293-
if (PQntuples(res) != 1 || PQnfields(res) < 3)
293+
if (PQntuples(res) != 1 || PQnfields(res) < 4)
294294
{
295295
fprintf(stderr,
296296
_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
297-
progname, PQntuples(res), PQnfields(res), 1, 3);
297+
progname, PQntuples(res), PQnfields(res), 1, 4);
298298
disconnect_and_exit(1);
299299
}
300300
servertli = atoi(PQgetvalue(res, 0, 1));

src/bin/pg_basebackup/receivelog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,11 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
499499
PQclear(res);
500500
return false;
501501
}
502-
if (PQntuples(res) != 1 || PQnfields(res) < 3)
502+
if (PQntuples(res) != 1 || PQnfields(res) < 4)
503503
{
504504
fprintf(stderr,
505505
_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
506-
progname, PQntuples(res), PQnfields(res), 1, 3);
506+
progname, PQntuples(res), PQnfields(res), 1, 4);
507507
PQclear(res);
508508
return false;
509509
}

0 commit comments

Comments
 (0)