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

From: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: pg_restore --format= option(without any value) should report an error as pg_dump is reporting an error
Date: 2025-04-13 13:02:01
Message-ID: CAKYtNApkh=Vy2DpNRCnEJmPpxNuksbAh_QBav=2fLmVjBhGwFw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v01-pg_restore-format-option-should-validate-all-values.patch application/octet-stream 2.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message 贾明伟 2025-04-13 13:17:36 Re: CSN snapshots in hot standby
Previous Message Álvaro Herrera 2025-04-13 12:12:05 Re: remove unnecessary explicit type conversion (to char) for appendStringInfoChar function calls