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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: imchifan(at)mail(dot)com
Subject: BUG #19891: pg_restore ignores an explicitly empty -F argument
Date: 2026-11-11 16:24:27
Message-ID: 19891-0b151c9cd5969ede@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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.

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-11-11 16:40:42 Re: BUG #19816: PL/Python SD dictionary is split by input collation in 19rc1
Previous Message Chuck Fisher 2026-11-11 16:14:58 Re: BUG #19859: pgdg download from 9/27 has does not correctly install Postgres version 15