Hi
I came across this when developing a sampling function using plpy.execute that needs to be able to sample zero rows. What actually happens is that zero is ignored for max-rows and all rows are returned. Test case below:-
Many thanks
Kieran
drop table if exists _test_max_rows;
create table _test_max_rows (i integer);
insert into _test_max_rows
select *
from generate_series(1, 100);
create or replace function plpython3u_execute_max_row(max_rows integer)
returns setof integer
language plpython3u
as $$
for row in plpy.execute('select * from _test_max_rows', max_rows):
yield row['i']
$$;
-- Correctly returns 10 rows
select * from plpython3u_execute_max_row(10);
-- Incorrectly returns all 100 rows
select * from plpython3u_execute_max_row(0)