From: spche <spche@163.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #5738: btree index search bug
Date: Mon, 1 Nov 2010 10:18:02 GMT
Message-ID: <201011011018.oA1AI2JM075862@wwwmaster.postgresql.org> (raw)
The following bug has been logged online:
Bug reference: 5738
Logged by: spche
Email address: spche@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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: spche@163.com
Subject: Re: BUG #5738: btree index search bug
In-Reply-To: <201011011018.oA1AI2JM075862@wwwmaster.postgresql.org>
References: <201011011018.oA1AI2JM075862@wwwmaster.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox