From b8b3f861fbd7ff40055225ec48cec97df925ff04 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Fri, 16 Aug 2024 13:23:18 -0400 Subject: libpq: Trace all messages received from the server Not all messages that libpq received from the server would be sent through our message tracing logic. This commit tries to fix that by introducing a new function pqParseDone which make it harder to forget about doing so. The messages that we now newly send through our tracing logic are: - CopyData (received by COPY TO STDOUT) - Authentication requests - NegotiateProtocolVersion - Some ErrorResponse messages during connection startup - ReadyForQuery when received after a FunctionCall message Author: Jelte Fennema-Nio Discussion: https://postgr.es/m/CAGECzQSoPHtZ4xe0raJ6FYSEiPPS+YWXBhOGo+Y1YecLgknF3g@mail.gmail.com --- src/interfaces/libpq/fe-misc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/interfaces/libpq/fe-misc.c') diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index f235bfbb41f..928a47162d1 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -435,6 +435,21 @@ pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn) return EOF; } +/* + * pqParseDone: after a server-to-client message has successfully + * been parsed, advance conn->inStart to account for it. + */ +void +pqParseDone(PGconn *conn, int newInStart) +{ + /* trace server-to-client message */ + if (conn->Pfdebug) + pqTraceOutputMessage(conn, conn->inBuffer + conn->inStart, false); + + /* Mark message as done */ + conn->inStart = newInStart; +} + /* * pqPutMsgStart: begin construction of a message to the server * -- cgit v1.2.3