Re: [PATCH] Make "psql -1 < file.sql" work as with "-f"

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: David Fetter <david(at)fetter(dot)org>, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Make "psql -1 < file.sql" work as with "-f"
Date: 2013-05-11 15:55:02
Message-ID: CA+Tgmoajgm3SqhRU1rBhPa7TY3ND_Ye1u97hAn8BRhr_Zomi5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 10, 2013 at 9:50 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> On 8/9/12 9:08 AM, Robert Haas wrote:
>> On Wed, Aug 8, 2012 at 6:50 PM, David Fetter <david(at)fetter(dot)org> wrote:
>>>> I'm wondering if perhaps -- in addition to what you've done here -- we
>>>> should make "psql -1" error out if reading from a terminal.
>>>
>>> +1 for this.
>>
>> OK, done.
>>
>> I had to revise the original patch pretty heavily before committing;
>
> My first use of 9.3beta1 in development failed because of changes
> introduced by this patch, specifically because of the newly introduced error
>
> psql: -1 is incompatible with -c and -l
>
> I'm not convinced this is correct. -c and -l are single-transaction
> actions almost by definition.
>
> This particular aspect of the change wasn't really brought up in the
> original thread. What was your thinking?

Well, I think my main thinking was to prevent it in interactive mode,
since it doesn't work in interactive mode, and then it also seemed to
make sense to prevent it in the other cases to which it does not
apply.

I think there are cases where you can detect the fact that -1 -c
wasn't actually wrapping the command in a BEGIN and an END, but I
agree it might be a bit pedantic to worry about them. There have been
previous proposals to allow multiple -c and -f options, and to allow
those to be intermingled; if we did that, then this would surely
matter. I agree that's hypothetical though since there's no patch to
do any such thing currently on the table.

Generally, I think we're too lax about detecting and complaining about
conflicting combinations of options. But I'm not going to stand here
and hold my breath if someone else feels that this particular
combination doesn't merit a complaint.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-05-11 16:27:36 Re: Proposal to add --single-row to psql
Previous Message David Fetter 2013-05-11 15:34:17 Re: Proposal to add --single-row to psql