From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: In libpq, always append new error messages to conn->errorMessage |
Date: | 2021-01-11 18:12:19 |
Message-ID: | E1kz1fv-00063r-7Q@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
In libpq, always append new error messages to conn->errorMessage.
Previously, we had an undisciplined mish-mash of printfPQExpBuffer and
appendPQExpBuffer calls to report errors within libpq. This commit
establishes a uniform rule that appendPQExpBuffer[Str] should be used.
conn->errorMessage is reset only at the start of an application request,
and then accumulates messages till we're done. We can remove no less
than three different ad-hoc mechanisms that were used to get the effect
of concatenation of error messages within a sequence of operations.
Although this makes things quite a bit cleaner conceptually, the main
reason to do it is to make the world safer for the multiple-target-host
feature that was added awhile back. Previously, there were many cases
in which an error occurring during an individual host connection attempt
would wipe out the record of what had happened during previous attempts.
(The reporting is still inadequate, in that it can be hard to tell which
host got the failure, but that seems like a matter for a separate commit.)
Currently, lo_import and lo_export contain exceptions to the "never
use printfPQExpBuffer" rule. If we changed them, we'd risk reporting
an incidental lo_close failure before the actual read or write
failure, which would be confusing, not least because lo_close happened
after the main failure. We could improve this by inventing an
internal version of lo_close that doesn't reset the errorMessage; but
we'd also need a version of PQfn() that does that, and it didn't quite
seem worth the trouble for now.
Discussion: https://postgr.es/m/BN6PR05MB3492948E4FD76C156E747E8BC9160@BN6PR05MB3492.namprd05.prod.outlook.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/ffa2e4670123124b92f037d335a1e844c3782d3f
Modified Files
--------------
src/interfaces/libpq/fe-auth-scram.c | 124 ++++++------
src/interfaces/libpq/fe-auth.c | 169 ++++++++--------
src/interfaces/libpq/fe-connect.c | 317 +++++++++++++------------------
src/interfaces/libpq/fe-exec.c | 281 ++++++++++++---------------
src/interfaces/libpq/fe-gssapi-common.c | 9 +-
src/interfaces/libpq/fe-lobj.c | 210 ++++++++++----------
src/interfaces/libpq/fe-misc.c | 54 +++---
src/interfaces/libpq/fe-protocol2.c | 36 ++--
src/interfaces/libpq/fe-protocol3.c | 51 +++--
src/interfaces/libpq/fe-secure-common.c | 24 +--
src/interfaces/libpq/fe-secure-gssapi.c | 28 +--
src/interfaces/libpq/fe-secure-openssl.c | 124 ++++++------
src/interfaces/libpq/fe-secure.c | 28 +--
src/interfaces/libpq/libpq-int.h | 18 +-
14 files changed, 699 insertions(+), 774 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-01-11 19:12:41 | pgsql: Allow pg_regress.c wrappers to postprocess test result files. |
Previous Message | Thomas Munro | 2021-01-11 02:31:27 | pgsql: Provide pg_preadv() and pg_pwritev(). |