You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by le...@apache.org on 2026/09/29 13:22:06 UTC

(cloudberry) 16/50: Fix incorrect error message for IDENTIFY_SYSTEM

This is an automated email from the ASF dual-hosted git repository.

leborchuk pushed a commit to branch REL_2_STABLE
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 16911cc213743d96b20dcd37ca40cc3a3c50d5d5
Author: Daniel Gustafsson <dg...@postgresql.org>
AuthorDate: Tue Dec 5 14:30:56 2023 +0100

    Fix incorrect error message for IDENTIFY_SYSTEM
    
    Commit 5a991ef8692e accidentally reversed the order of the tuples
    and fields parameters, making the error message incorrectly refer
    to 3 tuples with 1 field when IDENTIFY_SYSTEM returns 1 tuple and
    3 or 4 fields. Fix by changing the order of the parameters.  This
    also adds a comment describing why we check for < 3 when postgres
    since 9.4 has been sending 4 fields.
    
    Backpatch all the way since the bug is almost a decade old.
    
    Author: Tomonari Katsumata <t....@gmail.com>
    Reviewed-by: Tom Lane <tg...@sss.pgh.pa.us>
    Bug: #18224
    Backpatch-through: v12
    (cherry picked from commit 376eaa45a2b8a2aed45b26e5fc889d2cb70ec6a7)
---
 src/backend/replication/libpqwalreceiver/libpqwalreceiver.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
index 4f1f7abd006..cf3f735d935 100644
--- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
+++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
@@ -366,6 +366,10 @@ libpqrcv_identify_system(WalReceiverConn *conn, TimeLineID *primary_tli)
 						"the primary server: %s",
 						pchomp(PQerrorMessage(conn->streamConn)))));
 	}
+	/*
+	 * IDENTIFY_SERVER returns 3 columns in 9.3 and earlier, and 4 columns in
+	 * 9.4 and onwards.
+	 */
 	if (PQnfields(res) < 3 || PQntuples(res) != 1)
 	{
 		int			ntuples = PQntuples(res);
@@ -376,7 +380,7 @@ libpqrcv_identify_system(WalReceiverConn *conn, TimeLineID *primary_tli)
 				(errcode(ERRCODE_PROTOCOL_VIOLATION),
 				 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, 1, 3)));
 	}
 	primary_sysid = pstrdup(PQgetvalue(res, 0, 0));
 	*primary_tli = pg_strtoint32(PQgetvalue(res, 0, 1));


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org