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

From: Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>
To: 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-20 16:58:54
Message-ID: nh-70cb3a09-76af-490a-9057-9f8eddbcb1e8@google.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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.
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.
>
>
>
>
>
>
>

Attachment Content-Type Size
v1-0001-pg_restore-reject-an-empty-F-format-argument.patch text/x-patch 1.9 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message Ayush Tiwari 2026-11-20 16:58:52 Re: BUG #19631: currtid2() on a view with GROUP BY ctid crashes with XX000