Re: unexpected psql "feature" - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: unexpected psql "feature"
Date
Msg-id alpine.DEB.2.20.1607132320170.26777@sto
Whole thread Raw
In response to Re: unexpected psql "feature"  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-hackers
Hello David,

At least we aggree that having a documentation would be an improvement:-)

On the second point:

>>  - all results should be shown, not just the last one
>
> disagree
>
> # select 1 ; select 2 ;

vs

> # select 1 \; select 2 ;
>
> Result in identical behavior seems undesirable.

In both cases there is the two same queries, so having the same results 
does not strike me as "undesirable", on the contrary.

> At least now if you want to discard all intermediate work and just show 
> the last statement you can do so without going to any great lengths. If 
> you really want both results don't use "\;".  This makes even more sense 
> when the earlier statements are DML instead of SELECT.

Hmmm. I do not buy this "\; executes a statement but does not show the 
results" as a sane and expected behavior.

I think that the underlying and only reason it behaves like this is that 
at the protocol level one can send a batch of queries in one go, but for 
the simple "PQexec" function just one result is returned, the last one was 
chosen probably as a marker that they were all executed, and that is all.

So I see this as a low-level simplified API detail which has an unforeseen 
user impact.

-- 
Fabien.



pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: pgbench - allow to store select results into variables
Next
From: Tom Lane
Date:
Subject: Re: unexpected psql "feature"