Re: BUG #19891: pg_restore ignores an explicitly empty -F argument

From: Pierre Forstmann <pierre(dot)forstmann(at)gmail(dot)com>
To: Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: imchifan(at)mail(dot)com
Subject: Re: BUG #19891: pg_restore ignores an explicitly empty -F argument
Date: 2026-11-28 15:20:27
Message-ID: fa6e2c61-ff19-48a3-89f9-a38c23c190b2@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

I  have also reproduced this on 18.7 version and on master
e87b024bfb8dd55e3049b1b6e6ab4e810cf1abc8.

I have rebuilt with your patch and run successfully: make
installcheck-world ?

I have also reviewed your code changes : LGTM.

I have set patch status to review.

Regards,

P.F.

Le 20/11/2026 à 17:58, Raja Sai pranav a écrit :
> Hi,
>
> I reproduced this on master (4a26e36f87) and attached a patch.
>
> pg_restore only kept the -F value when it was not empty, so -F ''
> looked the same as no -F at all and pg_restore went on to detect the
> format. pg_dump already rejects an empty -F ("invalid output format ""
> specified"). The patch keeps the value always, so -F '' now fails the
> same way as -F garbage:
>
> pg_restore: error: unrecognized archive format ""; please specify "c",
> "d", or "t"
>
> The patch adds a test next to the existing garbage-format test in
> src/bin/pg_dump/t/https://www.google.com/url?q=http://001_basic.pl&source=gmail&ust=1795280332268000&sa=E
> <https://www.google.com/url?q=http://001_basic.pl&source=gmail&ust=1795280332268000&sa=E>.
> The pg_dump test suites pass with the patch, and the new test fails
> without it.
>
> Regards,
> Sai Pranav
>
> On Fri, Nov 20, 2026 10:28 PM, PG Bug reporting form
> <noreply(at)postgresql(dot)org> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference:      19891
> Logged by:          Faye
> Email address: imchifan(at)mail(dot)com
> PostgreSQL version: 18.6
> Operating system:   Linux/amd64
> Description:
>
> pg_restore treats an explicitly empty -F/--format argument as
> though the
> option were absent and proceeds with archive-format
> auto-detection. With
> empty input, I get an input-file error, while another invalid
> format is
> rejected during option validation.
>
> Because -F requires an archive format and accepts only c, d, or t, an
> explicitly supplied empty value should be rejected as an unrecognized
> archive format rather than enabling auto-detection.
>
> How to repeat:
>
> Run these commands with pg_restore on PATH:
>
> ```
> pg_restore -f - -F '' </dev/null
> pg_restore -f - -F garbage </dev/null
> ```
>
> PostgreSQL 18.6 produces:
>
> ```
> pg_restore: error: input file is too short (read 0, expected 5)
> pg_restore: error: unrecognized archive format "garbage"; please
> specify
> "c", "d", or "t"
> ```
>
> The empty value should instead be rejected consistently with the other
> invalid value, identifying the empty string as an unrecognized archive
> format.
>
> The issue was reproduced with pg_restore from PostgreSQL 18.6 (Debian
> 18.6-1.pgdg13+2) on Linux/amd64. The option handler records the
> format name
> only when the argument is nonempty, so an explicitly empty
> argument remains
> indistinguishable from an omitted -F option. This occurs when
> pg_restore is
> invoked with an explicitly empty archive-format argument.
>
>
>
>
>
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Ishjaap Singh 2026-11-28 15:27:19 Re: BUG #19825: JSON_VALUE(... RETURNING <domain over json/jsonb>) loses the re-quoting of scalar strings and silent
Previous Message Raja Sai pranav 2026-11-28 15:09:17 Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance