
Hi all,

I came across this comment in exec_append_initialize_next....

/* ----------------
*		initialize the scan
*		(and update the range table appropriately)
*		  (doesn't this leave the range table hosed for anybody upstream
*		   of the Append node??? - jolly )
* ----------------
*/

I took a stab at guessing what this might mean, and ran the following
test.
It looks like a bug. Can anybody shed any light on whether the above
comment is likely to relate to this bug, and is there anybody who is
so intimate with this code that they are willing to fix it?

# Comment: b and c inherit from a. d inherits from b.
chrisb=# begin work;
BEGIN
chrisb=# select aa from a;
 aa 
----
(0 rows)

chrisb=# select aa from b;
 aa  
-----
 ppp
(1 row)

chrisb=# select aa from c;
  aa   
-------
 cmore
(1 row)

chrisb=# select aa from d;
  aa   
-------
 dmore
(1 row)

chrisb=# select aa from a*;
  aa   
-------
 ppp
 cmore
 dmore
(3 rows)

chrisb=# declare cu cursor for select aa from a*;
SELECT
chrisb=# fetch forward 1 in cu;
 aa  
-----
 ppp
(1 row)

chrisb=# fetch forward 1 in cu;
  aa   
-------
 cmore
(1 row)

chrisb=# fetch backward 1 in cu;
 aa 
----
(0 rows)

Tue, 08 Feb 2000 16:56:06 +1100
Chris Bitmead <chrisb@nimrod.itg.telstra.com.au>
Bug in cursors??
> -----Original Message-----
> From: owner-pgsql-hackers@postgreSQL.org
> [mailto:owner-pgsql-hackers@postgreSQL.org]On Behalf Of Chris Bitmead
> 
> Hi all,
> 
> I came across this comment in exec_append_initialize_next....
> 
> /* ----------------
> *		initialize the scan
> *		(and update the range table appropriately)
> *		  (doesn't this leave the range table hosed for 
> anybody upstream
> *		   of the Append node??? - jolly )
> * ----------------
> */
> 
> I took a stab at guessing what this might mean, and ran the following
> test.
> It looks like a bug. Can anybody shed any light on whether the above
> comment is likely to relate to this bug, and is there anybody who is
> so intimate with this code that they are willing to fix it?
>
 
I've forgotten to apply the following patch.
Without the patch,backward sequential scan is impossible
after reaching EOF. 
It may be one of the cause.

Regards.

*** access/heap/heapam.c.orig	Mon Aug  2 14:56:36 1999
--- access/heap/heapam.c	Tue Nov  9 12:59:48 1999
***************
*** 775,782 ****
  		if (scan->rs_ptup.t_data == scan->rs_ctup.t_data &&
  			BufferIsInvalid(scan->rs_pbuf))
  		{
- 			if (BufferIsValid(scan->rs_nbuf))
- 				ReleaseBuffer(scan->rs_nbuf);
  			return NULL;
  		}

--- 775,780 ----
***************
*** 833,842 ****
  				ReleaseBuffer(scan->rs_pbuf);
  			scan->rs_ptup.t_data = NULL;
  			scan->rs_pbuf = InvalidBuffer;
- 			if (BufferIsValid(scan->rs_nbuf))
- 				ReleaseBuffer(scan->rs_nbuf);
- 			scan->rs_ntup.t_data = NULL;
- 			scan->rs_nbuf = InvalidBuffer;
  			return NULL;
  		}

--- 831,836 ----
***************
*** 855,862 ****
  		if (scan->rs_ctup.t_data == scan->rs_ntup.t_data &&
  			BufferIsInvalid(scan->rs_nbuf))
  		{
- 			if (BufferIsValid(scan->rs_pbuf))
- 				ReleaseBuffer(scan->rs_pbuf);
  			HEAPDEBUG_3;		/* heap_getnext returns NULL at end */
  			return NULL;
  		}
--- 849,854 ----
***************
*** 915,924 ****
  				ReleaseBuffer(scan->rs_nbuf);
  			scan->rs_ntup.t_data = NULL;
  			scan->rs_nbuf = InvalidBuffer;
- 			if (BufferIsValid(scan->rs_pbuf))
- 				ReleaseBuffer(scan->rs_pbuf);
- 			scan->rs_ptup.t_data = NULL;
- 			scan->rs_pbuf = InvalidBuffer;
  			HEAPDEBUG_6;		/* heap_getnext returning EOS */
  			return NULL;
  		}
--- 907,912 ----

Tue, 8 Feb 2000 17:44:32 +0900
"Hiroshi Inoue" <Inoue@tpf.co.jp>
RE: [HACKERS] Bug in cursors??

Hiroshi, do you need this applied?


