Re: libpq: Fix lots of discrepancies in PQtrace

Jelte Fennema-Nio <postgres@jeltef.nl>

From: Jelte Fennema-Nio <postgres@jeltef.nl>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Michael Paquier <michael@paquier.xyz>, Nathan Bossart <nathandbossart@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-08-10T14:27:02Z
Lists: pgsql-hackers
On Sat, 10 Aug 2024 at 01:08, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> I don't want to add 4 bytes to struct pg_conn for tracing support.  I'm
> tempted to make the new struct member a plain 'char' to reduce overhead
> for a feature that almost nobody is going to use.  According to pahole
> we have a 3 bytes hole in that position of the struct, so if we make it
> a 1- or 2-byte member, there's no storage overhead whatsoever.

Sounds fine to me.

> Also, why not have pqTraceOutputMessage() responsible for resetting the
> byte after printing the message?  It seems to cause less undesirable
> detritus.

Yeah, that's indeed much nicer.

> I propose something like the attached, but it's as yet untested.  What
> do you think?

Looks good, but I haven't tested it yet either.



Commits

  1. libpq: Trace all messages received from the server

  2. libpq: Trace responses to SSLRequest and GSSENCRequest

  3. libpq: Trace frontend authentication challenges

  4. libpq: Trace StartupMessage/SSLRequest/GSSENCRequest correctly

  5. libpq: Add suppress argument to pqTraceOutputNchar

  6. Use PqMsg_* macros in fe-auth.c.