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

From Robert Haas
Subject Re: [PATCH] Make "psql -1 < file.sql" work as with "-f"
Date
Msg-id CA+Tgmoajgm3SqhRU1rBhPa7TY3ND_Ye1u97hAn8BRhr_Zomi5g@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Make "psql -1 < file.sql" work as with "-f"  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
On Fri, May 10, 2013 at 9:50 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
> On 8/9/12 9:08 AM, Robert Haas wrote:
>> On Wed, Aug 8, 2012 at 6:50 PM, David Fetter <david@fetter.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



pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Re: Proposal to add --single-row to psql
Next
From: Tom Lane
Date:
Subject: Re: Proposal to add --single-row to psql