From 3118c43a204566c98a67ee764ca7dfda41877f2d Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Wed, 16 Oct 2024 15:41:09 +0500 Subject: [PATCH] First data row should be skipped since it is part of PGresult, which contains row description --- deps/postgresql/handle_row_data.patch | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/deps/postgresql/handle_row_data.patch b/deps/postgresql/handle_row_data.patch index dec09fe2b..59c8e60a7 100644 --- a/deps/postgresql/handle_row_data.patch +++ b/deps/postgresql/handle_row_data.patch @@ -6,10 +6,10 @@ index 2265ab5..56883ec 100644 return conn->result; } -+int PShandleRowData(PGconn *conn, PSresult* result) { ++int PShandleRowData(PGconn *conn, bool is_first_packet, PSresult* result) { + if (!conn || !result) + return 1; -+ return psHandleRowData(conn, result); ++ return psHandleRowData(conn, is_first_packet, result); +} + diff --git src/interfaces/libpq/fe-misc.c src/interfaces/libpq/fe-misc.c @@ -60,7 +60,7 @@ diff --git src/interfaces/libpq/fe-protocol3.c src/interfaces/libpq/fe-protocol3 index 9c4aa7e..de0746c 100644 --- src/interfaces/libpq/fe-protocol3.c +++ src/interfaces/libpq/fe-protocol3.c -@@ -2299,3 +2299,105 @@ build_startup_packet(const PGconn *conn, char *packet, +@@ -2299,3 +2299,109 @@ build_startup_packet(const PGconn *conn, char *packet, return packet_len; } @@ -78,7 +78,7 @@ index 9c4aa7e..de0746c 100644 + * -1 -> Not enough data to process the message; the next call should be to PQconsumeInput. + */ +int -+psHandleRowData(PGconn *conn, PSresult* result) ++psHandleRowData(PGconn *conn, bool isFirstPacket, PSresult* result) +{ + char id; + int msgLength; @@ -122,6 +122,10 @@ index 9c4aa7e..de0746c 100644 + return 1; + } + ++ /* First data row should be skipped since it is part of PGresult, which contains row description */ ++ if (isFirstPacket) ++ return 1; ++ + if (conn->result != NULL && + conn->result->resultStatus == PGRES_TUPLES_OK) + { @@ -194,7 +198,7 @@ index c5170d1..3e3cc34 100644 extern const PGresult *PQgetResultFromPGconn(PGconn *conn); +/* ProxySQL special handler function */ -+extern int PShandleRowData(PGconn *conn, PSresult* result); ++extern int PShandleRowData(PGconn *conn, bool is_first_packet, PSresult* result); + #ifdef __cplusplus } @@ -210,7 +214,7 @@ index a951f49..e1df8b5 100644 + /* + * ProxySQL light weight routines + */ -+extern int psHandleRowData(PGconn *conn, PSresult* result); ++extern int psHandleRowData(PGconn *conn, bool is_first_packet, PSresult* result); + /* === in fe-misc.c === */