plpython does not honour max-rows

Поиск
Список
Период
Сортировка
От Kieran McCusker
Тема plpython does not honour max-rows
Дата
Msg-id CAGgUQ6H6qYScctOhktQ9HLFDDoafBKHyUgJbZ6q_dOApnzNTXg@mail.gmail.com
обсуждение исходный текст
Ответы Re: plpython does not honour max-rows  (Daniel Gustafsson <daniel@yesql.se>)
Список 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)

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tobias Bussmann
Дата:
Сообщение: Re: pg_basebackup: errors on macOS on directories with ".DS_Store" files
Следующее
От: Daniel Gustafsson
Дата:
Сообщение: Re: pg_basebackup: errors on macOS on directories with ".DS_Store" files