Re: proposal: pg_restore --convert-to-text

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: José Arthur Benetasso Villanova <jose(dot)arthur(at)gmail(dot)com>, "Imai, Yoshikazu" <imai(dot)yoshikazu(at)jp(dot)fujitsu(dot)com>, Euler Taveira <euler(at)timbira(dot)com(dot)br>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andreas Karlsson <andreas(at)proxel(dot)se>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: pg_restore --convert-to-text
Date: 2019-06-12 17:02:01
Message-ID: 20190612170201.GA11881@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019-Jun-12, Daniel Verite wrote:

> While testing pg_restore on v12, I'm stumbling on this too.

Thanks for testing.

> pg_restore without argument fails like that:
>
> $ pg_restore
> pg_restore: error: one of -d/--dbname and -f/--file must be specified
>
> But that's not right since "pg_restore -l dumpfile" would work.

So you suggest that it should be

pg_restore: error: one of -d/--dbname, -f/--file and -l/--list must be specified
?

> Also, in the doc at https://www.postgresql.org/docs/devel/app-pgrestore.html
> the synopsis is
>
> pg_restore [connection-option...] [option...] [filename]
>
> so the invocation without argument seems possible while in fact
> it's not.

So you suggest that it should be
pg_restore [connection-option...] { -d | -f | -l } [option...] [filename]
?

Maybe we should do that and split out the "output destination options"
from other options in the list of options, to make this clearer; see
a proposal after my sig.

> In particular saying that --file must be specified leaves me with
> no idea what file it's talking about: the dumpfile or the output file?

If you want to submit a patch (for pg13) to rename --file to
--output-file (and make --file an alias of that), you're welcome to, and
endure the resulting discussion and possible rejection. I don't think
we're changing that at this point of pg12.

> My first inclination is to transform "pg_restore dumpfile" into
> "pg_restore -f dumpfile", which does nothing but wait
> (it waits for the dumpfile on the standard input, before
> I realize that it's not working and hit ^C. Fortunately it doesn't
> overwrite the dumpfile with an empty output).

Would you have it emit to stderr a message saying "reading standard
input" when it is?

> So the change in v12 removes the standard output as default,
> but does not remove the standard input as default.
> Isn't that weird?

I don't think they have the same surprise factor.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Usage:
pg_restore [connection-option...] { -d | -f | -l } [option...] [filename]

General options:
-F, --format=c|d|t backup file format (should be automatic)
-v, --verbose verbose mode
-V, --version output version information, then exit
-?, --help show this help, then exit

Output target options:
-l, --list print summarized TOC of the archive
-d, --dbname=NAME connect to database name
-f, --file=FILENAME output file name (- for stdout)

Options controlling the restore:
-a, --data-only restore only the data, no schema
-c, --clean clean (drop) database objects before recreating
...

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2019-06-12 17:42:01 Re: Race conditions with checkpointer and shutdown
Previous Message Jim Finnerty 2019-06-12 16:52:09 Re: Adaptive query optimization