Skip to content

Commit

Permalink
First data row should be skipped since it is part of PGresult, which …
Browse files Browse the repository at this point in the history
…contains row description
  • Loading branch information
rahim-kanji committed Nov 1, 2024
1 parent 4faeb16 commit 3118c43
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions deps/postgresql/handle_row_data.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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)
+ {
Expand Down Expand Up @@ -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
}
Expand All @@ -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 === */

Expand Down

0 comments on commit 3118c43

Please sign in to comment.