Re: libpq debug log

From: "alvherre(at)alvh(dot)no-ip(dot)org" <alvherre(at)alvh(dot)no-ip(dot)org>
To: "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>
Cc: "iwata(dot)aya(at)fujitsu(dot)com" <iwata(dot)aya(at)fujitsu(dot)com>, 'Kyotaro Horiguchi' <horikyota(dot)ntt(at)gmail(dot)com>, "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "k(dot)jamison(at)fujitsu(dot)com" <k(dot)jamison(at)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: libpq debug log
Date: 2021-03-26 19:48:42
Message-ID: 20210326194842.GA30980@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

I added an option to the new libpq_pipeline program that it activates
libpq trace. It works nicely and I think we can add that to the
regression tests. However I have two observations.

1. The trace output for the error message won't be very nice, because it
prints line numbers. So if I want to match the output to an "expected"
file, it would break every time somebody edits the source file where the
error originates and the ereport() line is moved. For example:

< 70 ErrorResponse S "ERROR" V "ERROR" C "22012" M "division by zero" F "numeric.c" L "8366" R "div_var" \x00 "Z"

The line number 8366 in this line would be problematic. I think if we
want regression testing for this, we should have another trace flag to
suppress output of a few of these fields. I would have it print only S,
C and M.

(Hey, what the heck is that "Z" at the end of the message? I thought
the error ended right at the \x00 ...)

2. The < and > characters are not good for visual inspection. I
replaced them with F and B and I think it's much clearer. Compare:

> 27 Query "SET lc_messages TO "C""
< 8 CommandComplete "SET"
< 5 ReadyForQuery I
> 21 Parse "" "SELECT $1" 1 23
> 19 Bind "" "" 0 1 1 '1' 1 0
> 6 Describe P ""
> 9 Execute "" 0
> 4 Sync
< 4 ParseComplete
< 4 BindComplete
< 33 RowDescription 1 "?column?" 0 0 23 4 -1 0
< 11 DataRow 1 1 '1'
< 13 CommandComplete "SELECT 1"
< 5 ReadyForQuery I
> 4 Terminate

with

F 27 Query "SET lc_messages TO "C""
B 8 CommandComplete "SET"
B 5 ReadyForQuery I
F 21 Parse "" "SELECT $1" 1 23
F 19 Bind "" "" 0 1 1 '1' 1 0
F 6 Describe P ""
F 9 Execute "" 0
F 4 Sync
B 4 ParseComplete
B 4 BindComplete
B 33 RowDescription 1 "?column?" 0 0 23 4 -1 0
B 11 DataRow 1 1 '1'
B 13 CommandComplete "SELECT 1"
B 5 ReadyForQuery I
F 4 Terminate

I think the second one is much easier on the eye.

(This one is the output from "libpq_pipeline simple_pipeline").

--
Álvaro Herrera Valdivia, Chile
"Saca el libro que tu religión considere como el indicado para encontrar la
oración que traiga paz a tu alma. Luego rebootea el computador
y ve si funciona" (Carlos Duclós)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2021-03-26 20:22:44 Re: SQL/JSON: functions
Previous Message Stephen Frost 2021-03-26 19:33:38 Re: Support for NSS as a libpq TLS backend