From 198b3716dba68544b55cb97bd120738a86d5df2d Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Tue, 30 Mar 2021 20:12:34 -0300 Subject: Improve PQtrace() output format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Transform the PQtrace output format from its ancient (and mostly useless) byte-level output format to a logical-message-level output, making it much more usable. This implementation allows the printing code to be written (as it indeed was) by looking at the protocol documentation, which gives more confidence that the three (docs, trace code and actual code) actually match. Author: 岩田 彩 (Aya Iwata) Reviewed-by: 綱川 貴之 (Takayuki Tsunakawa) Reviewed-by: Kirk Jamison Reviewed-by: Kyotaro Horiguchi Reviewed-by: Tom Lane Reviewed-by: 黒田 隼人 (Hayato Kuroda) Reviewed-by: "Nagaura, Ryohei" Reviewed-by: Ryo Matsumura Reviewed-by: Greg Nancarrow Reviewed-by: Jim Doty Reviewed-by: Álvaro Herrera Discussion: https://postgr.es/m/71E660EB361DF14299875B198D4CE5423DE3FBA4@g01jpexmbkw25 --- doc/src/sgml/libpq.sgml | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index be674fbaa92..3ec458ce09d 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -6459,12 +6459,27 @@ PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibilit - Enables tracing of the client/server communication to a debugging file stream. + Enables tracing of the client/server communication to a debugging file + stream. void PQtrace(PGconn *conn, FILE *stream); + + Each line consists of: an optional timestamp, a direction indicator + (F for messages from client to server + or B for messages from server to client), + message length, message type, and message contents. + Non-message contents fields (timestamp, direction, length and message type) + are separated by a tab. Message contents are separated by a space. + Protocol strings are enclosed in double quotes, while strings used as data + values are enclosed in single quotes. Non-printable chars are printed as + hexadecimal escapes. + Further message-type-specific detail can be found in + . + + On Windows, if the libpq library and an application are @@ -6479,6 +6494,31 @@ void PQtrace(PGconn *conn, FILE *stream); + + PQtraceSetFlagsPQtraceSetFlags + + + + Controls the tracing behavior of client/server communication. + +void PQtraceSetFlags(PGconn *conn, int flags); + + + + + flags contains flag bits describing the operating mode + of tracing. + If flags contains PQTRACE_SUPPRESS_TIMESTAMPS, + then the timestamp is not included when printing each message. + If flags contains PQTRACE_REGRESS_MODE, + then some fields are redacted when printing each message, such as object + OIDs, to make the output more convenient to use in testing frameworks. + This function must be called after calling PQtrace. + + + + + PQuntracePQuntrace -- cgit v1.2.3