BUG #6360: with hold cursor, cause function executed twice and wrong results

Поиск
Список
Период
Сортировка
От wcting163@163.com
Тема BUG #6360: with hold cursor, cause function executed twice and wrong results
Дата
Msg-id E1RfTzu-00024G-Dv@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #6360: with hold cursor, cause function executed twice and wrong results  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      6360
Logged by:          ctwang
Email address:      wcting163@163.com
PostgreSQL version: 9.0.5
Operating system:   linux 2.6.18-128.7AXS3=20
Description:=20=20=20=20=20=20=20=20

create table test_execute(id int,name varchar(40));
insert into test_execute values(1,'jack');

create or replace function p_test_execute() returns void
as
$$
begin
        raise notice 'hello world';
        update test_execute set id=3Did*2;
end;
$$ LANGUAGE plpgsql;

begin;
declare JDBC_CURS_1 cursor with hold for select p_test_execute() from
test_execute;
fetch 50 from JDBC_CURS_1;
NOTICE:  hello world

end;
NOTICE:  hello world
COMMIT

select * from test_execute;
 id | name
----+------
  4 | jack


I expect id =3D 2, but it is **4** instead,

The reason is that the function p_test_execute is executed twice, when
*fetch*, it is first executed, and when transaction commit, because the
cursor is a *holdable* cursor, it is executed again.

I read the code, for holdable cursor, when commit, following call will
execute:
 CommitHoldablePortals-->PersistHoldablePortal-->ExecutorRewind

Is *ExecutorRewind* necessary, is it the root of this bug?
Does *ExecutorRewind* cause plan re-execute?

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

Предыдущее
От: Devrim GÜNDÜZ
Дата:
Сообщение: Re: BUG #6341: Packaging - virtual provides "postgres" without version
Следующее
От: Phil Sorber
Дата:
Сообщение: converting between infinity timestamp and float8 (epoch)