v13-0001-libpq-Trace-NegotiateProtocolVersion-correctly.patch
application/octet-stream
Filename: v13-0001-libpq-Trace-NegotiateProtocolVersion-correctly.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v13-0001
Subject: libpq: Trace NegotiateProtocolVersion correctly
| File | + | − |
|---|---|---|
| src/interfaces/libpq/fe-connect.c | 4 | 0 |
| src/interfaces/libpq/fe-trace.c | 7 | 1 |
From 9878854939bf79a829c923bf6c18b6177d04804a Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <jelte.fennema@microsoft.com>
Date: Wed, 5 Jun 2024 11:40:04 +0200
Subject: [PATCH v13 1/9] libpq: Trace NegotiateProtocolVersion correctly
This changes the libpq tracing code to correctly trace the
NegotiateProtocolVersion message. Previously it wasn't important that
tracing of the NegotiateProtocolVersion message worked correctly,
because in practice libpq never received it. Now that we are planning to
introduce protocol changes in future commits it starts to become more
useful for testing/debugging.
---
src/interfaces/libpq/fe-connect.c | 4 ++++
src/interfaces/libpq/fe-trace.c | 8 +++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 548ad118fb1..794b82cda1c 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -3857,6 +3857,10 @@ keep_going: /* We will come back to here until there is
libpq_append_conn_error(conn, "received invalid protocol negotiation message");
goto error_return;
}
+
+ if (conn->Pfdebug)
+ pqTraceOutputMessage(conn, conn->inBuffer + conn->inStart, false);
+
/* OK, we read the message; mark data consumed */
conn->inStart = conn->inCursor;
goto error_return;
diff --git a/src/interfaces/libpq/fe-trace.c b/src/interfaces/libpq/fe-trace.c
index d7a61ec9cc1..d976b50d702 100644
--- a/src/interfaces/libpq/fe-trace.c
+++ b/src/interfaces/libpq/fe-trace.c
@@ -474,9 +474,15 @@ pqTraceOutput_RowDescription(FILE *f, const char *message, int *cursor, bool reg
static void
pqTraceOutput_NegotiateProtocolVersion(FILE *f, const char *message, int *cursor)
{
+ int nparams;
+
fprintf(f, "NegotiateProtocolVersion\t");
pqTraceOutputInt32(f, message, cursor, false);
- pqTraceOutputInt32(f, message, cursor, false);
+ nparams = pqTraceOutputInt32(f, message, cursor, false);
+ for (int i = 0; i < nparams; i++)
+ {
+ pqTraceOutputString(f, message, cursor, false);
+ }
}
static void
base-commit: 7b71e5bbccd6c86bc12ba0124e7282cfb3aa3226
--
2.34.1