Re: Multiple psql -c / -f options - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Multiple psql -c / -f options
Date
Msg-id 52613A1C.8070809@dunslane.net
Whole thread Raw
In response to Re: Multiple psql -c / -f options  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: Multiple psql -c / -f options  (Jim Nasby <jim@nasby.net>)
List pgsql-hackers
On 10/18/2013 02:19 AM, Fabien COELHO wrote:
>
>> IMHO the current behavior is broken:
>>
>> decibel@decina:[17:46]~/pgsql/HEAD/i$bin/psql -c 'select 1' -c 
>> 'select 2'
>> ?column?
>> ----------
>>        2
>> (1 row)
>
> Another try with one -c but with similar results:
>
>   sh> psql -c "SELECT 1; SELECT 'hello';"
>     ?column?
>     ----------
>     hello
>     (1 row)
>
>   sh> psql -V
>     psql (PostgreSQL) 9.3.1
>


It's not broken. All this behaviour is documented fairly explicitly. See 
<http://www.postgresql.org/docs/current/static/app-psql.html> For 
example, regarding Fabio's example, which is actually very different 
from Jim's, the docs say: "only the result of the last SQL command is 
returned."

If you want to argue that it should be enhanced, then do. But it's 
acting as designed and as documented.

I suspect changing this might actually have more wrinkles that you 
imagine, but I could be wrong.

Incidentally, both of you could probably achieve what you apparently 
want with:
   echo 'some sql here' | psql


cheers

andrew





pgsql-hackers by date:

Previous
From: Rajeev rastogi
Date:
Subject: COPY table FROM STDIN doesn't show count tag
Next
From: Tim Kane
Date:
Subject: Re: removing old ports and architectures