88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.92 2007/01/05 22:19:22 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.93 2007/01/20 18:43:35 neilc Exp $
1212 *
1313 * NOTES
1414 * This file contains only the public interface routines.
@@ -185,7 +185,7 @@ hashgettuple(PG_FUNCTION_ARGS)
185185 * appropriate direction. If we haven't done so yet, we call a routine to
186186 * get the first item in the scan.
187187 */
188- if (ItemPointerIsValid (& (scan -> currentItemData )))
188+ if (ItemPointerIsValid (& (so -> hashso_curpos )))
189189{
190190/*
191191 * Check to see if we should kill the previously-fetched tuple.
@@ -195,7 +195,7 @@ hashgettuple(PG_FUNCTION_ARGS)
195195/*
196196 * Yes, so mark it by setting the LP_DELETE bit in the item flags.
197197 */
198- offnum = ItemPointerGetOffsetNumber (& (scan -> currentItemData ));
198+ offnum = ItemPointerGetOffsetNumber (& (so -> hashso_curpos ));
199199page = BufferGetPage (so -> hashso_curbuf );
200200PageGetItemId (page ,offnum )-> lp_flags |=LP_DELETE ;
201201
@@ -222,7 +222,7 @@ hashgettuple(PG_FUNCTION_ARGS)
222222{
223223while (res )
224224{
225- offnum = ItemPointerGetOffsetNumber (& (scan -> currentItemData ));
225+ offnum = ItemPointerGetOffsetNumber (& (so -> hashso_curpos ));
226226page = BufferGetPage (so -> hashso_curbuf );
227227if (!ItemIdDeleted (PageGetItemId (page ,offnum )))
228228break ;
@@ -269,7 +269,7 @@ hashgetmulti(PG_FUNCTION_ARGS)
269269/*
270270 * Start scan, or advance to next tuple.
271271 */
272- if (ItemPointerIsValid (& (scan -> currentItemData )))
272+ if (ItemPointerIsValid (& (so -> hashso_curpos )))
273273res = _hash_next (scan ,ForwardScanDirection );
274274else
275275res = _hash_first (scan ,ForwardScanDirection );
@@ -284,7 +284,7 @@ hashgetmulti(PG_FUNCTION_ARGS)
284284Page page ;
285285OffsetNumber offnum ;
286286
287- offnum = ItemPointerGetOffsetNumber (& (scan -> currentItemData ));
287+ offnum = ItemPointerGetOffsetNumber (& (so -> hashso_curpos ));
288288page = BufferGetPage (so -> hashso_curbuf );
289289if (!ItemIdDeleted (PageGetItemId (page ,offnum )))
290290break ;
@@ -325,6 +325,10 @@ hashbeginscan(PG_FUNCTION_ARGS)
325325so -> hashso_bucket_valid = false;
326326so -> hashso_bucket_blkno = 0 ;
327327so -> hashso_curbuf = so -> hashso_mrkbuf = InvalidBuffer ;
328+ /* set positions invalid (this will cause _hash_first call) */
329+ ItemPointerSetInvalid (& (so -> hashso_curpos ));
330+ ItemPointerSetInvalid (& (so -> hashso_mrkpos ));
331+
328332scan -> opaque = so ;
329333
330334/* register scan in case we change pages it's using */
@@ -360,11 +364,11 @@ hashrescan(PG_FUNCTION_ARGS)
360364if (so -> hashso_bucket_blkno )
361365_hash_droplock (rel ,so -> hashso_bucket_blkno ,HASH_SHARE );
362366so -> hashso_bucket_blkno = 0 ;
363- }
364367
365- /* set positions invalid (this will cause _hash_first call) */
366- ItemPointerSetInvalid (& (scan -> currentItemData ));
367- ItemPointerSetInvalid (& (scan -> currentMarkData ));
368+ /* set positions invalid (this will cause _hash_first call) */
369+ ItemPointerSetInvalid (& (so -> hashso_curpos ));
370+ ItemPointerSetInvalid (& (so -> hashso_mrkpos ));
371+ }
368372
369373/* Update scan key, if a new one is given */
370374if (scankey && scan -> numberOfKeys > 0 )
@@ -406,10 +410,6 @@ hashendscan(PG_FUNCTION_ARGS)
406410_hash_droplock (rel ,so -> hashso_bucket_blkno ,HASH_SHARE );
407411so -> hashso_bucket_blkno = 0 ;
408412
409- /* be tidy */
410- ItemPointerSetInvalid (& (scan -> currentItemData ));
411- ItemPointerSetInvalid (& (scan -> currentMarkData ));
412-
413413pfree (so );
414414scan -> opaque = NULL ;
415415
@@ -430,14 +430,14 @@ hashmarkpos(PG_FUNCTION_ARGS)
430430if (BufferIsValid (so -> hashso_mrkbuf ))
431431_hash_dropbuf (rel ,so -> hashso_mrkbuf );
432432so -> hashso_mrkbuf = InvalidBuffer ;
433- ItemPointerSetInvalid (& (scan -> currentMarkData ));
433+ ItemPointerSetInvalid (& (so -> hashso_mrkpos ));
434434
435- /* bump pin count oncurrentItemData and copy tocurrentMarkData */
436- if (ItemPointerIsValid (& (scan -> currentItemData )))
435+ /* bump pin count oncurrent buffer and copy tomarked buffer */
436+ if (ItemPointerIsValid (& (so -> hashso_curpos )))
437437{
438438IncrBufferRefCount (so -> hashso_curbuf );
439439so -> hashso_mrkbuf = so -> hashso_curbuf ;
440- scan -> currentMarkData = scan -> currentItemData ;
440+ so -> hashso_mrkpos = so -> hashso_curpos ;
441441}
442442
443443PG_RETURN_VOID ();
@@ -457,14 +457,14 @@ hashrestrpos(PG_FUNCTION_ARGS)
457457if (BufferIsValid (so -> hashso_curbuf ))
458458_hash_dropbuf (rel ,so -> hashso_curbuf );
459459so -> hashso_curbuf = InvalidBuffer ;
460- ItemPointerSetInvalid (& (scan -> currentItemData ));
460+ ItemPointerSetInvalid (& (so -> hashso_curpos ));
461461
462- /* bump pin count oncurrentMarkData and copy tocurrentItemData */
463- if (ItemPointerIsValid (& (scan -> currentMarkData )))
462+ /* bump pin count onmarked buffer and copy tocurrent buffer */
463+ if (ItemPointerIsValid (& (so -> hashso_mrkpos )))
464464{
465465IncrBufferRefCount (so -> hashso_mrkbuf );
466466so -> hashso_curbuf = so -> hashso_mrkbuf ;
467- scan -> currentItemData = scan -> currentMarkData ;
467+ so -> hashso_curpos = so -> hashso_mrkpos ;
468468}
469469
470470PG_RETURN_VOID ();