Re: libpq debug log

From: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: "iwata(dot)aya(at)fujitsu(dot)com" <iwata(dot)aya(at)fujitsu(dot)com>, "k(dot)jamison(at)fujitsu(dot)com" <k(dot)jamison(at)fujitsu(dot)com>
Cc: "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>, "'Kyotaro Horiguchi'" <horikyota(dot)ntt(at)gmail(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-02-25 17:48:51
Message-ID: 3800ecbd-9256-4646-bf38-78a325ab56aa@www.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I tweaked this code a little bit more. I didn't like that libpq-trace.h was exposing all the internal details of the API to the world; and I liked it even less that libpq-int.h had to include the file, exposing everything everywhere. I added some forward struct declarations in libpq-int.h to avoid including libpq-trace.h in it; and I also moved a few of the definitions from libpq-trace.h to the .c file. We didn't really need them to be exposed outside the .c file. In the makefile, libpq-trace.h was being installed in the wrong place -- I changed so that it goes to includedir_internal, like libpq-int.h.

The function pqLogFormatTimestamp was returning a pointer to where it printed things. But that was pointless, because the buffer is caller supplied, so the caller knows full well where the output is. There's no gain in functionality, so I made it return void.

I added a description of the output format to the documentation.

I renamed a lot of functions, so that it looks more like a consistent API. pqTraceMaybeBreakLine() says it returns bool, but it was using "return 1/0" rather than actual bools. That's poor style.

The only thing we're missing here is some coverage. Right now, nothing in the source tree calls this at all, so if we break it, we'll never know. I think we should introduce src/test/modules/test_pqtrace or something like that.

v22 attached.

Attachment Content-Type Size
v22-0001-Improve-libpq-tracing-capabilities.patch text/x-patch 34.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2021-02-25 18:36:22 Re: SSL SNI
Previous Message Alexey Lesovsky 2021-02-25 17:07:22 Re: Asynchronous and "direct" IO support for PostgreSQL.