pgsql: Report the true database name on connection errors

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Report the true database name on connection errors
Date: 2021-01-26 19:43:13
Message-ID: E1l4UF7-0006w3-5x@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Report the true database name on connection errors

When reporting connection errors, we might show a database name in the
message that's not the one we actually tried to connect to, if the
database was taken from libpq defaults instead of from user parameters.
Fix such error messages to use PQdb(), which reports the correct name.

(But, per commit 2930c05634bc, make sure not to try to print NULL.)

Apply to branches 9.5 through 13. Branch master has already been
changed differently by commit 58cd8dca3de0.

Reported-by: Robert Haas <robertmhaas(at)gmail(dot)com>
Discussion: https://postgr.es/m/CA+TgmobssJ6rS22dspWnu-oDxXevGmhMD8VcRBjmj-b9UDqRjw@mail.gmail.com

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bcae842b962a485524a41575810caf231400e3db

Modified Files
--------------
contrib/oid2name/oid2name.c | 2 +-
contrib/vacuumlo/vacuumlo.c | 2 +-
src/bin/pg_dump/pg_dumpall.c | 2 +-
src/bin/pgbench/pgbench.c | 5 +++--
4 files changed, 6 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2021-01-26 21:37:31 pgsql: Rethink recently-added SPI interfaces.
Previous Message Tom Lane 2021-01-26 19:06:08 Re: pgsql: Improve performance of repeated CALLs within plpgsql procedures.