Re: pg_restore --format= option(without any value) should report an error as pg_dump is reporting an error

From: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
To: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_restore --format= option(without any value) should report an error as pg_dump is reporting an error
Date: 2026-03-15 13:44:57
Message-ID: CAFC+b6op5Y6CbAqSmUUPj-0z8=A7QR93Vppv4ko1wLqftY+GjA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Mar 15, 2026 at 9:48 AM Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
wrote:

> On Sun, 13 Apr 2025 at 18:32, Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
> wrote:
> >
> > Hi,
> > With "pg_restore --format=", we are not giving any error because in
> code, we are checking length of arg but pg_dump is reporting an error for
> the same option.
> >
> > For the consistency purpose, pg_dump and pg_restore both should report
> an error for the test case below.
> >
> > Ex: (output after this patch)but before this patch, below command is
> passing.
> > /pg_restore x1 -d postgres -j 10 -C --verbose --format=
> > pg_restore: error: unrecognized archive format ""; please specify "c",
> "d", or "t"
> >
> > Here, I am attaching a patch which is fixing the same. I added 2 TAP
> tests also for invalid options.
> >
> > Note: We have 2 more options in pg_restore code which validate the
> option if arg has non zero length. I will prepare patches for both(--host
> and --port). We need to add some validate function also for both these
> options.
> >
> > --
> > Thanks and Regards
> > Mahendra Singh Thalor
> > EnterpriseDB: http://www.enterprisedb.com
>
> Hi all,
> Here I am attaching a re-based patch.
>
> I think we should sync behaviour with pg_dump and pg_restore. Please
> review this patch and let me know feedback.
>

+1 , patch LGTM, i think this also needs backpatching,
but i think in the TAP test, change the test_name from pg_dump to
pg_restore.

diff --git a/src/bin/pg_dump/t/001_basic.pl b/src/bin/pg_dump/t/001_basic.pl
index bf661910c66..3914fb158c2 100755
--- a/src/bin/pg_dump/t/001_basic.pl
+++ b/src/bin/pg_dump/t/001_basic.pl
@@ -204,12 +204,12 @@ command_fails_like(
command_fails_like(
[ 'pg_restore', '-f -', '--format='],
qr/\Qpg_restore: error: unrecognized archive format "";\E/,
- 'pg_dump: unrecognized archive format empty string');
+ 'pg_restore: unrecognized archive format empty string');

command_fails_like(
[ 'pg_restore', '-f -', '-F', 'p' ],
qr/\Qpg_restore: error: archive format "p" is not supported; please
use psql\E/,
- 'pg_dump: unrecognized archive format p|plain');
+ 'pg_restore: unrecognized archive format p|plain');

command_fails_like(
[ 'pg_dump', '--on-conflict-do-nothing' ],

--
Thanks,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2026-03-15 13:50:04 Re: More speedups for tuple deformation
Previous Message Jim Jones 2026-03-15 12:57:59 Re: WIP - xmlvalidate implementation from TODO list