From e0c9301c87634f21c0a7c6305bdc6da15d6ba375 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 27 Jun 2001 23:31:40 +0000 Subject: Install infrastructure for shared-memory free space map. Doesn't actually do anything yet, but it has the necessary connections to initialization and so forth. Make some gestures towards allowing number of blocks in a relation to be BlockNumber, ie, unsigned int, rather than signed int. (I doubt I got all the places that are sloppy about it, yet.) On the way, replace the hardwired NLOCKS_PER_XACT fudge factor with a GUC variable. --- src/backend/access/heap/heapam.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) (limited to 'src/backend/access/heap/heapam.c') diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 6e0974ac32..b86425f7d1 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.119 2001/06/22 19:16:20 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.120 2001/06/27 23:31:38 tgl Exp $ * * * INTERFACE ROUTINES @@ -121,8 +121,8 @@ heapgettup(Relation relation, { ItemId lpp; Page dp; - int page; - int pages; + BlockNumber page; + BlockNumber pages; int lines; OffsetNumber lineoff; int linesleft; @@ -172,7 +172,7 @@ heapgettup(Relation relation, /* * return null immediately if relation is empty */ - if (!(pages = relation->rd_nblocks)) + if ((pages = relation->rd_nblocks) == 0) { if (BufferIsValid(*buffer)) ReleaseBuffer(*buffer); @@ -233,15 +233,8 @@ heapgettup(Relation relation, { page = ItemPointerGetBlockNumber(tid); /* current page */ } - if (page < 0) - { - if (BufferIsValid(*buffer)) - ReleaseBuffer(*buffer); - *buffer = InvalidBuffer; - tuple->t_datamcxt = NULL; - tuple->t_data = NULL; - return; - } + + Assert(page < pages); *buffer = ReleaseAndReadBuffer(*buffer, relation, @@ -283,15 +276,7 @@ heapgettup(Relation relation, OffsetNumberNext(ItemPointerGetOffsetNumber(tid)); } - if (page >= pages) - { - if (BufferIsValid(*buffer)) - ReleaseBuffer(*buffer); - *buffer = InvalidBuffer; - tuple->t_datamcxt = NULL; - tuple->t_data = NULL; - return; - } + Assert(page < pages); *buffer = ReleaseAndReadBuffer(*buffer, relation, @@ -369,12 +354,11 @@ heapgettup(Relation relation, * and it's time to move to the next. */ LockBuffer(*buffer, BUFFER_LOCK_UNLOCK); - page = (dir < 0) ? (page - 1) : (page + 1); /* * return NULL if we've exhausted all the pages */ - if (page < 0 || page >= pages) + if ((dir < 0) ? (page == 0) : (page+1 >= pages)) { if (BufferIsValid(*buffer)) ReleaseBuffer(*buffer); @@ -384,6 +368,10 @@ heapgettup(Relation relation, return; } + page = (dir < 0) ? (page - 1) : (page + 1); + + Assert(page < pages); + *buffer = ReleaseAndReadBuffer(*buffer, relation, page, -- cgit v1.2.1