mirror of
https://github.com/postgres/postgres.git
synced 2025-09-08 00:47:37 +03:00
Another round of cleanups for dynahash.c (maybe it's finally clean of
portability issues). Caller-visible data structures are now allocated on MAXALIGN boundaries, allowing safe use of datatypes wider than 'long'. Rejigger hash_create API so that caller specifies size of key and total size of entry, not size of key and size of rest of entry. This simplifies life considerably since each number is just a sizeof(), and padding issues etc. are taken care of automatically.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.44 2001/09/29 04:02:22 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.45 2001/10/01 05:36:13 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -280,9 +280,7 @@ BufferShmemSize(void)
|
||||
int size = 0;
|
||||
|
||||
/* size of shmem index hash table */
|
||||
size += hash_estimate_size(SHMEM_INDEX_SIZE,
|
||||
SHMEM_INDEX_KEYSIZE,
|
||||
SHMEM_INDEX_DATASIZE);
|
||||
size += hash_estimate_size(SHMEM_INDEX_SIZE, sizeof(ShmemIndexEnt));
|
||||
|
||||
/* size of buffer descriptors */
|
||||
size += MAXALIGN((NBuffers + 1) * sizeof(BufferDesc));
|
||||
@@ -291,9 +289,7 @@ BufferShmemSize(void)
|
||||
size += NBuffers * MAXALIGN(BLCKSZ);
|
||||
|
||||
/* size of buffer hash table */
|
||||
size += hash_estimate_size(NBuffers,
|
||||
sizeof(BufferTag),
|
||||
sizeof(Buffer));
|
||||
size += hash_estimate_size(NBuffers, sizeof(BufferLookupEnt));
|
||||
|
||||
#ifdef BMTRACE
|
||||
size += (BMT_LIMIT * sizeof(bmtrace)) + sizeof(long);
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.22 2001/09/29 04:02:22 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.23 2001/10/01 05:36:13 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -33,54 +33,42 @@
|
||||
|
||||
static HTAB *SharedBufHash;
|
||||
|
||||
typedef struct lookup
|
||||
{
|
||||
BufferTag key;
|
||||
Buffer id;
|
||||
} LookupEnt;
|
||||
|
||||
/*
|
||||
* Initialize shmem hash table for mapping buffers
|
||||
*/
|
||||
void
|
||||
InitBufTable()
|
||||
InitBufTable(void)
|
||||
{
|
||||
HASHCTL info;
|
||||
int hash_flags;
|
||||
|
||||
/* assume lock is held */
|
||||
|
||||
/* BufferTag maps to Buffer */
|
||||
info.keysize = sizeof(BufferTag);
|
||||
info.datasize = sizeof(Buffer);
|
||||
info.entrysize = sizeof(BufferLookupEnt);
|
||||
info.hash = tag_hash;
|
||||
|
||||
hash_flags = (HASH_ELEM | HASH_FUNCTION);
|
||||
|
||||
|
||||
SharedBufHash = (HTAB *) ShmemInitHash("Shared Buffer Lookup Table",
|
||||
NBuffers, NBuffers,
|
||||
&info, hash_flags);
|
||||
SharedBufHash = ShmemInitHash("Shared Buffer Lookup Table",
|
||||
NBuffers, NBuffers,
|
||||
&info,
|
||||
HASH_ELEM | HASH_FUNCTION);
|
||||
|
||||
if (!SharedBufHash)
|
||||
{
|
||||
elog(FATAL, "couldn't initialize shared buffer pool Hash Tbl");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BufferDesc *
|
||||
BufTableLookup(BufferTag *tagPtr)
|
||||
{
|
||||
LookupEnt *result;
|
||||
BufferLookupEnt *result;
|
||||
bool found;
|
||||
|
||||
if (tagPtr->blockNum == P_NEW)
|
||||
return NULL;
|
||||
|
||||
result = (LookupEnt *)
|
||||
hash_search(SharedBufHash, (char *) tagPtr, HASH_FIND, &found);
|
||||
result = (BufferLookupEnt *)
|
||||
hash_search(SharedBufHash, (void *) tagPtr, HASH_FIND, &found);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -98,7 +86,7 @@ BufTableLookup(BufferTag *tagPtr)
|
||||
bool
|
||||
BufTableDelete(BufferDesc *buf)
|
||||
{
|
||||
LookupEnt *result;
|
||||
BufferLookupEnt *result;
|
||||
bool found;
|
||||
|
||||
/*
|
||||
@@ -110,8 +98,8 @@ BufTableDelete(BufferDesc *buf)
|
||||
|
||||
buf->flags |= BM_DELETED;
|
||||
|
||||
result = (LookupEnt *)
|
||||
hash_search(SharedBufHash, (char *) &(buf->tag), HASH_REMOVE, &found);
|
||||
result = (BufferLookupEnt *)
|
||||
hash_search(SharedBufHash, (void *) &(buf->tag), HASH_REMOVE, &found);
|
||||
|
||||
if (!(result && found))
|
||||
{
|
||||
@@ -134,15 +122,15 @@ BufTableDelete(BufferDesc *buf)
|
||||
bool
|
||||
BufTableInsert(BufferDesc *buf)
|
||||
{
|
||||
LookupEnt *result;
|
||||
BufferLookupEnt *result;
|
||||
bool found;
|
||||
|
||||
/* cannot insert it twice */
|
||||
Assert(buf->flags & BM_DELETED);
|
||||
buf->flags &= ~(BM_DELETED);
|
||||
|
||||
result = (LookupEnt *)
|
||||
hash_search(SharedBufHash, (char *) &(buf->tag), HASH_ENTER, &found);
|
||||
result = (BufferLookupEnt *)
|
||||
hash_search(SharedBufHash, (void *) &(buf->tag), HASH_ENTER, &found);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.5 2001/09/29 04:02:23 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.6 2001/10/01 05:36:14 tgl Exp $
|
||||
*
|
||||
*
|
||||
* NOTES:
|
||||
@@ -100,9 +100,6 @@ struct FSMRelation
|
||||
FSMChunk *relChunks; /* linked list of page info chunks */
|
||||
};
|
||||
|
||||
#define SHMEM_FSMHASH_KEYSIZE sizeof(RelFileNode)
|
||||
#define SHMEM_FSMHASH_DATASIZE (sizeof(FSMRelation) - SHMEM_FSMHASH_KEYSIZE)
|
||||
|
||||
/*
|
||||
* Info about individual pages in a relation is stored in chunks to reduce
|
||||
* allocation overhead. Note that we allow any chunk of a relation's list
|
||||
@@ -180,8 +177,8 @@ InitFreeSpaceMap(void)
|
||||
MemSet(FreeSpaceMap, 0, sizeof(FSMHeader));
|
||||
|
||||
/* Create hashtable for FSMRelations */
|
||||
info.keysize = SHMEM_FSMHASH_KEYSIZE;
|
||||
info.datasize = SHMEM_FSMHASH_DATASIZE;
|
||||
info.keysize = sizeof(RelFileNode);
|
||||
info.entrysize = sizeof(FSMRelation);
|
||||
info.hash = tag_hash;
|
||||
|
||||
FreeSpaceMap->relHash = ShmemInitHash("Free Space Map Hash",
|
||||
@@ -224,9 +221,7 @@ FreeSpaceShmemSize(void)
|
||||
size = MAXALIGN(sizeof(FSMHeader));
|
||||
|
||||
/* hash table, including the FSMRelation objects */
|
||||
size += hash_estimate_size(MaxFSMRelations,
|
||||
SHMEM_FSMHASH_KEYSIZE,
|
||||
SHMEM_FSMHASH_DATASIZE);
|
||||
size += hash_estimate_size(MaxFSMRelations, sizeof(FSMRelation));
|
||||
|
||||
/* FSMChunk objects */
|
||||
nchunks = (MaxFSMPages - 1) / CHUNKPAGES + 1;
|
||||
@@ -498,7 +493,7 @@ lookup_fsm_rel(RelFileNode *rel)
|
||||
bool found;
|
||||
|
||||
fsmrel = (FSMRelation *) hash_search(FreeSpaceMap->relHash,
|
||||
(Pointer) rel,
|
||||
(void *) rel,
|
||||
HASH_FIND,
|
||||
&found);
|
||||
if (!fsmrel)
|
||||
@@ -524,7 +519,7 @@ create_fsm_rel(RelFileNode *rel)
|
||||
bool found;
|
||||
|
||||
fsmrel = (FSMRelation *) hash_search(FreeSpaceMap->relHash,
|
||||
(Pointer) rel,
|
||||
(void *) rel,
|
||||
HASH_ENTER,
|
||||
&found);
|
||||
if (!fsmrel)
|
||||
@@ -595,7 +590,7 @@ delete_fsm_rel(FSMRelation *fsmrel)
|
||||
unlink_fsm_rel(fsmrel);
|
||||
FreeSpaceMap->numRels--;
|
||||
result = (FSMRelation *) hash_search(FreeSpaceMap->relHash,
|
||||
(Pointer) &(fsmrel->key),
|
||||
(void *) &(fsmrel->key),
|
||||
HASH_REMOVE,
|
||||
&found);
|
||||
if (!result || !found)
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.59 2001/09/29 04:02:23 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.60 2001/10/01 05:36:14 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -191,7 +191,7 @@ InitShmemIndex(void)
|
||||
|
||||
/* create the shared memory shmem index */
|
||||
info.keysize = SHMEM_INDEX_KEYSIZE;
|
||||
info.datasize = SHMEM_INDEX_DATASIZE;
|
||||
info.entrysize = sizeof(ShmemIndexEnt);
|
||||
hash_flags = HASH_ELEM;
|
||||
|
||||
/* This will acquire the shmem index lock, but not release it. */
|
||||
@@ -208,7 +208,7 @@ InitShmemIndex(void)
|
||||
strncpy(item.key, "ShmemIndex", SHMEM_INDEX_KEYSIZE);
|
||||
|
||||
result = (ShmemIndexEnt *)
|
||||
hash_search(ShmemIndex, (char *) &item, HASH_ENTER, &found);
|
||||
hash_search(ShmemIndex, (void *) &item, HASH_ENTER, &found);
|
||||
if (!result)
|
||||
elog(FATAL, "InitShmemIndex: corrupted shmem index");
|
||||
|
||||
@@ -248,17 +248,15 @@ ShmemInitHash(char *name, /* table string name for shmem index */
|
||||
* can't grow or other backends wouldn't be able to find it. So, make
|
||||
* sure we make it big enough to start with.
|
||||
*
|
||||
* The segbase is for calculating pointer values. The shared memory
|
||||
* allocator must be specified too.
|
||||
* The shared memory allocator must be specified too.
|
||||
*/
|
||||
infoP->dsize = infoP->max_dsize = hash_select_dirsize(max_size);
|
||||
infoP->segbase = (long *) ShmemBase;
|
||||
infoP->alloc = ShmemAlloc;
|
||||
hash_flags |= HASH_SHARED_MEM | HASH_DIRSIZE;
|
||||
|
||||
/* look it up in the shmem index */
|
||||
location = ShmemInitStruct(name,
|
||||
sizeof(HHDR) + infoP->dsize * sizeof(SEG_OFFSET),
|
||||
sizeof(HASHHDR) + infoP->dsize * sizeof(HASHSEGMENT),
|
||||
&found);
|
||||
|
||||
/*
|
||||
@@ -266,18 +264,18 @@ ShmemInitHash(char *name, /* table string name for shmem index */
|
||||
* message since they have more information
|
||||
*/
|
||||
if (location == NULL)
|
||||
return 0;
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* it already exists, attach to it rather than allocate and initialize
|
||||
* if it already exists, attach to it rather than allocate and initialize
|
||||
* new space
|
||||
*/
|
||||
if (found)
|
||||
hash_flags |= HASH_ATTACH;
|
||||
|
||||
/* Now provide the header and directory pointers */
|
||||
infoP->hctl = (long *) location;
|
||||
infoP->dir = (long *) (((char *) location) + sizeof(HHDR));
|
||||
infoP->hctl = (HASHHDR *) location;
|
||||
infoP->dir = (HASHSEGMENT *) (((char *) location) + sizeof(HASHHDR));
|
||||
|
||||
return hash_create(init_size, infoP, hash_flags);
|
||||
}
|
||||
@@ -325,7 +323,7 @@ ShmemInitStruct(char *name, Size size, bool *foundPtr)
|
||||
|
||||
/* look it up in the shmem index */
|
||||
result = (ShmemIndexEnt *)
|
||||
hash_search(ShmemIndex, (char *) &item, HASH_ENTER, foundPtr);
|
||||
hash_search(ShmemIndex, (void *) &item, HASH_ENTER, foundPtr);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -359,7 +357,7 @@ ShmemInitStruct(char *name, Size size, bool *foundPtr)
|
||||
{
|
||||
/* out of memory */
|
||||
Assert(ShmemIndex);
|
||||
hash_search(ShmemIndex, (char *) &item, HASH_REMOVE, foundPtr);
|
||||
hash_search(ShmemIndex, (void *) &item, HASH_REMOVE, foundPtr);
|
||||
LWLockRelease(ShmemIndexLock);
|
||||
*foundPtr = FALSE;
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.98 2001/09/30 00:45:47 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.99 2001/10/01 05:36:14 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Outside modules can create a lock table and acquire/release
|
||||
@@ -308,8 +308,8 @@ LockMethodTableInit(char *tabName,
|
||||
* allocate a hash table for LOCK structs. This is used to store
|
||||
* per-locked-object information.
|
||||
*/
|
||||
info.keysize = SHMEM_LOCKTAB_KEYSIZE;
|
||||
info.datasize = SHMEM_LOCKTAB_DATASIZE;
|
||||
info.keysize = sizeof(LOCKTAG);
|
||||
info.entrysize = sizeof(LOCK);
|
||||
info.hash = tag_hash;
|
||||
hash_flags = (HASH_ELEM | HASH_FUNCTION);
|
||||
|
||||
@@ -328,8 +328,8 @@ LockMethodTableInit(char *tabName,
|
||||
* allocate a hash table for HOLDER structs. This is used to store
|
||||
* per-lock-holder information.
|
||||
*/
|
||||
info.keysize = SHMEM_HOLDERTAB_KEYSIZE;
|
||||
info.datasize = SHMEM_HOLDERTAB_DATASIZE;
|
||||
info.keysize = sizeof(HOLDERTAG);
|
||||
info.entrysize = sizeof(HOLDER);
|
||||
info.hash = tag_hash;
|
||||
hash_flags = (HASH_ELEM | HASH_FUNCTION);
|
||||
|
||||
@@ -485,7 +485,8 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
|
||||
* Find or create a lock with this tag
|
||||
*/
|
||||
Assert(lockMethodTable->lockHash->hash == tag_hash);
|
||||
lock = (LOCK *) hash_search(lockMethodTable->lockHash, (Pointer) locktag,
|
||||
lock = (LOCK *) hash_search(lockMethodTable->lockHash,
|
||||
(void *) locktag,
|
||||
HASH_ENTER, &found);
|
||||
if (!lock)
|
||||
{
|
||||
@@ -530,7 +531,8 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
|
||||
* Find or create a holder entry with this tag
|
||||
*/
|
||||
holderTable = lockMethodTable->holderHash;
|
||||
holder = (HOLDER *) hash_search(holderTable, (Pointer) &holdertag,
|
||||
holder = (HOLDER *) hash_search(holderTable,
|
||||
(void *) &holdertag,
|
||||
HASH_ENTER, &found);
|
||||
if (!holder)
|
||||
{
|
||||
@@ -655,7 +657,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
|
||||
SHMQueueDelete(&holder->lockLink);
|
||||
SHMQueueDelete(&holder->procLink);
|
||||
holder = (HOLDER *) hash_search(holderTable,
|
||||
(Pointer) holder,
|
||||
(void *) holder,
|
||||
HASH_REMOVE, &found);
|
||||
if (!holder || !found)
|
||||
elog(NOTICE, "LockAcquire: remove holder, table corrupted");
|
||||
@@ -1019,7 +1021,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
|
||||
* Find a lock with this tag
|
||||
*/
|
||||
Assert(lockMethodTable->lockHash->hash == tag_hash);
|
||||
lock = (LOCK *) hash_search(lockMethodTable->lockHash, (Pointer) locktag,
|
||||
lock = (LOCK *) hash_search(lockMethodTable->lockHash,
|
||||
(void *) locktag,
|
||||
HASH_FIND, &found);
|
||||
|
||||
/*
|
||||
@@ -1051,7 +1054,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
|
||||
TransactionIdStore(xid, &holdertag.xid);
|
||||
|
||||
holderTable = lockMethodTable->holderHash;
|
||||
holder = (HOLDER *) hash_search(holderTable, (Pointer) &holdertag,
|
||||
holder = (HOLDER *) hash_search(holderTable,
|
||||
(void *) &holdertag,
|
||||
HASH_FIND_SAVE, &found);
|
||||
if (!holder || !found)
|
||||
{
|
||||
@@ -1124,7 +1128,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
|
||||
*/
|
||||
Assert(lockMethodTable->lockHash->hash == tag_hash);
|
||||
lock = (LOCK *) hash_search(lockMethodTable->lockHash,
|
||||
(Pointer) &(lock->tag),
|
||||
(void *) &(lock->tag),
|
||||
HASH_REMOVE,
|
||||
&found);
|
||||
if (!lock || !found)
|
||||
@@ -1153,7 +1157,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
|
||||
HOLDER_PRINT("LockRelease: deleting", holder);
|
||||
SHMQueueDelete(&holder->lockLink);
|
||||
SHMQueueDelete(&holder->procLink);
|
||||
holder = (HOLDER *) hash_search(holderTable, (Pointer) &holder,
|
||||
holder = (HOLDER *) hash_search(holderTable,
|
||||
(void *) &holder,
|
||||
HASH_REMOVE_SAVED, &found);
|
||||
if (!holder || !found)
|
||||
{
|
||||
@@ -1306,7 +1311,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PROC *proc,
|
||||
* remove the holder entry from the hashtable
|
||||
*/
|
||||
holder = (HOLDER *) hash_search(lockMethodTable->holderHash,
|
||||
(Pointer) holder,
|
||||
(void *) holder,
|
||||
HASH_REMOVE,
|
||||
&found);
|
||||
if (!holder || !found)
|
||||
@@ -1326,7 +1331,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PROC *proc,
|
||||
LOCK_PRINT("LockReleaseAll: deleting", lock, 0);
|
||||
Assert(lockMethodTable->lockHash->hash == tag_hash);
|
||||
lock = (LOCK *) hash_search(lockMethodTable->lockHash,
|
||||
(Pointer) &(lock->tag),
|
||||
(void *) &(lock->tag),
|
||||
HASH_REMOVE, &found);
|
||||
if (!lock || !found)
|
||||
{
|
||||
@@ -1364,14 +1369,10 @@ LockShmemSize(int maxBackends)
|
||||
* lockMethodTable->ctl */
|
||||
|
||||
/* lockHash table */
|
||||
size += hash_estimate_size(max_table_size,
|
||||
SHMEM_LOCKTAB_KEYSIZE,
|
||||
SHMEM_LOCKTAB_DATASIZE);
|
||||
size += hash_estimate_size(max_table_size, sizeof(LOCK));
|
||||
|
||||
/* holderHash table */
|
||||
size += hash_estimate_size(max_table_size,
|
||||
SHMEM_HOLDERTAB_KEYSIZE,
|
||||
SHMEM_HOLDERTAB_DATASIZE);
|
||||
size += hash_estimate_size(max_table_size, sizeof(HOLDER));
|
||||
|
||||
/*
|
||||
* Since the lockHash entry count above is only an estimate, add 10%
|
||||
|
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.25 2001/09/29 04:02:25 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.26 2001/10/01 05:36:15 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -103,12 +103,12 @@ mminit()
|
||||
}
|
||||
|
||||
info.keysize = sizeof(MMCacheTag);
|
||||
info.datasize = sizeof(MMHashEntry) - sizeof(MMCacheTag);
|
||||
info.entrysize = sizeof(MMHashEntry);
|
||||
info.hash = tag_hash;
|
||||
|
||||
MMCacheHT = (HTAB *) ShmemInitHash("Main memory store HT",
|
||||
MMNBUFFERS, MMNBUFFERS,
|
||||
&info, (HASH_ELEM | HASH_FUNCTION));
|
||||
MMCacheHT = ShmemInitHash("Main memory store HT",
|
||||
MMNBUFFERS, MMNBUFFERS,
|
||||
&info, (HASH_ELEM | HASH_FUNCTION));
|
||||
|
||||
if (MMCacheHT == (HTAB *) NULL)
|
||||
{
|
||||
@@ -117,12 +117,12 @@ mminit()
|
||||
}
|
||||
|
||||
info.keysize = sizeof(MMRelTag);
|
||||
info.datasize = sizeof(MMRelHashEntry) - sizeof(MMRelTag);
|
||||
info.entrysize = sizeof(MMRelHashEntry);
|
||||
info.hash = tag_hash;
|
||||
|
||||
MMRelCacheHT = (HTAB *) ShmemInitHash("Main memory rel HT",
|
||||
MMNRELATIONS, MMNRELATIONS,
|
||||
&info, (HASH_ELEM | HASH_FUNCTION));
|
||||
MMRelCacheHT = ShmemInitHash("Main memory rel HT",
|
||||
MMNRELATIONS, MMNRELATIONS,
|
||||
&info, (HASH_ELEM | HASH_FUNCTION));
|
||||
|
||||
if (MMRelCacheHT == (HTAB *) NULL)
|
||||
{
|
||||
@@ -180,7 +180,8 @@ mmcreate(Relation reln)
|
||||
tag.mmrt_dbid = MyDatabaseId;
|
||||
|
||||
entry = (MMRelHashEntry *) hash_search(MMRelCacheHT,
|
||||
(char *) &tag, HASH_ENTER, &found);
|
||||
(void *) &tag,
|
||||
HASH_ENTER, &found);
|
||||
|
||||
if (entry == (MMRelHashEntry *) NULL)
|
||||
{
|
||||
@@ -224,7 +225,7 @@ mmunlink(RelFileNode rnode)
|
||||
&& MMBlockTags[i].mmct_relid == rnode.relNode)
|
||||
{
|
||||
entry = (MMHashEntry *) hash_search(MMCacheHT,
|
||||
(char *) &MMBlockTags[i],
|
||||
(void *) &MMBlockTags[i],
|
||||
HASH_REMOVE, &found);
|
||||
if (entry == (MMHashEntry *) NULL || !found)
|
||||
{
|
||||
@@ -239,7 +240,8 @@ mmunlink(RelFileNode rnode)
|
||||
rtag.mmrt_dbid = rnode.tblNode;
|
||||
rtag.mmrt_relid = rnode.relNode;
|
||||
|
||||
rentry = (MMRelHashEntry *) hash_search(MMRelCacheHT, (char *) &rtag,
|
||||
rentry = (MMRelHashEntry *) hash_search(MMRelCacheHT,
|
||||
(void *) &rtag,
|
||||
HASH_REMOVE, &found);
|
||||
|
||||
if (rentry == (MMRelHashEntry *) NULL || !found)
|
||||
@@ -302,7 +304,8 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
(*MMCurTop)++;
|
||||
}
|
||||
|
||||
rentry = (MMRelHashEntry *) hash_search(MMRelCacheHT, (char *) &rtag,
|
||||
rentry = (MMRelHashEntry *) hash_search(MMRelCacheHT,
|
||||
(void *) &rtag,
|
||||
HASH_FIND, &found);
|
||||
if (rentry == (MMRelHashEntry *) NULL || !found)
|
||||
{
|
||||
@@ -312,7 +315,8 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
|
||||
tag.mmct_blkno = rentry->mmrhe_nblocks;
|
||||
|
||||
entry = (MMHashEntry *) hash_search(MMCacheHT, (char *) &tag,
|
||||
entry = (MMHashEntry *) hash_search(MMCacheHT,
|
||||
(void *) &tag,
|
||||
HASH_ENTER, &found);
|
||||
if (entry == (MMHashEntry *) NULL || found)
|
||||
{
|
||||
@@ -381,7 +385,8 @@ mmread(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
tag.mmct_blkno = blocknum;
|
||||
|
||||
LWLockAcquire(MMCacheLock, LW_EXCLUSIVE);
|
||||
entry = (MMHashEntry *) hash_search(MMCacheHT, (char *) &tag,
|
||||
entry = (MMHashEntry *) hash_search(MMCacheHT,
|
||||
(void *) &tag,
|
||||
HASH_FIND, &found);
|
||||
|
||||
if (entry == (MMHashEntry *) NULL)
|
||||
@@ -428,7 +433,8 @@ mmwrite(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
tag.mmct_blkno = blocknum;
|
||||
|
||||
LWLockAcquire(MMCacheLock, LW_EXCLUSIVE);
|
||||
entry = (MMHashEntry *) hash_search(MMCacheHT, (char *) &tag,
|
||||
entry = (MMHashEntry *) hash_search(MMCacheHT,
|
||||
(void *) &tag,
|
||||
HASH_FIND, &found);
|
||||
|
||||
if (entry == (MMHashEntry *) NULL)
|
||||
@@ -502,7 +508,8 @@ mmnblocks(Relation reln)
|
||||
|
||||
LWLockAcquire(MMCacheLock, LW_EXCLUSIVE);
|
||||
|
||||
rentry = (MMRelHashEntry *) hash_search(MMRelCacheHT, (char *) &rtag,
|
||||
rentry = (MMRelHashEntry *) hash_search(MMRelCacheHT,
|
||||
(void *) &rtag,
|
||||
HASH_FIND, &found);
|
||||
|
||||
if (rentry == (MMRelHashEntry *) NULL)
|
||||
@@ -558,16 +565,12 @@ MMShmemSize()
|
||||
/*
|
||||
* first compute space occupied by the (dbid,relid,blkno) hash table
|
||||
*/
|
||||
size += hash_estimate_size(MMNBUFFERS,
|
||||
0, /* MMHashEntry includes key */
|
||||
sizeof(MMHashEntry));
|
||||
size += hash_estimate_size(MMNBUFFERS, sizeof(MMHashEntry));
|
||||
|
||||
/*
|
||||
* now do the same for the rel hash table
|
||||
*/
|
||||
size += hash_estimate_size(MMNRELATIONS,
|
||||
0, /* MMRelHashEntry includes key */
|
||||
sizeof(MMRelHashEntry));
|
||||
size += hash_estimate_size(MMNRELATIONS, sizeof(MMRelHashEntry));
|
||||
|
||||
/*
|
||||
* finally, add in the memory block we use directly
|
||||
|
Reference in New Issue
Block a user