diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-27 23:31:40 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-27 23:31:40 +0000 |
| commit | e0c9301c87634f21c0a7c6305bdc6da15d6ba375 (patch) | |
| tree | aad976ca0197137c3461ff19a3d0e155487f7b44 /src/backend/access/heap | |
| parent | b559382134a52bbe1d79d465afd89c8385f88581 (diff) | |
| download | postgresql-e0c9301c87634f21c0a7c6305bdc6da15d6ba375.tar.gz | |
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.
Diffstat (limited to 'src/backend/access/heap')
| -rw-r--r-- | src/backend/access/heap/heapam.c | 36 | ||||
| -rw-r--r-- | src/backend/access/heap/hio.c | 4 |
2 files changed, 14 insertions, 26 deletions
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, diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 1451dc2ecc..3a520f2c31 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Id: hio.c,v 1.39 2001/05/16 22:35:12 tgl Exp $ + * $Id: hio.c,v 1.40 2001/06/27 23:31:38 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -147,7 +147,7 @@ RelationGetBufferForTuple(Relation relation, Size len, */ relation->rd_nblocks = RelationGetNumberOfBlocks(relation); - if ((BlockNumber) relation->rd_nblocks > oldnblocks) + if (relation->rd_nblocks > oldnblocks) { /* * Someone else has indeed extended the relation recently. |
