mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
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.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.30 2001/03/07 21:20:26 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.31 2001/06/27 23:31:37 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Postgres hash pages look like ordinary relation pages. The opaque
|
||||
@@ -70,18 +70,15 @@ _hash_metapinit(Relation rel)
|
||||
int nbuckets;
|
||||
uint32 nelem; /* number elements */
|
||||
uint32 lg2nelem; /* _hash_log2(nelem) */
|
||||
uint32 nblocks;
|
||||
uint16 i;
|
||||
|
||||
/* can't be sharing this with anyone, now... */
|
||||
if (USELOCKING)
|
||||
LockRelation(rel, AccessExclusiveLock);
|
||||
|
||||
if ((nblocks = RelationGetNumberOfBlocks(rel)) != 0)
|
||||
{
|
||||
if (RelationGetNumberOfBlocks(rel) != 0)
|
||||
elog(ERROR, "Cannot initialize non-empty hash table %s",
|
||||
RelationGetRelationName(rel));
|
||||
}
|
||||
|
||||
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_WRITE);
|
||||
pg = BufferGetPage(metabuf);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.51 2001/03/22 03:59:14 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.52 2001/06/27 23:31:38 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Postgres btree pages look like ordinary relation pages. The opaque
|
||||
@@ -55,7 +55,6 @@ _bt_metapinit(Relation rel)
|
||||
{
|
||||
Buffer buf;
|
||||
Page pg;
|
||||
int nblocks;
|
||||
BTMetaPageData metad;
|
||||
BTPageOpaque op;
|
||||
|
||||
@@ -63,11 +62,9 @@ _bt_metapinit(Relation rel)
|
||||
if (USELOCKING)
|
||||
LockRelation(rel, AccessExclusiveLock);
|
||||
|
||||
if ((nblocks = RelationGetNumberOfBlocks(rel)) != 0)
|
||||
{
|
||||
if (RelationGetNumberOfBlocks(rel) != 0)
|
||||
elog(ERROR, "Cannot initialize non-empty btree %s",
|
||||
RelationGetRelationName(rel));
|
||||
}
|
||||
|
||||
buf = ReadBuffer(rel, P_NEW);
|
||||
pg = BufferGetPage(buf);
|
||||
|
||||
Reference in New Issue
Block a user