postgresql/src/bin/pg_dump
Tom Lane a45bc8a4f6 Fix handling of -d "connection string" in pg_dump/pg_restore.
Parallel pg_dump failed if its -d parameter was a connection string
containing any essential information other than host, port, or username.
The same was true for pg_restore with --create.

The reason is that these scenarios failed to preserve the connection
string from the command line; the code felt free to replace that with
just the database name when reconnecting from a pg_dump parallel worker
or after creating the target database.  By chance, parallel pg_restore
did not suffer this defect, as long as you didn't say --create.

In practice it seems that the error would be obvious only if the
connstring included essential, non-default SSL or GSS parameters.
This may explain why it took us so long to notice.  (It also makes
it very difficult to craft a regression test case illustrating the
problem, since the test would fail in builds without those options.)

Fix by refactoring so that ConnectDatabase always receives all the
relevant options directly from the command line, rather than
reconstructed values.  Inject a different database name, when necessary,
by relying on libpq's rules for handling multiple "dbname" parameters.

While here, let's get rid of the essentially duplicate _connectDB
function, as well as some obsolete nearby cruft.

Per bug #16604 from Zsolt Ero.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/16604-933f4b8791227b15@postgresql.org
2020-09-24 18:19:38 -04:00
..
po Translation updates 2020-05-18 12:49:30 +02:00
t Invent "amadjustmembers" AM method for validating opclass members. 2020-08-01 17:12:47 -04:00
.gitignore Clean up after pg_dump test runs. 2016-05-06 22:28:01 -04:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
common.c Avoid useless allocations for information of dumpable objects in pg_dump/ 2020-09-14 10:44:23 +09:00
compress_io.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
compress_io.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
dumputils.c Remove unused parameters 2020-09-19 13:29:54 +02:00
dumputils.h Remove unused parameters 2020-09-19 13:29:54 +02:00
nls.mk Fix gettext triggers specification 2019-08-26 19:06:01 +02:00
parallel.c code: replace 'master' with 'leader' where appropriate. 2020-07-08 12:58:32 -07:00
parallel.h code: replace 'master' with 'leader' where appropriate. 2020-07-08 12:58:32 -07:00
pg_backup.h Fix handling of -d "connection string" in pg_dump/pg_restore. 2020-09-24 18:19:38 -04:00
pg_backup_archiver.c Fix handling of -d "connection string" in pg_dump/pg_restore. 2020-09-24 18:19:38 -04:00
pg_backup_archiver.h Fix handling of -d "connection string" in pg_dump/pg_restore. 2020-09-24 18:19:38 -04:00
pg_backup_custom.c Yet more elimination of dead stores and useless initializations. 2020-09-05 13:17:32 -04:00
pg_backup_db.c Fix handling of -d "connection string" in pg_dump/pg_restore. 2020-09-24 18:19:38 -04:00
pg_backup_db.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_backup_directory.c code: replace 'master' with 'leader' where appropriate. 2020-07-08 12:58:32 -07:00
pg_backup_null.c Remove useless "return;" lines 2019-11-28 16:48:37 -03:00
pg_backup_tar.c Remove unused parameters 2020-09-19 13:29:54 +02:00
pg_backup_tar.h Fix tar files emitted by pg_dump and pg_basebackup to be POSIX conformant. 2012-09-28 15:19:15 -04:00
pg_backup_utils.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_backup_utils.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_dump.c Fix handling of -d "connection string" in pg_dump/pg_restore. 2020-09-24 18:19:38 -04:00
pg_dump.h Add support for streaming to built-in logical replication. 2020-09-03 07:54:07 +05:30
pg_dump_sort.c Fix pg_dump/pg_restore to restore event triggers later. 2020-03-09 14:58:26 -04:00
pg_dumpall.c Remove unused parameters 2020-09-19 13:29:54 +02:00
pg_restore.c Fix handling of -d "connection string" in pg_dump/pg_restore. 2020-09-24 18:19:38 -04:00