RE: libpq debug log - Mailing list pgsql-hackers

From iwata.aya@fujitsu.com
Subject RE: libpq debug log
Date
Msg-id TY2PR01MB1963A1EDDFC4C6B73D2066ADEA7D9@TY2PR01MB1963.jpnprd01.prod.outlook.com
Whole thread Raw
In response to RE: libpq debug log  ("tsunakawa.takay@fujitsu.com" <tsunakawa.takay@fujitsu.com>)
Responses Re: libpq debug log  ("'alvherre@alvh.no-ip.org'" <alvherre@alvh.no-ip.org>)
List pgsql-hackers
Hi Alvaro san, Tsunakawa san

Thank you for creating the v30 patch.

> From: Tsunakawa, Takayuki/綱川 貴之 <tsunakawa.takay@fujitsu.com>
> Sent: Monday, March 29, 2021 9:45 AM
...
> Iwata-san,
> Please review Alvaro-san's code, and I think you can integrate all patches into
> one except for 0002 and 0007.  Those two patches may be separate or
> merged into one as a test patch.

I reviewed v30 patches. I think it was good except that the documentation about the direction of the message was not
changing.
I also tried the v30 patch using regression test and it worked fine.
I merged v30 patches and update the patch to v31.

This new version patch includes the fix of libpq.smgl fix and the addition of regression test mode.
In libpq.smgl, the symbol indicating the message direction has been corrected from "<" ">" to "B" "F" in the
documentation.

> From: alvherre@alvh.no-ip.org <alvherre@alvh.no-ip.org>
> Sent: Sunday, March 28, 2021 4:28 AM
...
> Maybe the easiest way is to have a new flag PQTRACE_REGRESS_MODE.

To prepare for regression test, I read Message Formats documentation.
https://www.postgresql.org/docs/current/protocol-message-formats.html

Following protocol messages have values that depend on the code of master at that time;
- BackendKeyData(B) ... includes backend PID and backend private key
- ErrorResponse(B) ... includes error message line number
- FunctionCall(F) ... includes function OID
- NoticeResponse(B) ... includes notice message line number
- NotificationResponse (B) ... includes backend PID
- ParameterDescription  ... includes parameter OID
- Parse(F) ... includes parameter data type OID
- RowDescription(B) ... includes OIDs

I checked status of conn->pqTraceFlags to decide whether output version-dependent messages or not in above protocol
messageoutput functions.
 
In ErrorResponse and NoticeResponse, I skip string type message logging only when field type code is "L".
In my understanding, other field code message type does not depend on version.
So I didn't skip other code type's string messages.
And I also changed description of pqTraceSetFlags()
by changing PQTRACE_SUPPRESS_TIMESTAMPS flag to the PQTRACE_REGRESS_MODE flag.

Output of regress mode is following;

B   124 ErrorResponse    S "ERROR" V "ERROR" C "22023" M "unrecognized parameter "some_nonexistent_parameter"" F
"reloptions.c"L R "parseRelOptionsInternal" \x00
 
B   14  ParameterDescription     2   

Output of non-regress mode is following;

2021-03-30 12:55:31.327913  B   124 ErrorResponse    S "ERROR" V "ERROR" C "22023" M "unrecognized parameter
"some_nonexistent_parameter""F "reloptions.c" L "1447" R "parseRelOptionsInternal" \x00
 
2021-03-30 12:56:12.691617  B   14  ParameterDescription     2 25 701

Regards,
Aya Iwata

Attachment

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Refactor SSL test framework to support multiple TLS libraries
Next
From: Rod Taylor
Date:
Subject: Re: Idea: Avoid JOINs by using path expressions to follow FKs