pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #5738: btree index search bug
2+ messages / 2 participants
[nested] [flat]

* BUG #5738: btree index search bug
@ 2010-11-01 10:18 spche <spche@163.com>
  2010-11-01 14:26 ` Re: BUG #5738: btree index search bug Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: spche @ 2010-11-01 10:18 UTC (permalink / raw)
  To: pgsql-bugs


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.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #5738: btree index search bug
  2010-11-01 10:18 BUG #5738: btree index search bug spche <spche@163.com>
@ 2010-11-01 14:26 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2010-11-01 14:26 UTC (permalink / raw)
  To: spche <spche@163.com>; +Cc: pgsql-bugs

"spche" <spche@163.com> writes:
> Description:        btree index search bug

I see no bug here.  The cursor is opened at a time when there is one
row with a=3, so it can find only that one row because of its snapshot.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2010-11-01 14:26 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-11-01 10:18 BUG #5738: btree index search bug spche <spche@163.com>
2010-11-01 14:26 ` Tom Lane <tgl@sss.pgh.pa.us>

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