The following bug has been logged online: Bug reference: 5738 Logged by: spche Email address: sp...@163.com PostgreSQL version: 9.01 Operating system: Winxp Description: btree index search bug Details:
create table a (a int); create index a_a on a(a); insert into a values(1); insert into a values(2); insert into a select * from a; insert into a select * from a; insert into a select * from a; insert into a select * from a; insert into a select * from a; insert into a select * from a; insert into a select * from a; insert into a select * from a; insert into a select * from a; insert into a select * from a; insert into a select * from a; insert into a select * from a; delete from a where a=3; CREATE or replace FUNCTION aa() RETURNS integer AS $$ DECLARE curs2 cursor for SELECT a FROM a where a=3; rowv1 integer DEFAULT 0; rowv2 integer DEFAULT 32; cou1 integer DEFAULT 0; BEGIN insert into a values(3); OPEN curs2; FETCH curs2 INTO rowv1; IF FOUND THEN cou1 := cou1 + 1 ; END IF; insert into a values(3); insert into a values(3); insert into a values(3); --update a set a=4 where a=3; FETCH curs2 INTO rowv2; IF FOUND THEN cou1 := cou1 + 1 ; END IF; FETCH curs2 INTO rowv2; IF FOUND THEN cou1 := cou1 + 1 ; END IF; FETCH curs2 INTO rowv2; IF FOUND THEN cou1 := cou1 + 1 ; END IF; close curs2; RETURN cou1; END; $$ LANGUAGE plpgsql; select aa(); the result is 1; the index scan is not updated; because static bool _bt_readpage(IndexScanDesc scan, ScanDirection dir, OffsetNumber offnum) copy a old version, and not update when new version come. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs