aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/interfaces/libpq/fe-connect.c14
-rw-r--r--src/interfaces/libpq/fe-trace.c20
-rw-r--r--src/interfaces/libpq/libpq-int.h2
3 files changed, 36 insertions, 0 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 360d9a45476..a5055271ae3 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -3493,11 +3493,17 @@ keep_going: /* We will come back to here until there is
}
if (SSLok == 'S')
{
+ if (conn->Pfdebug)
+ pqTraceOutputCharResponse(conn, "SSLResponse",
+ SSLok);
/* mark byte consumed */
conn->inStart = conn->inCursor;
}
else if (SSLok == 'N')
{
+ if (conn->Pfdebug)
+ pqTraceOutputCharResponse(conn, "SSLResponse",
+ SSLok);
/* mark byte consumed */
conn->inStart = conn->inCursor;
@@ -3635,6 +3641,10 @@ keep_going: /* We will come back to here until there is
if (gss_ok == 'N')
{
+ if (conn->Pfdebug)
+ pqTraceOutputCharResponse(conn, "GSSENCResponse",
+ gss_ok);
+
/*
* The connection is still valid, so if it's OK to
* continue without GSS, we can proceed using this
@@ -3648,6 +3658,10 @@ keep_going: /* We will come back to here until there is
gss_ok);
goto error_return;
}
+
+ if (conn->Pfdebug)
+ pqTraceOutputCharResponse(conn, "GSSENCResponse",
+ gss_ok);
}
/* Begin or continue GSSAPI negotiation */
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);
+}
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index 03e4da40ba1..d97b595c97f 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -889,6 +889,8 @@ extern ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len);
extern void pqTraceOutputMessage(PGconn *conn, const char *message,
bool toServer);
extern void pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message);
+extern void pqTraceOutputCharResponse(PGconn *conn, const char *responseType,
+ char response);
/* === miscellaneous macros === */