8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
* NOTES
14
14
* This file contains only the public interface routines.
@@ -185,7 +185,7 @@ hashgettuple(PG_FUNCTION_ARGS)
185
185
* appropriate direction. If we haven't done so yet, we call a routine to
186
186
* get the first item in the scan.
187
187
*/
188
- if (ItemPointerIsValid (& (scan -> currentItemData )))
188
+ if (ItemPointerIsValid (& (so -> hashso_curpos )))
189
189
{
190
190
/*
191
191
* Check to see if we should kill the previously-fetched tuple.
@@ -195,7 +195,7 @@ hashgettuple(PG_FUNCTION_ARGS)
195
195
/*
196
196
* Yes, so mark it by setting the LP_DELETE bit in the item flags.
197
197
*/
198
- offnum = ItemPointerGetOffsetNumber (& (scan -> currentItemData ));
198
+ offnum = ItemPointerGetOffsetNumber (& (so -> hashso_curpos ));
199
199
page = BufferGetPage (so -> hashso_curbuf );
200
200
PageGetItemId (page ,offnum )-> lp_flags |=LP_DELETE ;
201
201
@@ -222,7 +222,7 @@ hashgettuple(PG_FUNCTION_ARGS)
222
222
{
223
223
while (res )
224
224
{
225
- offnum = ItemPointerGetOffsetNumber (& (scan -> currentItemData ));
225
+ offnum = ItemPointerGetOffsetNumber (& (so -> hashso_curpos ));
226
226
page = BufferGetPage (so -> hashso_curbuf );
227
227
if (!ItemIdDeleted (PageGetItemId (page ,offnum )))
228
228
break ;
@@ -269,7 +269,7 @@ hashgetmulti(PG_FUNCTION_ARGS)
269
269
/*
270
270
* Start scan, or advance to next tuple.
271
271
*/
272
- if (ItemPointerIsValid (& (scan -> currentItemData )))
272
+ if (ItemPointerIsValid (& (so -> hashso_curpos )))
273
273
res = _hash_next (scan ,ForwardScanDirection );
274
274
else
275
275
res = _hash_first (scan ,ForwardScanDirection );
@@ -284,7 +284,7 @@ hashgetmulti(PG_FUNCTION_ARGS)
284
284
Page page ;
285
285
OffsetNumber offnum ;
286
286
287
- offnum = ItemPointerGetOffsetNumber (& (scan -> currentItemData ));
287
+ offnum = ItemPointerGetOffsetNumber (& (so -> hashso_curpos ));
288
288
page = BufferGetPage (so -> hashso_curbuf );
289
289
if (!ItemIdDeleted (PageGetItemId (page ,offnum )))
290
290
break ;
@@ -325,6 +325,10 @@ hashbeginscan(PG_FUNCTION_ARGS)
325
325
so -> hashso_bucket_valid = false;
326
326
so -> hashso_bucket_blkno = 0 ;
327
327
so -> 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
+
328
332
scan -> opaque = so ;
329
333
330
334
/* register scan in case we change pages it's using */
@@ -360,11 +364,11 @@ hashrescan(PG_FUNCTION_ARGS)
360
364
if (so -> hashso_bucket_blkno )
361
365
_hash_droplock (rel ,so -> hashso_bucket_blkno ,HASH_SHARE );
362
366
so -> hashso_bucket_blkno = 0 ;
363
- }
364
367
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
+ }
368
372
369
373
/* Update scan key, if a new one is given */
370
374
if (scankey && scan -> numberOfKeys > 0 )
@@ -406,10 +410,6 @@ hashendscan(PG_FUNCTION_ARGS)
406
410
_hash_droplock (rel ,so -> hashso_bucket_blkno ,HASH_SHARE );
407
411
so -> hashso_bucket_blkno = 0 ;
408
412
409
- /* be tidy */
410
- ItemPointerSetInvalid (& (scan -> currentItemData ));
411
- ItemPointerSetInvalid (& (scan -> currentMarkData ));
412
-
413
413
pfree (so );
414
414
scan -> opaque = NULL ;
415
415
@@ -430,14 +430,14 @@ hashmarkpos(PG_FUNCTION_ARGS)
430
430
if (BufferIsValid (so -> hashso_mrkbuf ))
431
431
_hash_dropbuf (rel ,so -> hashso_mrkbuf );
432
432
so -> hashso_mrkbuf = InvalidBuffer ;
433
- ItemPointerSetInvalid (& (scan -> currentMarkData ));
433
+ ItemPointerSetInvalid (& (so -> hashso_mrkpos ));
434
434
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 )))
437
437
{
438
438
IncrBufferRefCount (so -> hashso_curbuf );
439
439
so -> hashso_mrkbuf = so -> hashso_curbuf ;
440
- scan -> currentMarkData = scan -> currentItemData ;
440
+ so -> hashso_mrkpos = so -> hashso_curpos ;
441
441
}
442
442
443
443
PG_RETURN_VOID ();
@@ -457,14 +457,14 @@ hashrestrpos(PG_FUNCTION_ARGS)
457
457
if (BufferIsValid (so -> hashso_curbuf ))
458
458
_hash_dropbuf (rel ,so -> hashso_curbuf );
459
459
so -> hashso_curbuf = InvalidBuffer ;
460
- ItemPointerSetInvalid (& (scan -> currentItemData ));
460
+ ItemPointerSetInvalid (& (so -> hashso_curpos ));
461
461
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 )))
464
464
{
465
465
IncrBufferRefCount (so -> hashso_mrkbuf );
466
466
so -> hashso_curbuf = so -> hashso_mrkbuf ;
467
- scan -> currentItemData = scan -> currentMarkData ;
467
+ so -> hashso_curpos = so -> hashso_mrkpos ;
468
468
}
469
469
470
470
PG_RETURN_VOID ();