]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Don't fail on libpq-generated error reports in ecpg_raise_backend().
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 6 Jun 2022 15:20:21 +0000 (11:20 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 6 Jun 2022 15:20:31 +0000 (11:20 -0400)
commita5dbca460ace7e89a607d43e206973efaee0ed19
tree60a028b2acb15ffea946aea1123c91dd5ad9d871
parenta04ccf6dfb4a15b9c279154b3366f8051de8b5d1
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
src/interfaces/ecpg/ecpglib/error.c