Re: psql FETCH_COUNT feature does not work with combined queries - Mailing list pgsql-hackers

From David Johnston
Subject Re: psql FETCH_COUNT feature does not work with combined queries
Date
Msg-id 159494088831.807.13347475451859514773.pgcf@coridan.postgresql.org
Whole thread Raw
In response to Re: psql FETCH_COUNT feature does not work with combined queries  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: psql FETCH_COUNT feature does not work with combined queries
List pgsql-hackers
The following review has been posted through the commitfest application:
make installcheck-world:  not tested
Implements feature:       not tested
Spec compliant:           not tested
Documentation:            tested, passed

Fabien,

There is a minor typo (works -> work) but overall I'm not a fan of the wording.

Instead of a note maybe add a paragraph stating:

"This setting is ignored when multiple statements are sent to the server as a single command (i.e., via the -c command
lineoption or the \; meta-command).  Additionally, it is possible for certain combinations of statements sent in that
mannerto instead return no results, or even be ignored, instead of returning the result set of the last query.  In
short,when FETCH_COUNT is non-zero, and you send a multi-statement command to the server, the results are undefined.
Thiscombination in presently allowed for backward compatibility."
 

I would suggest, however, adding some tests in src/test/psql.sql demonstrating the broken behavior.  A potentially
usefultest setup would be:
 
create temp table testtbl (idx int, div int);
insert into testtbl (1,1), (2,1),(3,1),(4,0),(5,1);
and combine that with FETCH_COUNT 3

Some other things I tried, with and without FETCH_COUNT:

begin \; select 2 \; commit \; select 1 / div from (select div from testtbl order by idx) as src;
select 1/0 \; select 1 / div from (select div from testtbl where div <> 0 order by idx) as src;
begin \; select 2 \; select 1 \; commit;
begin \; select 2 \; select 1;
commit;

I'm not sure how to go about getting a equivalent result of "select pg_sleep(2) \; select 1;" not sleeping.  If I put
select1/0 instead of pg_sleep I get an error and any DML seems to end up working just fine (minus actual batch
fetching)
update testtbl set val = 2 \; select 1; --result (1)

David J.

The new status of this patch is: Waiting on Author

pgsql-hackers by date:

Previous
From: "Hsu, John"
Date:
Subject: Re: Physical slot restart_lsn advances incorrectly requiring restore from archive
Next
From: Alvaro Herrera
Date:
Subject: Re: psql FETCH_COUNT feature does not work with combined queries