aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-trace.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2024-08-14 14:53:55 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2024-08-14 14:53:55 -0400
commita5c6b8f22c206aaa22fc9a826f858a262a023cd5 (patch)
tree44e0aa32f274b2cbcc53a7655746a148d9a6098b /src/interfaces/libpq/fe-trace.c
parent5304fec4d8a141abe6f8f6f2a6862822ec1f3598 (diff)
downloadpostgresql-a5c6b8f22c206aaa22fc9a826f858a262a023cd5.tar.gz
postgresql-a5c6b8f22c206aaa22fc9a826f858a262a023cd5.zip
libpq: Trace responses to SSLRequest and GSSENCRequest
Since these are single bytes instead of v2 or v3 messages they need custom tracing logic. These "messages" don't even have official names in the protocol specification, so I (Jelte) called them SSLResponse and GSSENCResponse here. Author: Jelte Fennema-Nio <postgres@jeltef.nl> Discussion: https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com
Diffstat (limited to 'src/interfaces/libpq/fe-trace.c')
-rw-r--r--src/interfaces/libpq/fe-trace.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/interfaces/libpq/fe-trace.c b/src/interfaces/libpq/fe-trace.c
index 367b322b992..3527b9f0f5d 100644
--- a/src/interfaces/libpq/fe-trace.c
+++ b/src/interfaces/libpq/fe-trace.c
@@ -840,3 +840,23 @@ pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message)
fputc('\n', conn->Pfdebug);
}
+
+/*
+ * Trace a single-byte backend response received for a known request
+ * type the frontend previously sent. Only useful for the simplest of
+ * FE/BE interaction workflows such as SSL/GSS encryption requests.
+ */
+void
+pqTraceOutputCharResponse(PGconn *conn, const char *responseType,
+ char response)
+{
+ if ((conn->traceFlags & PQTRACE_SUPPRESS_TIMESTAMPS) == 0)
+ {
+ char timestr[128];
+
+ pqTraceFormatTimestamp(timestr, sizeof(timestr));
+ fprintf(conn->Pfdebug, "%s\t", timestr);
+ }
+
+ fprintf(conn->Pfdebug, "B\t1\t%s\t %c\n", responseType, response);
+}