On Fri, 20 Mar 2026 at 01:31, Mahendra Singh Thalor <[email protected]> wrote: > > Thanks Nathan for committing this. > > Thanks and Regards > Mahendra Singh Thalor > EnterpriseDB: http://www.enterprisedb.com > > > On Thu, 19 Mar 2026 at 12:54 AM, Nathan Bossart <[email protected]> > wrote: >> >> Committed. >> >> -- >> nathan
Hi Nathan, This fix was committed as ec80215c033, but it got reverted along with 7ca548f23a6 (the revert of pg_dumpall's non-text output format support) as collateral damage: the option-parsing block it touched had been restructured by that feature, so the revert took this change down with it even though it has nothing to do with non-text formats. Re-attaching the same fix, unchanged, rebased on the current master. We can back-port till v19. -- Thanks and Regards Mahendra Singh Thalor EnterpriseDB: http://www.enterprisedb.com
From 98d8df3bb71eeeda21b99d620d8611f1dfc6d75e Mon Sep 17 00:00:00 2001 From: Mahendra Singh Thalor <[email protected]> Date: Tue, 14 Jul 2026 17:36:18 +0530 Subject: [PATCH] pg_restore: Remove unnecessary strlen() calls in options parsing Unlike pg_dump and pg_dumpall, pg_restore first checks whether the argument passed to --format, --host, and --port is empty before setting the corresponding variable. Consequently, pg_restore does not error if given an empty format name, whereas pg_dump and pg_dumpall do. Empty arguments for --host and --port are ignored by all three applications, so this produces no functionality changes there. Add a test covering the new empty-format error. Originally committed as ec80215c033, and inadvertently undone by 7ca548f23a6 as collateral of an unrelated revert; restored here unchanged. Discussion: https://postgr.es/m/CAKYtNApkh%3DVy2DpNRCnEJmPpxNuksbAh_QBav%3D2fLmVjBhGwFw%40mail.gmail.com --- src/bin/pg_dump/pg_restore.c | 9 +++------ src/bin/pg_dump/t/001_basic.pl | 7 ++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 8be609c5170..f8074f33d5b 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -194,12 +194,10 @@ main(int argc, char **argv) opts->filename = pg_strdup(optarg); break; case 'F': - if (strlen(optarg) != 0) - opts->formatName = pg_strdup(optarg); + opts->formatName = pg_strdup(optarg); break; case 'h': - if (strlen(optarg) != 0) - opts->cparams.pghost = pg_strdup(optarg); + opts->cparams.pghost = pg_strdup(optarg); break; case 'j': /* number of restore jobs */ @@ -230,8 +228,7 @@ main(int argc, char **argv) break; case 'p': - if (strlen(optarg) != 0) - opts->cparams.pgport = pg_strdup(optarg); + opts->cparams.pgport = pg_strdup(optarg); break; case 'R': /* no-op, still accepted for backwards compatibility */ diff --git a/src/bin/pg_dump/t/001_basic.pl b/src/bin/pg_dump/t/001_basic.pl index d89ba4a4ceb..c12b93a01af 100644 --- a/src/bin/pg_dump/t/001_basic.pl +++ b/src/bin/pg_dump/t/001_basic.pl @@ -205,7 +205,12 @@ command_fails_like( command_fails_like( [ 'pg_restore', '-f -', '-F', 'garbage' ], qr/\Qpg_restore: error: unrecognized archive format "garbage";\E/, - 'pg_dump: unrecognized archive format'); + 'pg_restore: unrecognized archive format'); + +command_fails_like( + [ 'pg_restore', '-f -', '-F', '' ], + qr/\Qpg_restore: error: unrecognized archive format "";\E/, + 'pg_restore: empty archive format'); command_fails_like( [ 'pg_dump', '--on-conflict-do-nothing' ], -- 2.52.0
