Skip site navigation (1) Skip section navigation (2)

BUG #5738: btree index search bug

From: "spche" <spche(at)163(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5738: btree index search bug
Date: 2010-11-01 10:18:02
Message-ID: 201011011018.oA1AI2JM075862@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      5738
Logged by:          spche
Email address:      spche(at)163(dot)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.

Responses

pgsql-bugs by date

Next:From: Heikki LinnakangasDate: 2010-11-01 13:31:49
Subject: ecpg preprocessor regression in 9.0
Previous:From: John R PierceDate: 2010-11-01 04:00:50
Subject: Re: BUG #5737: LIKE and ILIKE strange behaviour

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group