]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Report the true database name on connection errors
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 26 Jan 2021 19:42:13 +0000 (16:42 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 26 Jan 2021 19:42:13 +0000 (16:42 -0300)
commitfdd405c63fff4e3d0215f1d41b1ef58361dc81dc
tree6974755678c8b0770bba0414cc585393f0c60a3f
parent3fa7b9078f284f6e0f06befeaaf0499b0a096211
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@gmail.com>
Discussion: https://postgr.es/m/CA+TgmobssJ6rS22dspWnu-oDxXevGmhMD8VcRBjmj-b9UDqRjw@mail.gmail.com
contrib/oid2name/oid2name.c
contrib/vacuumlo/vacuumlo.c
src/bin/pg_dump/pg_dumpall.c
src/bin/pgbench/pgbench.c