plpython does not honour max-rows
Kieran McCusker <kieran.mccusker@gmail.com>
From: Kieran McCusker <kieran.mccusker@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Date: 2023-05-02T10:30:16Z
Lists: pgsql-bugs
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)
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Doc: clarify behavior of row-limit arguments in the PLs' SPI wrappers.
- b00bae2e9103 13.11 landed
- 825828956ab3 12.15 landed
- 66ab2660e078 14.8 landed
- 6489875ce6b1 16.0 landed
- 23c7aa865b32 15.3 landed
- 0e0463fc590c 11.20 landed