RE: proposal: pg_restore --convert-to-text

Imai, Yoshikazu <imai.yoshikazu@jp.fujitsu.com>

From: "Imai, Yoshikazu" <imai.yoshikazu@jp.fujitsu.com>
To: 'Euler Taveira' <euler@timbira.com.br>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andreas Karlsson <andreas@proxel.se>, "Andrew Gierth" <andrew@tao11.riddles.org.uk>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2019-02-28T02:48:22Z
Lists: pgsql-hackers
Hi,

On Tue, Feb 19, 2019 at 8:20 PM, Euler Taveira wrote:
> Em seg, 18 de fev de 2019 às 19:21, Tom Lane <tgl@sss.pgh.pa.us> escreveu:
> >
> > Euler Taveira <euler@timbira.com.br> writes:
> > > Since no one has stepped up, I took a stab at it. It will prohibit
> > > standard output unless '-f -' be specified. -l option also has the
> > > same restriction.
> >
> > Hm, don't really see the need to break -l usage here.
> >
> After thinking about it, revert it.
> 
> > Pls add to next CF, if you didn't already.
> >
> Done.

I saw the patch.

Is there no need to rewrite the Description in the Doc to state we should specify either -d or -f option?
(and also it might be better to write if -l option is given, neither -d nor -f option isn't necessarily needed.)


I also have the simple question in the code.

I thought the below if-else condition

+	if (filename && strcmp(filename, "-") == 0)
+		fn = fileno(stdout);
+	else if (filename)
 		fn = -1;
    else if (AH->FH)

can also be written by the form below.

    if (filename)
    {
        if(strcmp(filename, "-") == 0)
            fn = fileno(stdout);
        else
            fn = -1;
    }
    else if (AH->FH)

I think the former one looks like pretty, but which one is preffered?

--
Yoshikazu Imai

Commits

  1. pg_restore: Require "-f -" to mean stdout