>  
> I've forgotten to apply the following patch.
> Without the patch,backward sequential scan is impossible
> after reaching EOF. 
> It may be one of the cause.
> 
> Regards.
> 
> *** access/heap/heapam.c.orig	Mon Aug  2 14:56:36 1999
> --- access/heap/heapam.c	Tue Nov  9 12:59:48 1999
> ***************
> *** 775,782 ****
>   		if (scan->rs_ptup.t_data == scan->rs_ctup.t_data &&
>   			BufferIsInvalid(scan->rs_pbuf))
>   		{
> - 			if (BufferIsValid(scan->rs_nbuf))
> - 				ReleaseBuffer(scan->rs_nbuf);
>   			return NULL;
>   		}
> 
> --- 775,780 ----
> ***************
> *** 833,842 ****
>   				ReleaseBuffer(scan->rs_pbuf);
>   			scan->rs_ptup.t_data = NULL;
>   			scan->rs_pbuf = InvalidBuffer;
> - 			if (BufferIsValid(scan->rs_nbuf))
> - 				ReleaseBuffer(scan->rs_nbuf);
> - 			scan->rs_ntup.t_data = NULL;
> - 			scan->rs_nbuf = InvalidBuffer;
>   			return NULL;
>   		}
> 
> --- 831,836 ----
> ***************
> *** 855,862 ****
>   		if (scan->rs_ctup.t_data == scan->rs_ntup.t_data &&
>   			BufferIsInvalid(scan->rs_nbuf))
>   		{
> - 			if (BufferIsValid(scan->rs_pbuf))
> - 				ReleaseBuffer(scan->rs_pbuf);
>   			HEAPDEBUG_3;		/* heap_getnext returns NULL at end */
>   			return NULL;
>   		}
> --- 849,854 ----
> ***************
> *** 915,924 ****
>   				ReleaseBuffer(scan->rs_nbuf);
>   			scan->rs_ntup.t_data = NULL;
>   			scan->rs_nbuf = InvalidBuffer;
> - 			if (BufferIsValid(scan->rs_pbuf))
> - 				ReleaseBuffer(scan->rs_pbuf);
> - 			scan->rs_ptup.t_data = NULL;
> - 			scan->rs_pbuf = InvalidBuffer;
>   			HEAPDEBUG_6;		/* heap_getnext returning EOS */
>   			return NULL;
>   		}
> --- 907,912 ----
> 
> ************
> 


-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Tue, 8 Feb 2000 04:16:02 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] Bug in cursors??
> -----Original Message-----
> From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
> Sent: Tuesday, February 08, 2000 6:16 PM
> 
> Hiroshi, do you need this applied?
>

Oops,this patch is old,sorry.
Another patch may be needed.

DO you think this patch should also be applied to REL tree ?
If so,could you please apply it to both trees ?
Otherwise I would commit it only to current tree myself.

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp

Tue, 8 Feb 2000 19:12:52 +0900
"Hiroshi Inoue" <Inoue@tpf.co.jp>
RE: [HACKERS] Bug in cursors??
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> > -----Original Message-----
> > From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
> > Sent: Tuesday, February 08, 2000 6:16 PM
> > 
> > Hiroshi, do you need this applied?
> >
> 
> Oops,this patch is old,sorry.
> Another patch may be needed.
> 
> DO you think this patch should also be applied to REL tree ?
> If so,could you please apply it to both trees ?
> Otherwise I would commit it only to current tree myself.

I don't think we are doing more 6.5.* releases

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Tue, 8 Feb 2000 09:16:07 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] Bug in cursors??
> -----Original Message-----
> From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
> 
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
> > > -----Original Message-----
> > > From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
> > > Sent: Tuesday, February 08, 2000 6:16 PM
> > > 
> > > Hiroshi, do you need this applied?
> > >
> > 
> > Oops,this patch is old,sorry.
> > Another patch may be needed.
> > 
> > DO you think this patch should also be applied to REL tree ?
> > If so,could you please apply it to both trees ?
> > Otherwise I would commit it only to current tree myself.
> 
> I don't think we are doing more 6.5.* releases
>

OK,I have committed the patch to current tree.

BTW I found the following TODO item.
* update pg_class.relhasindex during vacuum when all indexes are dropped

Seems vacuum has done so from the first.

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp

Wed, 9 Feb 2000 15:24:41 +0900
"Hiroshi Inoue" <Inoue@tpf.co.jp>
RE: [HACKERS] Bug in cursors??
> > > If so,could you please apply it to both trees ?
> > > Otherwise I would commit it only to current tree myself.
> > 
> > I don't think we are doing more 6.5.* releases
> >
> 
> OK,I have committed the patch to current tree.
> 
> BTW I found the following TODO item.
> * update pg_class.relhasindex during vacuum when all indexes are dropped
> 
> Seems vacuum has done so from the first.

Yes, I see.  TODO updated.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Wed, 9 Feb 2000 15:09:02 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] Bug in cursors??