libpq: Fix lots of discrepancies in PQtrace
Jelte Fennema-Nio <postgres@jeltef.nl>
From: Jelte Fennema-Nio <postgres@jeltef.nl>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-06-21T09:22:05Z
Lists: pgsql-hackers
Attachments
- v1-0001-libpq-Use-PqMsg-macros-in-fe-auth.c.patch (application/x-patch) patch v1-0001
- v1-0002-libpq-Add-suppress-argument-to-pqTraceOutputNchar.patch (application/x-patch) patch v1-0002
- v1-0003-libpq-Trace-StartupMessage-SSLRequest-GSSENCReque.patch (application/x-patch) patch v1-0003
- v1-0004-libpq-Trace-frontend-authentication-challenges.patch (application/x-patch) patch v1-0004
- v1-0005-libpq-Trace-responses-to-SSLRequest-and-GSSENCReq.patch (application/x-patch) patch v1-0005
- v1-0006-libpq-Trace-all-messages-received-from-the-server.patch (application/x-patch) patch v1-0006
- v1-0007-libpq-Trace-server-Authentication-messages-in-det.patch (application/x-patch) patch v1-0007
- v1-0008-libpq-Trace-NegotiateProtocolVersion-correctly.patch (application/x-patch) patch v1-0008
After initially trying to add trace support for StartupMessage/SSLRequest/GSSENCRequest[1] I realized there were many more cases where PQtrace was not correctly tracing messages, or not even tracing them at all. These patches fix all of the issues that I was able to find. 0001 is some cleanup after f4b54e1ed9 0002 does some preparatory changes for 0004 & 0007 All the others improve the tracing, and apart from 0004 and 0007 depending on 0002, none of these patches depend on each other. Although you could argue that 0007 and 0008 depend on 0006, because without 0006 the code added by 0007 and 0008 won't ever really be executed. To test you can add a PQreset(conn) call to the start of the test_cancel function in: src/test/modules/libpq_pipeline/libpq_pipeline.c. And then run: ninja -C build all install-quiet && build/src/test/modules/libpq_pipeline/libpq_pipeline cancel 'port=5432' -t test.trace And then look at the top of test.trace [1]: https://www.postgresql.org/message-id/CAGECzQTTN5aGqtDaRifJXPyd_O5qHWQcOxsHJsDSVNqMugGNEA%40mail.gmail.com
Commits
-
libpq: Trace all messages received from the server
- b8b3f861fbd7 18.0 landed
-
libpq: Trace responses to SSLRequest and GSSENCRequest
- a5c6b8f22c20 18.0 landed
-
libpq: Trace frontend authentication challenges
- ea92f3a0a5ad 18.0 landed
-
libpq: Trace StartupMessage/SSLRequest/GSSENCRequest correctly
- 7adec2d5fc29 18.0 landed
-
libpq: Add suppress argument to pqTraceOutputNchar
- 4eb179e5bf7a 18.0 landed
-
Use PqMsg_* macros in fe-auth.c.
- 32f07991b728 17.0 landed