pgsql: Don't fail on libpq-generated error reports in ecpg_raise_backen

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't fail on libpq-generated error reports in ecpg_raise_backen
Date: 2022-06-06 15:21:19
Message-ID: E1nyEXf-003062-E8@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't fail on libpq-generated error reports in ecpg_raise_backend().

An error PGresult generated by libpq itself, such as a report of
connection loss, won't have broken-down error fields.
ecpg_raise_backend() blithely assumed that PG_DIAG_MESSAGE_PRIMARY
would always be present, and would end up passing a NULL string
pointer to snprintf when it isn't. That would typically crash
before 3779ac62d, and it would fail to provide a useful error report
in any case. Best practice is to substitute PQerrorMessage(conn)
in such cases, so do that.

Per bug #17421 from Masayuki Hirose. Back-patch to all supported
branches.

Discussion: https://postgr.es/m/17421-790ff887e3188874@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/89254606b61e36b82930c509326d46b72e003545

Modified Files
--------------
src/interfaces/ecpg/ecpglib/error.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2022-06-06 15:27:07 pgsql: Don't fail on libpq-generated error reports in pg_amcheck.
Previous Message Michael Paquier 2022-06-06 02:08:46 pgsql: Fix psql's single transaction mode on client-side errors with -c