RE: libpq debug log

tsunakawa.takay@fujitsu.com <tsunakawa.takay@fujitsu.com>

From: "tsunakawa.takay@fujitsu.com" <tsunakawa.takay@fujitsu.com>
To: "k.jamison@fujitsu.com" <k.jamison@fujitsu.com>, "iwata.aya@fujitsu.com" <iwata.aya@fujitsu.com>
Cc: "'pgsql-hackers@lists.postgresql.org'" <pgsql-hackers@lists.postgresql.org>
Date: 2020-12-22T00:53:15Z
Lists: pgsql-hackers
From: k.jamison@fujitsu.com <k.jamison@fujitsu.com>
> I understand that protocol 2.0 is still supported, but it is only used for
> PostgreSQL versions 7.3 and earlier, which is not updated by fixes anymore
> since we only backpatch up to previous 5 versions. However I am not sure if
> it's a good idea, but how about if we just support this feature for protocol 3.

+1
I thought psqlODBC (still) allows the user to choose the protocol version, it looks like the current psqlODBC disallows pre-3 protocol:

[libpq_connect()]
    MYLOG(0, "libpq connection to the database established.\n");
    pversion = PQprotocolVersion(pqconn);
    if (pversion < 3)
    {
        MYLOG(0, "Protocol version %d is not supported\n", pversion);
        goto cleanup;
    }


> There are similar chunks of code in fe-exec.c, PQsendPrepare(),
> PQsendDescribe(),
> etc. that already do something similar, so I just thought in hindsight if we can
> do the same.
> 	if (PG_PROTOCOL_MAJOR(conn->pversion) >= 3)
> 	{
>         <new code here>
>     }
>     else
>     {
>         /* Protocol 2.0 isn't supported */
>          printfPQExpBuffer(&conn->errorMessage,
>                            libpq_gettext("function requires at least protocol
> version 3.0\n"));
>          return 0;
>     }


I haven't looked at the patch and don't know the code structure, but I want the code clutter to be minimized.  So, I think we should avoid putting if statements like above here and there.

Plus, I don't think it's not necessary to fail the processing when the protocol version is 2; we can just stop the trace output.  So, how about disabling the trace output silently if the protocol turns out to be < 3 upon connection?


Regards
Takayuki Tsunakawa






Commits

  1. Rename PQtraceSetFlags() to PQsetTraceFlags().

  2. Suppress length of Notice/Error msgs in PQtrace regress mode

  3. Strip file names reported in error messages on Windows, too.

  4. Fix setvbuf()-induced crash in libpq_pipeline

  5. libpq_pipeline: Must strdup(optarg) to avoid crash

  6. Remove setvbuf() call from PQtrace()

  7. Initialize conn->Pfdebug to NULL when creating a connection

  8. Disable force_parallel_mode in libpq_pipeline

  9. libpq_pipeline: add PQtrace() support and tests

  10. Improve PQtrace() output format

  11. Re-simplify management of inStart in pqParseInput3's subroutines.