mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.11 1997/09/07 04:48:15 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.12 1997/09/08 02:28:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -43,33 +43,33 @@
|
||||
* deallocations in a circular buffer in shared memory.
|
||||
*/
|
||||
#ifdef BMTRACE
|
||||
bmtrace *TraceBuf;
|
||||
long *CurTraceBuf;
|
||||
bmtrace *TraceBuf;
|
||||
long *CurTraceBuf;
|
||||
|
||||
#define BMT_LIMIT 200
|
||||
#endif /* BMTRACE */
|
||||
int ShowPinTrace = 0;
|
||||
int ShowPinTrace = 0;
|
||||
|
||||
int NBuffers = NDBUFS; /* NDBUFS defined in miscadmin.h */
|
||||
int Data_Descriptors;
|
||||
int Free_List_Descriptor;
|
||||
int Lookup_List_Descriptor;
|
||||
int Num_Descriptors;
|
||||
int NBuffers = NDBUFS; /* NDBUFS defined in miscadmin.h */
|
||||
int Data_Descriptors;
|
||||
int Free_List_Descriptor;
|
||||
int Lookup_List_Descriptor;
|
||||
int Num_Descriptors;
|
||||
|
||||
BufferDesc *BufferDescriptors;
|
||||
BufferBlock BufferBlocks;
|
||||
BufferDesc *BufferDescriptors;
|
||||
BufferBlock BufferBlocks;
|
||||
|
||||
#ifndef HAS_TEST_AND_SET
|
||||
long *NWaitIOBackendP;
|
||||
long *NWaitIOBackendP;
|
||||
|
||||
#endif
|
||||
|
||||
extern IpcSemaphoreId WaitIOSemId;
|
||||
|
||||
long *PrivateRefCount;/* also used in freelist.c */
|
||||
long *LastRefCount; /* refcounts of last ExecMain level */
|
||||
long *CommitInfoNeedsSave; /* to write buffers where we have
|
||||
* filled in */
|
||||
long *PrivateRefCount; /* also used in freelist.c */
|
||||
long *LastRefCount; /* refcounts of last ExecMain level */
|
||||
long *CommitInfoNeedsSave;/* to write buffers where we have filled
|
||||
* in */
|
||||
|
||||
/* t_tmin (or t_tmax) */
|
||||
|
||||
@@ -124,14 +124,14 @@ long *CommitInfoNeedsSave; /* to write buffers where we have
|
||||
*
|
||||
*/
|
||||
|
||||
SPINLOCK BufMgrLock;
|
||||
SPINLOCK BufMgrLock;
|
||||
|
||||
long int ReadBufferCount;
|
||||
long int ReadLocalBufferCount;
|
||||
long int BufferHitCount;
|
||||
long int LocalBufferHitCount;
|
||||
long int BufferFlushCount;
|
||||
long int LocalBufferFlushCount;
|
||||
long int ReadBufferCount;
|
||||
long int ReadLocalBufferCount;
|
||||
long int BufferHitCount;
|
||||
long int LocalBufferHitCount;
|
||||
long int BufferFlushCount;
|
||||
long int LocalBufferFlushCount;
|
||||
|
||||
|
||||
/*
|
||||
@@ -143,9 +143,9 @@ long int LocalBufferFlushCount;
|
||||
void
|
||||
InitBufferPool(IPCKey key)
|
||||
{
|
||||
bool foundBufs,
|
||||
foundDescs;
|
||||
int i;
|
||||
bool foundBufs,
|
||||
foundDescs;
|
||||
int i;
|
||||
|
||||
/* check padding of BufferDesc and BufferHdr */
|
||||
|
||||
@@ -189,7 +189,7 @@ InitBufferPool(IPCKey key)
|
||||
|
||||
#ifndef HAS_TEST_AND_SET
|
||||
{
|
||||
bool foundNWaitIO;
|
||||
bool foundNWaitIO;
|
||||
|
||||
NWaitIOBackendP = (long *) ShmemInitStruct("#Backends Waiting IO",
|
||||
sizeof(long),
|
||||
@@ -208,8 +208,8 @@ InitBufferPool(IPCKey key)
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferDesc *buf;
|
||||
unsigned long block;
|
||||
BufferDesc *buf;
|
||||
unsigned long block;
|
||||
|
||||
buf = BufferDescriptors;
|
||||
block = (unsigned long) BufferBlocks;
|
||||
@@ -249,7 +249,7 @@ InitBufferPool(IPCKey key)
|
||||
|
||||
#ifndef HAS_TEST_AND_SET
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
|
||||
WaitIOSemId = IpcSemaphoreCreate(IPCKeyGetWaitIOSemaphoreKey(key),
|
||||
1, IPCProtection, 0, 1, &status);
|
||||
@@ -270,10 +270,10 @@ InitBufferPool(IPCKey key)
|
||||
int
|
||||
BufferShmemSize()
|
||||
{
|
||||
int size = 0;
|
||||
int nbuckets;
|
||||
int nsegs;
|
||||
int tmp;
|
||||
int size = 0;
|
||||
int nbuckets;
|
||||
int nsegs;
|
||||
int tmp;
|
||||
|
||||
nbuckets = 1 << (int) my_log2((NBuffers - 1) / DEF_FFACTOR + 1);
|
||||
nsegs = 1 << (int) my_log2((nbuckets - 1) / DEF_SEGSIZE + 1);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.5 1997/09/07 04:48:17 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.6 1997/09/08 02:28:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -34,13 +34,13 @@
|
||||
#include "storage/spin.h"
|
||||
#include "utils/hsearch.h"
|
||||
|
||||
static HTAB *SharedBufHash;
|
||||
static HTAB *SharedBufHash;
|
||||
|
||||
typedef struct lookup
|
||||
{
|
||||
BufferTag key;
|
||||
Buffer id;
|
||||
} LookupEnt;
|
||||
BufferTag key;
|
||||
Buffer id;
|
||||
} LookupEnt;
|
||||
|
||||
/*
|
||||
* Initialize shmem hash table for mapping buffers
|
||||
@@ -48,8 +48,8 @@ typedef struct lookup
|
||||
void
|
||||
InitBufTable()
|
||||
{
|
||||
HASHCTL info;
|
||||
int hash_flags;
|
||||
HASHCTL info;
|
||||
int hash_flags;
|
||||
|
||||
/* assume lock is held */
|
||||
|
||||
@@ -73,11 +73,11 @@ InitBufTable()
|
||||
|
||||
}
|
||||
|
||||
BufferDesc *
|
||||
BufferDesc *
|
||||
BufTableLookup(BufferTag * tagPtr)
|
||||
{
|
||||
LookupEnt *result;
|
||||
bool found;
|
||||
LookupEnt *result;
|
||||
bool found;
|
||||
|
||||
if (tagPtr->blockNum == P_NEW)
|
||||
return (NULL);
|
||||
@@ -103,8 +103,8 @@ BufTableLookup(BufferTag * tagPtr)
|
||||
bool
|
||||
BufTableDelete(BufferDesc * buf)
|
||||
{
|
||||
LookupEnt *result;
|
||||
bool found;
|
||||
LookupEnt *result;
|
||||
bool found;
|
||||
|
||||
/*
|
||||
* buffer not initialized or has been removed from table already.
|
||||
@@ -132,8 +132,8 @@ BufTableDelete(BufferDesc * buf)
|
||||
bool
|
||||
BufTableInsert(BufferDesc * buf)
|
||||
{
|
||||
LookupEnt *result;
|
||||
bool found;
|
||||
LookupEnt *result;
|
||||
bool found;
|
||||
|
||||
/* cannot insert it twice */
|
||||
Assert(buf->flags & BM_DELETED);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.20 1997/09/07 04:48:19 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.21 1997/09/08 02:28:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -77,14 +77,14 @@ extern long int LocalBufferHitCount;
|
||||
extern long int BufferFlushCount;
|
||||
extern long int LocalBufferFlushCount;
|
||||
|
||||
static int WriteMode = BUFFER_LATE_WRITE; /* Delayed write is
|
||||
static int WriteMode = BUFFER_LATE_WRITE; /* Delayed write is
|
||||
* default */
|
||||
|
||||
static void WaitIO(BufferDesc * buf, SPINLOCK spinlock);
|
||||
static void WaitIO(BufferDesc * buf, SPINLOCK spinlock);
|
||||
|
||||
#ifndef HAS_TEST_AND_SET
|
||||
static void SignalIO(BufferDesc * buf);
|
||||
extern long *NWaitIOBackendP;/* defined in buf_init.c */
|
||||
static void SignalIO(BufferDesc * buf);
|
||||
extern long *NWaitIOBackendP; /* defined in buf_init.c */
|
||||
|
||||
#endif /* HAS_TEST_AND_SET */
|
||||
|
||||
@@ -94,9 +94,9 @@ ReadBufferWithBufferLock(Relation relation, BlockNumber blockNum,
|
||||
static BufferDesc *
|
||||
BufferAlloc(Relation reln, BlockNumber blockNum,
|
||||
bool * foundPtr, bool bufferLockHeld);
|
||||
static int FlushBuffer(Buffer buffer, bool release);
|
||||
static void BufferSync(void);
|
||||
static int BufferReplace(BufferDesc * bufHdr, bool bufferLockHeld);
|
||||
static int FlushBuffer(Buffer buffer, bool release);
|
||||
static void BufferSync(void);
|
||||
static int BufferReplace(BufferDesc * bufHdr, bool bufferLockHeld);
|
||||
|
||||
/* ---------------------------------------------------
|
||||
* RelationGetBufferWithBuffer
|
||||
@@ -109,8 +109,8 @@ RelationGetBufferWithBuffer(Relation relation,
|
||||
BlockNumber blockNumber,
|
||||
Buffer buffer)
|
||||
{
|
||||
BufferDesc *bufHdr;
|
||||
LRelId lrelId;
|
||||
BufferDesc *bufHdr;
|
||||
LRelId lrelId;
|
||||
|
||||
if (BufferIsValid(buffer))
|
||||
{
|
||||
@@ -154,7 +154,7 @@ RelationGetBufferWithBuffer(Relation relation,
|
||||
* opened already.
|
||||
*/
|
||||
|
||||
extern int ShowPinTrace;
|
||||
extern int ShowPinTrace;
|
||||
|
||||
|
||||
#undef ReadBuffer /* conflicts with macro when BUFMGR_DEBUG
|
||||
@@ -176,10 +176,10 @@ ReadBuffer(Relation reln, BlockNumber blockNum)
|
||||
* XXX caller must have already acquired BufMgrLock
|
||||
*/
|
||||
#ifdef NOT_USED
|
||||
static bool
|
||||
static bool
|
||||
is_userbuffer(Buffer buffer)
|
||||
{
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
|
||||
if (IsSystemRelationName(buf->sb_relname))
|
||||
return false;
|
||||
@@ -195,12 +195,12 @@ ReadBuffer_Debug(char *file,
|
||||
Relation reln,
|
||||
BlockNumber blockNum)
|
||||
{
|
||||
Buffer buffer;
|
||||
Buffer buffer;
|
||||
|
||||
buffer = ReadBufferWithBufferLock(reln, blockNum, false);
|
||||
if (ShowPinTrace && !BufferIsLocal(buffer) && is_userbuffer(buffer))
|
||||
{
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
|
||||
fprintf(stderr, "PIN(RD) %ld relname = %s, blockNum = %d, \
|
||||
refcount = %ld, file: %s, line: %d\n",
|
||||
@@ -219,16 +219,16 @@ refcount = %ld, file: %s, line: %d\n",
|
||||
* is yet another effort to reduce the number of
|
||||
* semops in the system.
|
||||
*/
|
||||
static Buffer
|
||||
static Buffer
|
||||
ReadBufferWithBufferLock(Relation reln,
|
||||
BlockNumber blockNum,
|
||||
bool bufferLockHeld)
|
||||
{
|
||||
BufferDesc *bufHdr;
|
||||
int extend; /* extending the file by one block */
|
||||
int status;
|
||||
bool found;
|
||||
bool isLocalBuf;
|
||||
BufferDesc *bufHdr;
|
||||
int extend; /* extending the file by one block */
|
||||
int status;
|
||||
bool found;
|
||||
bool isLocalBuf;
|
||||
|
||||
extend = (blockNum == P_NEW);
|
||||
isLocalBuf = reln->rd_islocal;
|
||||
@@ -357,11 +357,11 @@ BufferAlloc(Relation reln,
|
||||
bool * foundPtr,
|
||||
bool bufferLockHeld)
|
||||
{
|
||||
BufferDesc *buf,
|
||||
*buf2;
|
||||
BufferTag newTag; /* identity of requested block */
|
||||
bool inProgress; /* buffer undergoing IO */
|
||||
bool newblock = FALSE;
|
||||
BufferDesc *buf,
|
||||
*buf2;
|
||||
BufferTag newTag; /* identity of requested block */
|
||||
bool inProgress; /* buffer undergoing IO */
|
||||
bool newblock = FALSE;
|
||||
|
||||
/* create a new tag so we can lookup the buffer */
|
||||
/* assume that the relation is already open */
|
||||
@@ -458,7 +458,7 @@ BufferAlloc(Relation reln,
|
||||
|
||||
if (buf->flags & BM_DIRTY)
|
||||
{
|
||||
bool smok;
|
||||
bool smok;
|
||||
|
||||
/*
|
||||
* Set BM_IO_IN_PROGRESS to keep anyone from doing anything
|
||||
@@ -693,7 +693,7 @@ BufferAlloc(Relation reln,
|
||||
int
|
||||
WriteBuffer(Buffer buffer)
|
||||
{
|
||||
BufferDesc *bufHdr;
|
||||
BufferDesc *bufHdr;
|
||||
|
||||
if (WriteMode == BUFFER_FLUSH_WRITE)
|
||||
{
|
||||
@@ -727,7 +727,7 @@ WriteBuffer_Debug(char *file, int line, Buffer buffer)
|
||||
WriteBuffer(buffer);
|
||||
if (ShowPinTrace && BufferIsLocal(buffer) && is_userbuffer(buffer))
|
||||
{
|
||||
BufferDesc *buf;
|
||||
BufferDesc *buf;
|
||||
|
||||
buf = &BufferDescriptors[buffer - 1];
|
||||
fprintf(stderr, "UNPIN(WR) %ld relname = %s, blockNum = %d, \
|
||||
@@ -761,8 +761,8 @@ refcount = %ld, file: %s, line: %d\n",
|
||||
void
|
||||
DirtyBufferCopy(Oid dbid, Oid relid, BlockNumber blkno, char *dest)
|
||||
{
|
||||
BufferDesc *buf;
|
||||
BufferTag btag;
|
||||
BufferDesc *buf;
|
||||
BufferTag btag;
|
||||
|
||||
btag.relId.relId = relid;
|
||||
btag.relId.dbId = dbid;
|
||||
@@ -803,10 +803,10 @@ DirtyBufferCopy(Oid dbid, Oid relid, BlockNumber blkno, char *dest)
|
||||
static int
|
||||
FlushBuffer(Buffer buffer, bool release)
|
||||
{
|
||||
BufferDesc *bufHdr;
|
||||
Oid bufdb;
|
||||
Relation bufrel;
|
||||
int status;
|
||||
BufferDesc *bufHdr;
|
||||
Oid bufdb;
|
||||
Relation bufrel;
|
||||
int status;
|
||||
|
||||
if (BufferIsLocal(buffer))
|
||||
return FlushLocalBuffer(buffer, release);
|
||||
@@ -871,7 +871,7 @@ FlushBuffer(Buffer buffer, bool release)
|
||||
int
|
||||
WriteNoReleaseBuffer(Buffer buffer)
|
||||
{
|
||||
BufferDesc *bufHdr;
|
||||
BufferDesc *bufHdr;
|
||||
|
||||
if (WriteMode == BUFFER_FLUSH_WRITE)
|
||||
{
|
||||
@@ -908,8 +908,8 @@ ReleaseAndReadBuffer(Buffer buffer,
|
||||
Relation relation,
|
||||
BlockNumber blockNum)
|
||||
{
|
||||
BufferDesc *bufHdr;
|
||||
Buffer retbuf;
|
||||
BufferDesc *bufHdr;
|
||||
Buffer retbuf;
|
||||
|
||||
if (BufferIsLocal(buffer))
|
||||
{
|
||||
@@ -972,12 +972,12 @@ ReleaseAndReadBuffer(Buffer buffer,
|
||||
static void
|
||||
BufferSync()
|
||||
{
|
||||
int i;
|
||||
Oid bufdb;
|
||||
Oid bufrel;
|
||||
Relation reln;
|
||||
BufferDesc *bufHdr;
|
||||
int status;
|
||||
int i;
|
||||
Oid bufdb;
|
||||
Oid bufrel;
|
||||
Relation reln;
|
||||
BufferDesc *bufHdr;
|
||||
int status;
|
||||
|
||||
SpinAcquire(BufMgrLock);
|
||||
for (i = 0, bufHdr = BufferDescriptors; i < NBuffers; i++, bufHdr++)
|
||||
@@ -1114,12 +1114,12 @@ WaitIO(BufferDesc * buf, SPINLOCK spinlock)
|
||||
}
|
||||
|
||||
#else /* HAS_TEST_AND_SET */
|
||||
IpcSemaphoreId WaitIOSemId;
|
||||
IpcSemaphoreId WaitIOSemId;
|
||||
|
||||
static void
|
||||
WaitIO(BufferDesc * buf, SPINLOCK spinlock)
|
||||
{
|
||||
bool inProgress;
|
||||
bool inProgress;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -1149,16 +1149,15 @@ SignalIO(BufferDesc * buf)
|
||||
|
||||
#endif /* HAS_TEST_AND_SET */
|
||||
|
||||
long NDirectFileRead;/* some I/O's are direct file access.
|
||||
long NDirectFileRead; /* some I/O's are direct file access.
|
||||
* bypass bufmgr */
|
||||
long NDirectFileWrite; /* e.g., I/O in psort and
|
||||
* hashjoin. */
|
||||
long NDirectFileWrite; /* e.g., I/O in psort and hashjoin. */
|
||||
|
||||
void
|
||||
PrintBufferUsage(FILE * statfp)
|
||||
{
|
||||
float hitrate;
|
||||
float localhitrate;
|
||||
float hitrate;
|
||||
float localhitrate;
|
||||
|
||||
if (ReadBufferCount == 0)
|
||||
hitrate = 0.0;
|
||||
@@ -1202,7 +1201,7 @@ ResetBufferUsage()
|
||||
void
|
||||
ResetBufferPool()
|
||||
{
|
||||
register int i;
|
||||
register int i;
|
||||
|
||||
for (i = 1; i <= NBuffers; i++)
|
||||
{
|
||||
@@ -1230,8 +1229,8 @@ ResetBufferPool()
|
||||
int
|
||||
BufferPoolCheckLeak()
|
||||
{
|
||||
register int i;
|
||||
int error = 0;
|
||||
register int i;
|
||||
int error = 0;
|
||||
|
||||
for (i = 1; i <= NBuffers; i++)
|
||||
{
|
||||
@@ -1315,8 +1314,8 @@ BufferGetBlockNumber(Buffer buffer)
|
||||
Relation
|
||||
BufferGetRelation(Buffer buffer)
|
||||
{
|
||||
Relation relation;
|
||||
Oid relid;
|
||||
Relation relation;
|
||||
Oid relid;
|
||||
|
||||
Assert(BufferIsValid(buffer));
|
||||
Assert(!BufferIsLocal(buffer)); /* not supported for local buffers */
|
||||
@@ -1349,10 +1348,10 @@ BufferGetRelation(Buffer buffer)
|
||||
static int
|
||||
BufferReplace(BufferDesc * bufHdr, bool bufferLockHeld)
|
||||
{
|
||||
Relation reln;
|
||||
Oid bufdb,
|
||||
bufrel;
|
||||
int status;
|
||||
Relation reln;
|
||||
Oid bufdb,
|
||||
bufrel;
|
||||
int status;
|
||||
|
||||
if (!bufferLockHeld)
|
||||
SpinAcquire(BufMgrLock);
|
||||
@@ -1446,9 +1445,9 @@ BufferGetBlock(Buffer buffer)
|
||||
void
|
||||
ReleaseRelationBuffers(Relation rdesc)
|
||||
{
|
||||
register int i;
|
||||
int holding = 0;
|
||||
BufferDesc *buf;
|
||||
register int i;
|
||||
int holding = 0;
|
||||
BufferDesc *buf;
|
||||
|
||||
if (rdesc->rd_islocal)
|
||||
{
|
||||
@@ -1503,8 +1502,8 @@ ReleaseRelationBuffers(Relation rdesc)
|
||||
void
|
||||
DropBuffers(Oid dbid)
|
||||
{
|
||||
register int i;
|
||||
BufferDesc *buf;
|
||||
register int i;
|
||||
BufferDesc *buf;
|
||||
|
||||
SpinAcquire(BufMgrLock);
|
||||
for (i = 1; i <= NBuffers; i++)
|
||||
@@ -1528,8 +1527,8 @@ DropBuffers(Oid dbid)
|
||||
void
|
||||
PrintBufferDescs()
|
||||
{
|
||||
int i;
|
||||
BufferDesc *buf = BufferDescriptors;
|
||||
int i;
|
||||
BufferDesc *buf = BufferDescriptors;
|
||||
|
||||
if (IsUnderPostmaster)
|
||||
{
|
||||
@@ -1559,8 +1558,8 @@ blockNum=%d, flags=0x%x, refcount=%d %d)",
|
||||
void
|
||||
PrintPinnedBufs()
|
||||
{
|
||||
int i;
|
||||
BufferDesc *buf = BufferDescriptors;
|
||||
int i;
|
||||
BufferDesc *buf = BufferDescriptors;
|
||||
|
||||
SpinAcquire(BufMgrLock);
|
||||
for (i = 0; i < NBuffers; ++i, ++buf)
|
||||
@@ -1587,7 +1586,7 @@ blockNum=%d, flags=0x%x, refcount=%d %d)\n",
|
||||
void
|
||||
BufferPoolBlowaway()
|
||||
{
|
||||
register int i;
|
||||
register int i;
|
||||
|
||||
BufferSync();
|
||||
for (i = 1; i <= NBuffers; i++)
|
||||
@@ -1630,7 +1629,7 @@ IncrBufferRefCount(Buffer buffer)
|
||||
int
|
||||
ReleaseBuffer(Buffer buffer)
|
||||
{
|
||||
BufferDesc *bufHdr;
|
||||
BufferDesc *bufHdr;
|
||||
|
||||
if (BufferIsLocal(buffer))
|
||||
{
|
||||
@@ -1678,7 +1677,7 @@ IncrBufferRefCount_Debug(char *file, int line, Buffer buffer)
|
||||
IncrBufferRefCount(buffer);
|
||||
if (ShowPinTrace && !BufferIsLocal(buffer) && is_userbuffer(buffer))
|
||||
{
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
|
||||
fprintf(stderr, "PIN(Incr) %ld relname = %s, blockNum = %d, \
|
||||
refcount = %ld, file: %s, line: %d\n",
|
||||
@@ -1696,7 +1695,7 @@ ReleaseBuffer_Debug(char *file, int line, Buffer buffer)
|
||||
ReleaseBuffer(buffer);
|
||||
if (ShowPinTrace && !BufferIsLocal(buffer) && is_userbuffer(buffer))
|
||||
{
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
|
||||
fprintf(stderr, "UNPIN(Rel) %ld relname = %s, blockNum = %d, \
|
||||
refcount = %ld, file: %s, line: %d\n",
|
||||
@@ -1715,15 +1714,15 @@ ReleaseAndReadBuffer_Debug(char *file,
|
||||
Relation relation,
|
||||
BlockNumber blockNum)
|
||||
{
|
||||
bool bufferValid;
|
||||
Buffer b;
|
||||
bool bufferValid;
|
||||
Buffer b;
|
||||
|
||||
bufferValid = BufferIsValid(buffer);
|
||||
b = ReleaseAndReadBuffer(buffer, relation, blockNum);
|
||||
if (ShowPinTrace && bufferValid && BufferIsLocal(buffer)
|
||||
&& is_userbuffer(buffer))
|
||||
{
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
BufferDesc *buf = &BufferDescriptors[buffer - 1];
|
||||
|
||||
fprintf(stderr, "UNPIN(Rel&Rd) %ld relname = %s, blockNum = %d, \
|
||||
refcount = %ld, file: %s, line: %d\n",
|
||||
@@ -1732,7 +1731,7 @@ refcount = %ld, file: %s, line: %d\n",
|
||||
}
|
||||
if (ShowPinTrace && BufferIsLocal(buffer) && is_userbuffer(buffer))
|
||||
{
|
||||
BufferDesc *buf = &BufferDescriptors[b - 1];
|
||||
BufferDesc *buf = &BufferDescriptors[b - 1];
|
||||
|
||||
fprintf(stderr, "PIN(Rel&Rd) %ld relname = %s, blockNum = %d, \
|
||||
refcount = %ld, file: %s, line: %d\n",
|
||||
@@ -1754,10 +1753,10 @@ refcount = %ld, file: %s, line: %d\n",
|
||||
|
||||
_bm_trace(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType)
|
||||
{
|
||||
static int mypid = 0;
|
||||
long start,
|
||||
cur;
|
||||
bmtrace *tb;
|
||||
static int mypid = 0;
|
||||
long start,
|
||||
cur;
|
||||
bmtrace *tb;
|
||||
|
||||
if (mypid == 0)
|
||||
mypid = getpid();
|
||||
@@ -1810,9 +1809,9 @@ okay:
|
||||
_bm_die(Oid dbId, Oid relId, int blkNo, int bufNo,
|
||||
int allocType, long start, long cur)
|
||||
{
|
||||
FILE *fp;
|
||||
bmtrace *tb;
|
||||
int i;
|
||||
FILE *fp;
|
||||
bmtrace *tb;
|
||||
int i;
|
||||
|
||||
tb = &TraceBuf[cur];
|
||||
|
||||
@@ -1839,21 +1838,21 @@ _bm_die(Oid dbId, Oid relId, int blkNo, int bufNo,
|
||||
|
||||
switch (tb->bmt_op)
|
||||
{
|
||||
case BMT_ALLOCFND:
|
||||
fprintf(fp, "allocate (found)\n");
|
||||
break;
|
||||
case BMT_ALLOCFND:
|
||||
fprintf(fp, "allocate (found)\n");
|
||||
break;
|
||||
|
||||
case BMT_ALLOCNOTFND:
|
||||
fprintf(fp, "allocate (not found)\n");
|
||||
break;
|
||||
case BMT_ALLOCNOTFND:
|
||||
fprintf(fp, "allocate (not found)\n");
|
||||
break;
|
||||
|
||||
case BMT_DEALLOC:
|
||||
fprintf(fp, "deallocate\n");
|
||||
break;
|
||||
case BMT_DEALLOC:
|
||||
fprintf(fp, "deallocate\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(fp, "unknown op type %d\n", tb->bmt_op);
|
||||
break;
|
||||
default:
|
||||
fprintf(fp, "unknown op type %d\n", tb->bmt_op);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1868,21 +1867,21 @@ _bm_die(Oid dbId, Oid relId, int blkNo, int bufNo,
|
||||
|
||||
switch (allocType)
|
||||
{
|
||||
case BMT_ALLOCFND:
|
||||
fprintf(fp, "allocate (found)\n");
|
||||
break;
|
||||
case BMT_ALLOCFND:
|
||||
fprintf(fp, "allocate (found)\n");
|
||||
break;
|
||||
|
||||
case BMT_ALLOCNOTFND:
|
||||
fprintf(fp, "allocate (not found)\n");
|
||||
break;
|
||||
case BMT_ALLOCNOTFND:
|
||||
fprintf(fp, "allocate (not found)\n");
|
||||
break;
|
||||
|
||||
case BMT_DEALLOC:
|
||||
fprintf(fp, "deallocate\n");
|
||||
break;
|
||||
case BMT_DEALLOC:
|
||||
fprintf(fp, "deallocate\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(fp, "unknown op type %d\n", allocType);
|
||||
break;
|
||||
default:
|
||||
fprintf(fp, "unknown op type %d\n", allocType);
|
||||
break;
|
||||
}
|
||||
|
||||
FreeFile(fp);
|
||||
@@ -1895,7 +1894,7 @@ _bm_die(Oid dbId, Oid relId, int blkNo, int bufNo,
|
||||
void
|
||||
BufferRefCountReset(int *refcountsave)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NBuffers; i++)
|
||||
{
|
||||
@@ -1908,7 +1907,7 @@ BufferRefCountReset(int *refcountsave)
|
||||
void
|
||||
BufferRefCountRestore(int *refcountsave)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NBuffers; i++)
|
||||
{
|
||||
@@ -1921,7 +1920,7 @@ BufferRefCountRestore(int *refcountsave)
|
||||
int
|
||||
SetBufferWriteMode(int mode)
|
||||
{
|
||||
int old;
|
||||
int old;
|
||||
|
||||
old = WriteMode;
|
||||
WriteMode = mode;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.5 1997/09/07 04:48:22 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.6 1997/09/08 02:28:33 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -84,7 +84,7 @@ AddBufferToFreelist(BufferDesc * bf)
|
||||
void
|
||||
PinBuffer(BufferDesc * buf)
|
||||
{
|
||||
long b;
|
||||
long b;
|
||||
|
||||
/* Assert (buf->refcount < 25); */
|
||||
|
||||
@@ -119,7 +119,7 @@ PinBuffer_Debug(char *file, int line, BufferDesc * buf)
|
||||
PinBuffer(buf);
|
||||
if (ShowPinTrace)
|
||||
{
|
||||
Buffer buffer = BufferDescriptorGetBuffer(buf);
|
||||
Buffer buffer = BufferDescriptorGetBuffer(buf);
|
||||
|
||||
fprintf(stderr, "PIN(Pin) %ld relname = %s, blockNum = %d, \
|
||||
refcount = %ld, file: %s, line: %d\n",
|
||||
@@ -138,7 +138,7 @@ refcount = %ld, file: %s, line: %d\n",
|
||||
void
|
||||
UnpinBuffer(BufferDesc * buf)
|
||||
{
|
||||
long b = BufferDescriptorGetBuffer(buf) - 1;
|
||||
long b = BufferDescriptorGetBuffer(buf) - 1;
|
||||
|
||||
Assert(buf->refcount);
|
||||
Assert(PrivateRefCount[b] > 0);
|
||||
@@ -165,7 +165,7 @@ UnpinBuffer_Debug(char *file, int line, BufferDesc * buf)
|
||||
UnpinBuffer(buf);
|
||||
if (ShowPinTrace)
|
||||
{
|
||||
Buffer buffer = BufferDescriptorGetBuffer(buf);
|
||||
Buffer buffer = BufferDescriptorGetBuffer(buf);
|
||||
|
||||
fprintf(stderr, "UNPIN(Unpin) %ld relname = %s, blockNum = %d, \
|
||||
refcount = %ld, file: %s, line: %d\n",
|
||||
@@ -180,10 +180,10 @@ refcount = %ld, file: %s, line: %d\n",
|
||||
* GetFreeBuffer() -- get the 'next' buffer from the freelist.
|
||||
*
|
||||
*/
|
||||
BufferDesc *
|
||||
BufferDesc *
|
||||
GetFreeBuffer()
|
||||
{
|
||||
BufferDesc *buf;
|
||||
BufferDesc *buf;
|
||||
|
||||
if (Free_List_Descriptor == SharedFreeList->freeNext)
|
||||
{
|
||||
@@ -242,8 +242,8 @@ InitFreeList(bool init)
|
||||
void
|
||||
DBG_FreeListCheck(int nfree)
|
||||
{
|
||||
int i;
|
||||
BufferDesc *buf;
|
||||
int i;
|
||||
BufferDesc *buf;
|
||||
|
||||
buf = &(BufferDescriptors[SharedFreeList->freeNext]);
|
||||
for (i = 0; i < nfree; i++, buf = &(BufferDescriptors[buf->freeNext]))
|
||||
@@ -291,7 +291,7 @@ DBG_FreeListCheck(int nfree)
|
||||
static void
|
||||
PrintBufferFreeList()
|
||||
{
|
||||
BufferDesc *buf;
|
||||
BufferDesc *buf;
|
||||
|
||||
if (SharedFreeList->freeNext == Free_List_Descriptor)
|
||||
{
|
||||
@@ -302,7 +302,7 @@ PrintBufferFreeList()
|
||||
buf = &(BufferDescriptors[SharedFreeList->freeNext]);
|
||||
for (;;)
|
||||
{
|
||||
int i = (buf - BufferDescriptors);
|
||||
int i = (buf - BufferDescriptors);
|
||||
|
||||
printf("[%-2d] (%s, %d) flags=0x%x, refcnt=%d %ld, nxt=%ld prv=%ld)\n",
|
||||
i, buf->sb_relname, buf->tag.blockNum,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.9 1997/09/07 04:48:23 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.10 1997/09/08 02:28:34 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -50,11 +50,11 @@
|
||||
|
||||
extern long int LocalBufferFlushCount;
|
||||
|
||||
int NLocBuffer = 64;
|
||||
BufferDesc *LocalBufferDescriptors = NULL;
|
||||
long *LocalRefCount = NULL;
|
||||
int NLocBuffer = 64;
|
||||
BufferDesc *LocalBufferDescriptors = NULL;
|
||||
long *LocalRefCount = NULL;
|
||||
|
||||
static int nextFreeLocalBuf = 0;
|
||||
static int nextFreeLocalBuf = 0;
|
||||
|
||||
/*#define LBDEBUG*/
|
||||
|
||||
@@ -62,11 +62,11 @@ static int nextFreeLocalBuf = 0;
|
||||
* LocalBufferAlloc -
|
||||
* allocate a local buffer. We do round robin allocation for now.
|
||||
*/
|
||||
BufferDesc *
|
||||
BufferDesc *
|
||||
LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr)
|
||||
{
|
||||
int i;
|
||||
BufferDesc *bufHdr = (BufferDesc *) NULL;
|
||||
int i;
|
||||
BufferDesc *bufHdr = (BufferDesc *) NULL;
|
||||
|
||||
if (blockNum == P_NEW)
|
||||
{
|
||||
@@ -99,7 +99,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr)
|
||||
/* need to get a new buffer (round robin for now) */
|
||||
for (i = 0; i < NLocBuffer; i++)
|
||||
{
|
||||
int b = (nextFreeLocalBuf + i) % NLocBuffer;
|
||||
int b = (nextFreeLocalBuf + i) % NLocBuffer;
|
||||
|
||||
if (LocalRefCount[b] == 0)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr)
|
||||
*/
|
||||
if (bufHdr->flags & BM_DIRTY)
|
||||
{
|
||||
Relation bufrel = RelationIdCacheGetRelation(bufHdr->tag.relId.relId);
|
||||
Relation bufrel = RelationIdCacheGetRelation(bufHdr->tag.relId.relId);
|
||||
|
||||
Assert(bufrel != NULL);
|
||||
|
||||
@@ -142,7 +142,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr)
|
||||
*/
|
||||
if (bufHdr->data == (SHMEM_OFFSET) 0)
|
||||
{
|
||||
char *data = (char *) malloc(BLCKSZ);
|
||||
char *data = (char *) malloc(BLCKSZ);
|
||||
|
||||
bufHdr->data = MAKE_OFFSET(data);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr)
|
||||
int
|
||||
WriteLocalBuffer(Buffer buffer, bool release)
|
||||
{
|
||||
int bufid;
|
||||
int bufid;
|
||||
|
||||
Assert(BufferIsLocal(buffer));
|
||||
|
||||
@@ -185,9 +185,9 @@ WriteLocalBuffer(Buffer buffer, bool release)
|
||||
int
|
||||
FlushLocalBuffer(Buffer buffer, bool release)
|
||||
{
|
||||
int bufid;
|
||||
Relation bufrel;
|
||||
BufferDesc *bufHdr;
|
||||
int bufid;
|
||||
Relation bufrel;
|
||||
BufferDesc *bufHdr;
|
||||
|
||||
Assert(BufferIsLocal(buffer));
|
||||
|
||||
@@ -221,7 +221,7 @@ FlushLocalBuffer(Buffer buffer, bool release)
|
||||
void
|
||||
InitLocalBuffer(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* these aren't going away. I'm not gonna use palloc.
|
||||
@@ -233,7 +233,7 @@ InitLocalBuffer(void)
|
||||
|
||||
for (i = 0; i < NLocBuffer; i++)
|
||||
{
|
||||
BufferDesc *buf = &LocalBufferDescriptors[i];
|
||||
BufferDesc *buf = &LocalBufferDescriptors[i];
|
||||
|
||||
/*
|
||||
* negative to indicate local buffer. This is tricky: shared
|
||||
@@ -258,12 +258,12 @@ InitLocalBuffer(void)
|
||||
void
|
||||
LocalBufferSync(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NLocBuffer; i++)
|
||||
{
|
||||
BufferDesc *buf = &LocalBufferDescriptors[i];
|
||||
Relation bufrel;
|
||||
BufferDesc *buf = &LocalBufferDescriptors[i];
|
||||
Relation bufrel;
|
||||
|
||||
if (buf->flags & BM_DIRTY)
|
||||
{
|
||||
@@ -290,11 +290,11 @@ LocalBufferSync(void)
|
||||
void
|
||||
ResetLocalBufferPool(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NLocBuffer; i++)
|
||||
{
|
||||
BufferDesc *buf = &LocalBufferDescriptors[i];
|
||||
BufferDesc *buf = &LocalBufferDescriptors[i];
|
||||
|
||||
buf->tag.relId.relId = InvalidOid;
|
||||
buf->flags &= ~BM_DIRTY;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Id: fd.c,v 1.23 1997/09/07 04:48:25 momjian Exp $
|
||||
* $Id: fd.c,v 1.24 1997/09/08 02:28:38 momjian Exp $
|
||||
*
|
||||
* NOTES:
|
||||
*
|
||||
@@ -99,33 +99,33 @@
|
||||
|
||||
typedef struct vfd
|
||||
{
|
||||
signed short fd;
|
||||
unsigned short fdstate;
|
||||
signed short fd;
|
||||
unsigned short fdstate;
|
||||
|
||||
#define FD_DIRTY (1 << 0)
|
||||
|
||||
File nextFree;
|
||||
File lruMoreRecently;
|
||||
File lruLessRecently;
|
||||
long seekPos;
|
||||
char *fileName;
|
||||
int fileFlags;
|
||||
int fileMode;
|
||||
} Vfd;
|
||||
File nextFree;
|
||||
File lruMoreRecently;
|
||||
File lruLessRecently;
|
||||
long seekPos;
|
||||
char *fileName;
|
||||
int fileFlags;
|
||||
int fileMode;
|
||||
} Vfd;
|
||||
|
||||
/*
|
||||
* Virtual File Descriptor array pointer and size. This grows as
|
||||
* needed.
|
||||
*/
|
||||
static Vfd *VfdCache;
|
||||
static Size SizeVfdCache = 0;
|
||||
static Vfd *VfdCache;
|
||||
static Size SizeVfdCache = 0;
|
||||
|
||||
/*
|
||||
* Number of file descriptors known to be open.
|
||||
*/
|
||||
static int nfile = 0;
|
||||
static int nfile = 0;
|
||||
|
||||
static char Sep_char = '/';
|
||||
static char Sep_char = '/';
|
||||
|
||||
/*
|
||||
* Private Routines
|
||||
@@ -154,23 +154,23 @@ static char Sep_char = '/';
|
||||
* FreeVfd - free a file record
|
||||
*
|
||||
*/
|
||||
static void Delete(File file);
|
||||
static void LruDelete(File file);
|
||||
static void Insert(File file);
|
||||
static int LruInsert(File file);
|
||||
static void AssertLruRoom(void);
|
||||
static File AllocateVfd(void);
|
||||
static void FreeVfd(File file);
|
||||
static void Delete(File file);
|
||||
static void LruDelete(File file);
|
||||
static void Insert(File file);
|
||||
static int LruInsert(File file);
|
||||
static void AssertLruRoom(void);
|
||||
static File AllocateVfd(void);
|
||||
static void FreeVfd(File file);
|
||||
|
||||
static int FileAccess(File file);
|
||||
static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
|
||||
static char *filepath(char *filename);
|
||||
static long pg_nofile(void);
|
||||
static int FileAccess(File file);
|
||||
static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
|
||||
static char *filepath(char *filename);
|
||||
static long pg_nofile(void);
|
||||
|
||||
int
|
||||
pg_fsync(int fd)
|
||||
{
|
||||
extern int fsyncOff;
|
||||
extern int fsyncOff;
|
||||
|
||||
return fsyncOff ? 0 : fsync(fd);
|
||||
}
|
||||
@@ -180,7 +180,7 @@ pg_fsync(int fd)
|
||||
long
|
||||
pg_nofile(void)
|
||||
{
|
||||
static long no_files = 0;
|
||||
static long no_files = 0;
|
||||
|
||||
if (no_files == 0)
|
||||
{
|
||||
@@ -207,9 +207,9 @@ pg_nofile(void)
|
||||
static void
|
||||
_dump_lru()
|
||||
{
|
||||
int mru = VfdCache[0].lruLessRecently;
|
||||
Vfd *vfdP = &VfdCache[mru];
|
||||
char buf[2048];
|
||||
int mru = VfdCache[0].lruLessRecently;
|
||||
Vfd *vfdP = &VfdCache[mru];
|
||||
char buf[2048];
|
||||
|
||||
sprintf(buf, "LRU: MOST %d ", mru);
|
||||
while (mru != 0)
|
||||
@@ -227,7 +227,7 @@ _dump_lru()
|
||||
static void
|
||||
Delete(File file)
|
||||
{
|
||||
Vfd *fileP;
|
||||
Vfd *fileP;
|
||||
|
||||
DO_DB(elog(DEBUG, "Delete %d (%s)",
|
||||
file, VfdCache[file].fileName));
|
||||
@@ -248,8 +248,8 @@ Delete(File file)
|
||||
static void
|
||||
LruDelete(File file)
|
||||
{
|
||||
Vfd *fileP;
|
||||
int returnValue;
|
||||
Vfd *fileP;
|
||||
int returnValue;
|
||||
|
||||
DO_DB(elog(DEBUG, "LruDelete %d (%s)",
|
||||
file, VfdCache[file].fileName));
|
||||
@@ -285,7 +285,7 @@ LruDelete(File file)
|
||||
static void
|
||||
Insert(File file)
|
||||
{
|
||||
Vfd *vfdP;
|
||||
Vfd *vfdP;
|
||||
|
||||
DO_DB(elog(DEBUG, "Insert %d (%s)",
|
||||
file, VfdCache[file].fileName));
|
||||
@@ -304,8 +304,8 @@ Insert(File file)
|
||||
static int
|
||||
LruInsert(File file)
|
||||
{
|
||||
Vfd *vfdP;
|
||||
int returnValue;
|
||||
Vfd *vfdP;
|
||||
int returnValue;
|
||||
|
||||
DO_DB(elog(DEBUG, "LruInsert %d (%s)",
|
||||
file, VfdCache[file].fileName));
|
||||
@@ -384,11 +384,11 @@ AssertLruRoom()
|
||||
LruDelete(VfdCache[0].lruMoreRecently);
|
||||
}
|
||||
|
||||
static File
|
||||
static File
|
||||
AllocateVfd()
|
||||
{
|
||||
Index i;
|
||||
File file;
|
||||
Index i;
|
||||
File file;
|
||||
|
||||
DO_DB(elog(DEBUG, "AllocateVfd. Size %d", SizeVfdCache));
|
||||
|
||||
@@ -458,12 +458,12 @@ FreeVfd(File file)
|
||||
VfdCache[0].nextFree = file;
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
filepath(char *filename)
|
||||
{
|
||||
char *buf;
|
||||
char basename[16];
|
||||
int len;
|
||||
char *buf;
|
||||
char basename[16];
|
||||
int len;
|
||||
|
||||
if (*filename != Sep_char)
|
||||
{
|
||||
@@ -488,7 +488,7 @@ filepath(char *filename)
|
||||
static int
|
||||
FileAccess(File file)
|
||||
{
|
||||
int returnValue;
|
||||
int returnValue;
|
||||
|
||||
DO_DB(elog(DEBUG, "FileAccess %d (%s)",
|
||||
file, VfdCache[file].fileName));
|
||||
@@ -539,13 +539,13 @@ FileInvalidate(File file)
|
||||
#endif
|
||||
|
||||
/* VARARGS2 */
|
||||
static File
|
||||
static File
|
||||
fileNameOpenFile(FileName fileName,
|
||||
int fileFlags,
|
||||
int fileMode)
|
||||
{
|
||||
File file;
|
||||
Vfd *vfdP;
|
||||
File file;
|
||||
Vfd *vfdP;
|
||||
|
||||
DO_DB(elog(DEBUG, "fileNameOpenFile: %s %x %o",
|
||||
fileName, fileFlags, fileMode));
|
||||
@@ -600,8 +600,8 @@ tryAgain:
|
||||
File
|
||||
FileNameOpenFile(FileName fileName, int fileFlags, int fileMode)
|
||||
{
|
||||
File fd;
|
||||
char *fname;
|
||||
File fd;
|
||||
char *fname;
|
||||
|
||||
fname = filepath(fileName);
|
||||
fd = fileNameOpenFile(fname, fileFlags, fileMode);
|
||||
@@ -621,7 +621,7 @@ PathNameOpenFile(FileName fileName, int fileFlags, int fileMode)
|
||||
void
|
||||
FileClose(File file)
|
||||
{
|
||||
int returnValue;
|
||||
int returnValue;
|
||||
|
||||
DO_DB(elog(DEBUG, "FileClose: %d (%s)",
|
||||
file, VfdCache[file].fileName));
|
||||
@@ -662,7 +662,7 @@ FileClose(File file)
|
||||
void
|
||||
FileUnlink(File file)
|
||||
{
|
||||
int returnValue;
|
||||
int returnValue;
|
||||
|
||||
DO_DB(elog(DEBUG, "FileUnlink: %d (%s)",
|
||||
file, VfdCache[file].fileName));
|
||||
@@ -699,7 +699,7 @@ FileUnlink(File file)
|
||||
int
|
||||
FileRead(File file, char *buffer, int amount)
|
||||
{
|
||||
int returnCode;
|
||||
int returnCode;
|
||||
|
||||
DO_DB(elog(DEBUG, "FileRead: %d (%s) %d %p",
|
||||
file, VfdCache[file].fileName, amount, buffer));
|
||||
@@ -717,7 +717,7 @@ FileRead(File file, char *buffer, int amount)
|
||||
int
|
||||
FileWrite(File file, char *buffer, int amount)
|
||||
{
|
||||
int returnCode;
|
||||
int returnCode;
|
||||
|
||||
DO_DB(elog(DEBUG, "FileWrite: %d (%s) %d %p",
|
||||
file, VfdCache[file].fileName, amount, buffer));
|
||||
@@ -738,7 +738,7 @@ FileWrite(File file, char *buffer, int amount)
|
||||
long
|
||||
FileSeek(File file, long offset, int whence)
|
||||
{
|
||||
int returnCode;
|
||||
int returnCode;
|
||||
|
||||
DO_DB(elog(DEBUG, "FileSeek: %d (%s) %ld %d",
|
||||
file, VfdCache[file].fileName, offset, whence));
|
||||
@@ -747,20 +747,20 @@ FileSeek(File file, long offset, int whence)
|
||||
{
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
VfdCache[file].seekPos = offset;
|
||||
return offset;
|
||||
case SEEK_CUR:
|
||||
VfdCache[file].seekPos = VfdCache[file].seekPos + offset;
|
||||
return VfdCache[file].seekPos;
|
||||
case SEEK_END:
|
||||
FileAccess(file);
|
||||
returnCode = VfdCache[file].seekPos =
|
||||
lseek(VfdCache[file].fd, offset, whence);
|
||||
return returnCode;
|
||||
default:
|
||||
elog(WARN, "FileSeek: invalid whence: %d", whence);
|
||||
break;
|
||||
case SEEK_SET:
|
||||
VfdCache[file].seekPos = offset;
|
||||
return offset;
|
||||
case SEEK_CUR:
|
||||
VfdCache[file].seekPos = VfdCache[file].seekPos + offset;
|
||||
return VfdCache[file].seekPos;
|
||||
case SEEK_END:
|
||||
FileAccess(file);
|
||||
returnCode = VfdCache[file].seekPos =
|
||||
lseek(VfdCache[file].fd, offset, whence);
|
||||
return returnCode;
|
||||
default:
|
||||
elog(WARN, "FileSeek: invalid whence: %d", whence);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -790,7 +790,7 @@ FileTell(File file)
|
||||
int
|
||||
FileTruncate(File file, int offset)
|
||||
{
|
||||
int returnCode;
|
||||
int returnCode;
|
||||
|
||||
DO_DB(elog(DEBUG, "FileTruncate %d (%s)",
|
||||
file, VfdCache[file].fileName));
|
||||
@@ -804,7 +804,7 @@ FileTruncate(File file, int offset)
|
||||
int
|
||||
FileSync(File file)
|
||||
{
|
||||
int returnCode;
|
||||
int returnCode;
|
||||
|
||||
/*
|
||||
* If the file isn't open, then we don't need to sync it; we always
|
||||
@@ -828,8 +828,8 @@ FileSync(File file)
|
||||
int
|
||||
FileNameUnlink(char *filename)
|
||||
{
|
||||
int retval;
|
||||
char *fname;
|
||||
int retval;
|
||||
char *fname;
|
||||
|
||||
fname = filepath(filename);
|
||||
retval = unlink(fname);
|
||||
@@ -846,13 +846,13 @@ FileNameUnlink(char *filename)
|
||||
* allocatedFiles keeps track of how many have been allocated so we
|
||||
* can give a warning if there are too few left.
|
||||
*/
|
||||
static int allocatedFiles = 0;
|
||||
static int allocatedFiles = 0;
|
||||
|
||||
FILE *
|
||||
FILE *
|
||||
AllocateFile(char *name, char *mode)
|
||||
{
|
||||
FILE *file;
|
||||
int fdleft;
|
||||
FILE *file;
|
||||
int fdleft;
|
||||
|
||||
DO_DB(elog(DEBUG, "AllocateFile: Allocated %d.", allocatedFiles));
|
||||
|
||||
@@ -895,7 +895,7 @@ FreeFile(FILE * file)
|
||||
void
|
||||
closeAllVfds()
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */
|
||||
for (i = 1; i < SizeVfdCache; i++)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.12 1997/09/07 04:48:30 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.13 1997/09/08 02:28:44 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -44,14 +44,14 @@
|
||||
#endif
|
||||
|
||||
#if defined(bsd44)
|
||||
int UsePrivateMemory = 1;
|
||||
int UsePrivateMemory = 1;
|
||||
|
||||
#else
|
||||
int UsePrivateMemory = 0;
|
||||
int UsePrivateMemory = 0;
|
||||
|
||||
#endif
|
||||
|
||||
static void IpcMemoryDetach(int status, char *shmaddr);
|
||||
static void IpcMemoryDetach(int status, char *shmaddr);
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* exit() handling stuff
|
||||
@@ -62,26 +62,26 @@ static void IpcMemoryDetach(int status, char *shmaddr);
|
||||
|
||||
static struct ONEXIT
|
||||
{
|
||||
void (*function) ();
|
||||
caddr_t arg;
|
||||
} onexit_list[MAX_ON_EXITS];
|
||||
void (*function) ();
|
||||
caddr_t arg;
|
||||
} onexit_list[MAX_ON_EXITS];
|
||||
|
||||
static int onexit_index;
|
||||
static void IpcConfigTip(void);
|
||||
static int onexit_index;
|
||||
static void IpcConfigTip(void);
|
||||
|
||||
typedef struct _PrivateMemStruct
|
||||
{
|
||||
int id;
|
||||
char *memptr;
|
||||
} PrivateMem;
|
||||
int id;
|
||||
char *memptr;
|
||||
} PrivateMem;
|
||||
|
||||
PrivateMem IpcPrivateMem[16];
|
||||
PrivateMem IpcPrivateMem[16];
|
||||
|
||||
static int
|
||||
PrivateMemoryCreate(IpcMemoryKey memKey,
|
||||
uint32 size)
|
||||
{
|
||||
static int memid = 0;
|
||||
static int memid = 0;
|
||||
|
||||
UsePrivateMemory = 1;
|
||||
|
||||
@@ -94,7 +94,7 @@ PrivateMemoryCreate(IpcMemoryKey memKey,
|
||||
return (memid++);
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
PrivateMemoryAttach(IpcMemoryId memid)
|
||||
{
|
||||
return (IpcPrivateMem[memid].memptr);
|
||||
@@ -110,12 +110,12 @@ PrivateMemoryAttach(IpcMemoryId memid)
|
||||
* -cim 2/6/90
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static int exitpg_inprogress = 0;
|
||||
static int exitpg_inprogress = 0;
|
||||
|
||||
void
|
||||
exitpg(int code)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/* ----------------
|
||||
* if exitpg_inprocess is true, then it means that we
|
||||
@@ -147,7 +147,7 @@ exitpg(int code)
|
||||
void
|
||||
quasi_exitpg()
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/* ----------------
|
||||
* if exitpg_inprocess is true, then it means that we
|
||||
@@ -179,7 +179,7 @@ quasi_exitpg()
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
on_exitpg(void (*function) (), caddr_t arg)
|
||||
on_exitpg(void (*function) (), caddr_t arg)
|
||||
{
|
||||
if (onexit_index >= MAX_ON_EXITS)
|
||||
return (-1);
|
||||
@@ -200,7 +200,7 @@ static void
|
||||
IPCPrivateSemaphoreKill(int status,
|
||||
int semId) /* caddr_t */
|
||||
{
|
||||
union semun semun;
|
||||
union semun semun;
|
||||
|
||||
semctl(semId, 0, IPC_RMID, semun);
|
||||
}
|
||||
@@ -259,11 +259,11 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
|
||||
int removeOnExit,
|
||||
int *status)
|
||||
{
|
||||
int i;
|
||||
int errStatus;
|
||||
int semId;
|
||||
u_short array[IPC_NMAXSEM];
|
||||
union semun semun;
|
||||
int i;
|
||||
int errStatus;
|
||||
int semId;
|
||||
u_short array[IPC_NMAXSEM];
|
||||
union semun semun;
|
||||
|
||||
/* get a semaphore if non-existent */
|
||||
/* check arguments */
|
||||
@@ -332,13 +332,13 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
|
||||
/* note: the xxx_return variables are only used for debugging. */
|
||||
/****************************************************************************/
|
||||
#ifdef NOT_USED
|
||||
static int IpcSemaphoreSet_return;
|
||||
static int IpcSemaphoreSet_return;
|
||||
|
||||
void
|
||||
IpcSemaphoreSet(int semId, int semno, int value)
|
||||
{
|
||||
int errStatus;
|
||||
union semun semun;
|
||||
int errStatus;
|
||||
union semun semun;
|
||||
|
||||
semun.val = value;
|
||||
errStatus = semctl(semId, semno, SETVAL, semun);
|
||||
@@ -360,8 +360,8 @@ IpcSemaphoreSet(int semId, int semno, int value)
|
||||
void
|
||||
IpcSemaphoreKill(IpcSemaphoreKey key)
|
||||
{
|
||||
int semId;
|
||||
union semun semun;
|
||||
int semId;
|
||||
union semun semun;
|
||||
|
||||
/* kill semaphore if existent */
|
||||
|
||||
@@ -375,14 +375,14 @@ IpcSemaphoreKill(IpcSemaphoreKey key)
|
||||
/* */
|
||||
/* note: the xxx_return variables are only used for debugging. */
|
||||
/****************************************************************************/
|
||||
static int IpcSemaphoreLock_return;
|
||||
static int IpcSemaphoreLock_return;
|
||||
|
||||
void
|
||||
IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock)
|
||||
{
|
||||
extern int errno;
|
||||
int errStatus;
|
||||
struct sembuf sops;
|
||||
extern int errno;
|
||||
int errStatus;
|
||||
struct sembuf sops;
|
||||
|
||||
sops.sem_op = lock;
|
||||
sops.sem_flg = 0;
|
||||
@@ -419,14 +419,14 @@ IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock)
|
||||
/* */
|
||||
/* note: the xxx_return variables are only used for debugging. */
|
||||
/****************************************************************************/
|
||||
static int IpcSemaphoreUnlock_return;
|
||||
static int IpcSemaphoreUnlock_return;
|
||||
|
||||
void
|
||||
IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock)
|
||||
{
|
||||
extern int errno;
|
||||
int errStatus;
|
||||
struct sembuf sops;
|
||||
extern int errno;
|
||||
int errStatus;
|
||||
struct sembuf sops;
|
||||
|
||||
sops.sem_op = -lock;
|
||||
sops.sem_flg = 0;
|
||||
@@ -462,8 +462,8 @@ IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock)
|
||||
int
|
||||
IpcSemaphoreGetCount(IpcSemaphoreId semId, int sem)
|
||||
{
|
||||
int semncnt;
|
||||
union semun dummy; /* for Solaris */
|
||||
int semncnt;
|
||||
union semun dummy; /* for Solaris */
|
||||
|
||||
semncnt = semctl(semId, sem, GETNCNT, dummy);
|
||||
return semncnt;
|
||||
@@ -472,8 +472,8 @@ IpcSemaphoreGetCount(IpcSemaphoreId semId, int sem)
|
||||
int
|
||||
IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem)
|
||||
{
|
||||
int semval;
|
||||
union semun dummy; /* for Solaris */
|
||||
int semval;
|
||||
union semun dummy; /* for Solaris */
|
||||
|
||||
semval = semctl(semId, sem, GETVAL, dummy);
|
||||
return semval;
|
||||
@@ -489,7 +489,7 @@ IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem)
|
||||
IpcMemoryId
|
||||
IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission)
|
||||
{
|
||||
IpcMemoryId shmid;
|
||||
IpcMemoryId shmid;
|
||||
|
||||
if (memKey == PrivateIPCKey)
|
||||
{
|
||||
@@ -523,7 +523,7 @@ IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission)
|
||||
IpcMemoryId
|
||||
IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size)
|
||||
{
|
||||
IpcMemoryId shmid;
|
||||
IpcMemoryId shmid;
|
||||
|
||||
shmid = shmget(memKey, size, 0);
|
||||
|
||||
@@ -560,10 +560,10 @@ IpcMemoryDetach(int status, char *shmaddr)
|
||||
/* CALL IT: addr = (struct <MemoryStructure> *) IpcMemoryAttach(memId); */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
char *
|
||||
char *
|
||||
IpcMemoryAttach(IpcMemoryId memId)
|
||||
{
|
||||
char *memAddress;
|
||||
char *memAddress;
|
||||
|
||||
if (UsePrivateMemory)
|
||||
{
|
||||
@@ -596,7 +596,7 @@ IpcMemoryAttach(IpcMemoryId memId)
|
||||
void
|
||||
IpcMemoryKill(IpcMemoryKey memKey)
|
||||
{
|
||||
IpcMemoryId shmid;
|
||||
IpcMemoryId shmid;
|
||||
|
||||
if (!UsePrivateMemory && (shmid = shmget(memKey, 0, 0)) >= 0)
|
||||
{
|
||||
@@ -615,26 +615,26 @@ IpcMemoryKill(IpcMemoryKey memKey)
|
||||
* supply of locks.
|
||||
* ------------------
|
||||
*/
|
||||
static SLock *SLockArray = NULL;
|
||||
static SLock **FreeSLockPP;
|
||||
static int *UnusedSLockIP;
|
||||
static SLock *SLockArray = NULL;
|
||||
static SLock **FreeSLockPP;
|
||||
static int *UnusedSLockIP;
|
||||
static slock_t *SLockMemoryLock;
|
||||
static IpcMemoryId SLockMemoryId = -1;
|
||||
|
||||
struct ipcdummy
|
||||
{ /* to get alignment/size right */
|
||||
SLock *free;
|
||||
int unused;
|
||||
slock_t memlock;
|
||||
SLock slocks[NSLOCKS];
|
||||
SLock *free;
|
||||
int unused;
|
||||
slock_t memlock;
|
||||
SLock slocks[NSLOCKS];
|
||||
};
|
||||
static int SLockMemorySize = sizeof(struct ipcdummy);
|
||||
static int SLockMemorySize = sizeof(struct ipcdummy);
|
||||
|
||||
void
|
||||
CreateAndInitSLockMemory(IPCKey key)
|
||||
{
|
||||
int id;
|
||||
SLock *slckP;
|
||||
int id;
|
||||
SLock *slckP;
|
||||
|
||||
SLockMemoryId = IpcMemoryCreate(key,
|
||||
SLockMemorySize,
|
||||
@@ -687,7 +687,7 @@ shlock = %d, exlock =%d)\n", LOCK->locklock, \
|
||||
void
|
||||
ExclusiveLock(int lockid)
|
||||
{
|
||||
SLock *slckP;
|
||||
SLock *slckP;
|
||||
|
||||
slckP = &(SLockArray[lockid]);
|
||||
#ifdef LOCKDEBUG
|
||||
@@ -699,29 +699,29 @@ ex_try_again:
|
||||
S_LOCK(&(slckP->locklock));
|
||||
switch (slckP->flag)
|
||||
{
|
||||
case NOLOCK:
|
||||
slckP->flag = EXCLUSIVELOCK;
|
||||
S_LOCK(&(slckP->exlock));
|
||||
S_LOCK(&(slckP->shlock));
|
||||
S_UNLOCK(&(slckP->locklock));
|
||||
case NOLOCK:
|
||||
slckP->flag = EXCLUSIVELOCK;
|
||||
S_LOCK(&(slckP->exlock));
|
||||
S_LOCK(&(slckP->shlock));
|
||||
S_UNLOCK(&(slckP->locklock));
|
||||
#ifdef LOCKDEBUG
|
||||
printf("OUT: ");
|
||||
PRINT_LOCK(slckP);
|
||||
printf("OUT: ");
|
||||
PRINT_LOCK(slckP);
|
||||
#endif
|
||||
return;
|
||||
case SHAREDLOCK:
|
||||
case EXCLUSIVELOCK:
|
||||
S_UNLOCK(&(slckP->locklock));
|
||||
S_LOCK(&(slckP->exlock));
|
||||
S_UNLOCK(&(slckP->exlock));
|
||||
goto ex_try_again;
|
||||
return;
|
||||
case SHAREDLOCK:
|
||||
case EXCLUSIVELOCK:
|
||||
S_UNLOCK(&(slckP->locklock));
|
||||
S_LOCK(&(slckP->exlock));
|
||||
S_UNLOCK(&(slckP->exlock));
|
||||
goto ex_try_again;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ExclusiveUnlock(int lockid)
|
||||
{
|
||||
SLock *slckP;
|
||||
SLock *slckP;
|
||||
|
||||
slckP = &(SLockArray[lockid]);
|
||||
#ifdef LOCKDEBUG
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.6 1997/09/07 04:48:33 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.7 1997/09/08 02:28:48 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -57,7 +57,7 @@ SystemPortAddressCreateIPCKey(SystemPortAddress address)
|
||||
void
|
||||
CreateSharedMemoryAndSemaphores(IPCKey key)
|
||||
{
|
||||
int size;
|
||||
int size;
|
||||
|
||||
#ifdef HAS_TEST_AND_SET
|
||||
/* ---------------
|
||||
@@ -114,7 +114,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key)
|
||||
void
|
||||
AttachSharedMemoryAndSemaphores(IPCKey key)
|
||||
{
|
||||
int size;
|
||||
int size;
|
||||
|
||||
/* ----------------
|
||||
* create rather than attach if using private key
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.22 1997/09/07 04:48:35 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.23 1997/09/08 02:28:51 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -161,7 +161,7 @@ S_LOCK_FREE(slock_t * lock)
|
||||
defined(sparc_solaris)
|
||||
/* for xxxxx_solaris, this is defined in port/.../tas.s */
|
||||
|
||||
static int tas(slock_t * lock);
|
||||
static int tas(slock_t * lock);
|
||||
|
||||
void
|
||||
S_LOCK(slock_t * lock)
|
||||
@@ -227,9 +227,9 @@ S_INIT_LOCK(slock_t * lock)
|
||||
* a "set" slock_t has a single word cleared. a "clear" slock_t has
|
||||
* all words set to non-zero.
|
||||
*/
|
||||
static slock_t clear_lock = {-1, -1, -1, -1};
|
||||
static slock_t clear_lock = {-1, -1, -1, -1};
|
||||
|
||||
static int tas(slock_t * lock);
|
||||
static int tas(slock_t * lock);
|
||||
|
||||
void
|
||||
S_LOCK(slock_t * lock)
|
||||
@@ -253,7 +253,7 @@ S_INIT_LOCK(slock_t * lock)
|
||||
int
|
||||
S_LOCK_FREE(slock_t * lock)
|
||||
{
|
||||
register int *lock_word = (int *) (((long) lock + 15) & ~15);
|
||||
register int *lock_word = (int *) (((long) lock + 15) & ~15);
|
||||
|
||||
return (*lock_word != 0);
|
||||
}
|
||||
@@ -266,7 +266,7 @@ S_LOCK_FREE(slock_t * lock)
|
||||
|
||||
#if defined(sun3)
|
||||
|
||||
static int tas(slock_t * lock);
|
||||
static int tas(slock_t * lock);
|
||||
|
||||
void
|
||||
S_LOCK(slock_t * lock)
|
||||
@@ -320,7 +320,7 @@ tas_dummy()
|
||||
#define asm(x) __asm__(x)
|
||||
#endif
|
||||
|
||||
static int tas(slock_t * lock);
|
||||
static int tas(slock_t * lock);
|
||||
|
||||
static int
|
||||
tas_dummy()
|
||||
@@ -388,7 +388,7 @@ S_INIT_LOCK(unsigned char *addr)
|
||||
void
|
||||
S_LOCK(slock_t * lock)
|
||||
{
|
||||
slock_t res;
|
||||
slock_t res;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -416,7 +416,7 @@ S_INIT_LOCK(slock_t * lock)
|
||||
void
|
||||
S_LOCK(slock_t * lock)
|
||||
{
|
||||
slock_t res;
|
||||
slock_t res;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -456,7 +456,7 @@ S_INIT_LOCK(slock_t * lock)
|
||||
void
|
||||
S_LOCK(slock_t * lock)
|
||||
{
|
||||
slock_t res;
|
||||
slock_t res;
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.11 1997/09/07 04:48:37 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.12 1997/09/08 02:28:53 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -70,23 +70,23 @@
|
||||
|
||||
/* shared memory global variables */
|
||||
|
||||
unsigned long ShmemBase = 0; /* start and end address of shared memory */
|
||||
unsigned long ShmemBase = 0; /* start and end address of shared memory */
|
||||
static unsigned long ShmemEnd = 0;
|
||||
static unsigned long ShmemSize = 0; /* current size (and default) */
|
||||
|
||||
SPINLOCK ShmemLock; /* lock for shared memory allocation */
|
||||
SPINLOCK ShmemLock; /* lock for shared memory allocation */
|
||||
|
||||
SPINLOCK BindingLock; /* lock for binding table access */
|
||||
SPINLOCK BindingLock; /* lock for binding table access */
|
||||
|
||||
static unsigned long *ShmemFreeStart = NULL; /* pointer to the OFFSET
|
||||
* of first free shared
|
||||
* memory */
|
||||
static unsigned long *ShmemBindingTabOffset = NULL; /* start of the binding
|
||||
* table (for bootstrap) */
|
||||
static int ShmemBootstrap = FALSE; /* flag becomes true when shared
|
||||
static int ShmemBootstrap = FALSE; /* flag becomes true when shared
|
||||
* mem is created by POSTMASTER */
|
||||
|
||||
static HTAB *BindingTable = NULL;
|
||||
static HTAB *BindingTable = NULL;
|
||||
|
||||
/* ---------------------
|
||||
* ShmemBindingTabReset() - Resets the binding table to NULL....
|
||||
@@ -142,15 +142,15 @@ ShmemCreate(unsigned int key, unsigned int size)
|
||||
int
|
||||
InitShmem(unsigned int key, unsigned int size)
|
||||
{
|
||||
Pointer sharedRegion;
|
||||
unsigned long currFreeSpace;
|
||||
Pointer sharedRegion;
|
||||
unsigned long currFreeSpace;
|
||||
|
||||
HASHCTL info;
|
||||
int hash_flags;
|
||||
BindingEnt *result,
|
||||
item;
|
||||
bool found;
|
||||
IpcMemoryId shmid;
|
||||
HASHCTL info;
|
||||
int hash_flags;
|
||||
BindingEnt *result,
|
||||
item;
|
||||
bool found;
|
||||
IpcMemoryId shmid;
|
||||
|
||||
/* if zero key, use default memory size */
|
||||
if (size)
|
||||
@@ -223,8 +223,8 @@ InitShmem(unsigned int key, unsigned int size)
|
||||
|
||||
/*
|
||||
* Now, check the binding table for an entry to the binding table. If
|
||||
* there is an entry there, someone else created the table.
|
||||
* Otherwise, we did and we have to initialize it.
|
||||
* there is an entry there, someone else created the table. Otherwise,
|
||||
* we did and we have to initialize it.
|
||||
*/
|
||||
memset(item.key, 0, BTABLE_KEYSIZE);
|
||||
strncpy(item.key, "BindingTable", BTABLE_KEYSIZE);
|
||||
@@ -276,11 +276,11 @@ InitShmem(unsigned int key, unsigned int size)
|
||||
* of space. Has to return a real pointer in order
|
||||
* to be compatable with malloc().
|
||||
*/
|
||||
long *
|
||||
long *
|
||||
ShmemAlloc(unsigned long size)
|
||||
{
|
||||
unsigned long tmpFree;
|
||||
long *newSpace;
|
||||
unsigned long tmpFree;
|
||||
long *newSpace;
|
||||
|
||||
/*
|
||||
* ensure space is word aligned.
|
||||
@@ -338,15 +338,15 @@ ShmemIsValid(unsigned long addr)
|
||||
* table at once. Use SpinAlloc() to create a spinlock
|
||||
* for the structure before creating the structure itself.
|
||||
*/
|
||||
HTAB *
|
||||
HTAB *
|
||||
ShmemInitHash(char *name, /* table string name for binding */
|
||||
long init_size, /* initial size */
|
||||
long max_size, /* max size of the table */
|
||||
HASHCTL * infoP, /* info about key and bucket size */
|
||||
int hash_flags) /* info about infoP */
|
||||
{
|
||||
bool found;
|
||||
long *location;
|
||||
bool found;
|
||||
long *location;
|
||||
|
||||
/*
|
||||
* shared memory hash tables have a fixed max size so that the control
|
||||
@@ -402,9 +402,9 @@ ShmemInitHash(char *name, /* table string name for binding */
|
||||
bool
|
||||
ShmemPIDLookup(int pid, SHMEM_OFFSET * locationPtr)
|
||||
{
|
||||
BindingEnt *result,
|
||||
item;
|
||||
bool found;
|
||||
BindingEnt *result,
|
||||
item;
|
||||
bool found;
|
||||
|
||||
Assert(BindingTable);
|
||||
memset(item.key, 0, BTABLE_KEYSIZE);
|
||||
@@ -448,10 +448,10 @@ ShmemPIDLookup(int pid, SHMEM_OFFSET * locationPtr)
|
||||
SHMEM_OFFSET
|
||||
ShmemPIDDestroy(int pid)
|
||||
{
|
||||
BindingEnt *result,
|
||||
item;
|
||||
bool found;
|
||||
SHMEM_OFFSET location = 0;
|
||||
BindingEnt *result,
|
||||
item;
|
||||
bool found;
|
||||
SHMEM_OFFSET location = 0;
|
||||
|
||||
Assert(BindingTable);
|
||||
|
||||
@@ -496,12 +496,12 @@ ShmemPIDDestroy(int pid)
|
||||
* the object is already in the binding table (hence, already
|
||||
* initialized).
|
||||
*/
|
||||
long *
|
||||
long *
|
||||
ShmemInitStruct(char *name, unsigned long size, bool * foundPtr)
|
||||
{
|
||||
BindingEnt *result,
|
||||
item;
|
||||
long *structPtr;
|
||||
BindingEnt *result,
|
||||
item;
|
||||
long *structPtr;
|
||||
|
||||
strncpy(item.key, name, BTABLE_KEYSIZE);
|
||||
item.location = BAD_LOCATION;
|
||||
@@ -512,7 +512,7 @@ ShmemInitStruct(char *name, unsigned long size, bool * foundPtr)
|
||||
{
|
||||
/* Assert() is a macro now. substitutes inside quotes. */
|
||||
#ifndef NO_ASSERT_CHECKING
|
||||
char *strname = "BindingTable";
|
||||
char *strname = "BindingTable";
|
||||
|
||||
#endif
|
||||
|
||||
@@ -613,8 +613,8 @@ ShmemInitStruct(char *name, unsigned long size, bool * foundPtr)
|
||||
bool
|
||||
TransactionIdIsInProgress(TransactionId xid)
|
||||
{
|
||||
BindingEnt *result;
|
||||
PROC *proc;
|
||||
BindingEnt *result;
|
||||
PROC *proc;
|
||||
|
||||
Assert(BindingTable);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.4 1997/09/07 04:48:42 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.5 1997/09/08 02:28:56 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@@ -76,8 +76,8 @@ SHMQueueElemInit(SHM_QUEUE * queue)
|
||||
void
|
||||
SHMQueueDelete(SHM_QUEUE * queue)
|
||||
{
|
||||
SHM_QUEUE *nextElem = (SHM_QUEUE *) MAKE_PTR((queue)->next);
|
||||
SHM_QUEUE *prevElem = (SHM_QUEUE *) MAKE_PTR((queue)->prev);
|
||||
SHM_QUEUE *nextElem = (SHM_QUEUE *) MAKE_PTR((queue)->next);
|
||||
SHM_QUEUE *prevElem = (SHM_QUEUE *) MAKE_PTR((queue)->prev);
|
||||
|
||||
Assert(SHM_PTR_VALID(queue));
|
||||
Assert(SHM_PTR_VALID(nextElem));
|
||||
@@ -99,10 +99,10 @@ SHMQueueDelete(SHM_QUEUE * queue)
|
||||
void
|
||||
dumpQ(SHM_QUEUE * q, char *s)
|
||||
{
|
||||
char elem[16];
|
||||
char buf[1024];
|
||||
SHM_QUEUE *start = q;
|
||||
int count = 0;
|
||||
char elem[16];
|
||||
char buf[1024];
|
||||
SHM_QUEUE *start = q;
|
||||
int count = 0;
|
||||
|
||||
sprintf(buf, "q prevs: %x", MAKE_OFFSET(q));
|
||||
q = (SHM_QUEUE *) MAKE_PTR(q->prev);
|
||||
@@ -154,8 +154,8 @@ dumpQ(SHM_QUEUE * q, char *s)
|
||||
void
|
||||
SHMQueueInsertHD(SHM_QUEUE * queue, SHM_QUEUE * elem)
|
||||
{
|
||||
SHM_QUEUE *prevPtr = (SHM_QUEUE *) MAKE_PTR((queue)->prev);
|
||||
SHMEM_OFFSET elemOffset = MAKE_OFFSET(elem);
|
||||
SHM_QUEUE *prevPtr = (SHM_QUEUE *) MAKE_PTR((queue)->prev);
|
||||
SHMEM_OFFSET elemOffset = MAKE_OFFSET(elem);
|
||||
|
||||
Assert(SHM_PTR_VALID(queue));
|
||||
Assert(SHM_PTR_VALID(elem));
|
||||
@@ -179,8 +179,8 @@ SHMQueueInsertHD(SHM_QUEUE * queue, SHM_QUEUE * elem)
|
||||
void
|
||||
SHMQueueInsertTL(SHM_QUEUE * queue, SHM_QUEUE * elem)
|
||||
{
|
||||
SHM_QUEUE *nextPtr = (SHM_QUEUE *) MAKE_PTR((queue)->next);
|
||||
SHMEM_OFFSET elemOffset = MAKE_OFFSET(elem);
|
||||
SHM_QUEUE *nextPtr = (SHM_QUEUE *) MAKE_PTR((queue)->next);
|
||||
SHMEM_OFFSET elemOffset = MAKE_OFFSET(elem);
|
||||
|
||||
Assert(SHM_PTR_VALID(queue));
|
||||
Assert(SHM_PTR_VALID(elem));
|
||||
@@ -224,7 +224,7 @@ SHMQueueInsertTL(SHM_QUEUE * queue, SHM_QUEUE * elem)
|
||||
void
|
||||
SHMQueueFirst(SHM_QUEUE * queue, Pointer * nextPtrPtr, SHM_QUEUE * nextQueue)
|
||||
{
|
||||
SHM_QUEUE *elemPtr = (SHM_QUEUE *) MAKE_PTR((queue)->next);
|
||||
SHM_QUEUE *elemPtr = (SHM_QUEUE *) MAKE_PTR((queue)->next);
|
||||
|
||||
Assert(SHM_PTR_VALID(queue));
|
||||
*nextPtrPtr = (Pointer) (((unsigned long) *nextPtrPtr) +
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.8 1997/09/07 04:48:43 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.9 1997/09/08 02:28:59 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -22,13 +22,13 @@
|
||||
#include "storage/sinvaladt.h"
|
||||
#include "storage/spin.h"
|
||||
|
||||
extern SISeg *shmInvalBuffer; /* the shared buffer segment, set by */
|
||||
extern SISeg *shmInvalBuffer; /* the shared buffer segment, set by */
|
||||
|
||||
/* SISegmentAttach() */
|
||||
extern BackendId MyBackendId;
|
||||
extern BackendTag MyBackendTag;
|
||||
|
||||
SPINLOCK SInvalLock = (SPINLOCK) NULL;
|
||||
SPINLOCK SInvalLock = (SPINLOCK) NULL;
|
||||
|
||||
/****************************************************************************/
|
||||
/* CreateSharedInvalidationState(key) Create a buffer segment */
|
||||
@@ -38,7 +38,7 @@ SPINLOCK SInvalLock = (SPINLOCK) NULL;
|
||||
void
|
||||
CreateSharedInvalidationState(IPCKey key)
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
|
||||
/*
|
||||
* REMOVED SISyncKill(IPCKeyGetSIBufferMemorySemaphoreKey(key));
|
||||
@@ -62,7 +62,7 @@ CreateSharedInvalidationState(IPCKey key)
|
||||
void
|
||||
AttachSharedInvalidationState(IPCKey key)
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
|
||||
if (key == PrivateIPCKey)
|
||||
{
|
||||
@@ -165,8 +165,8 @@ RegisterSharedInvalid(int cacheId, /* XXX */
|
||||
/* should be called by a backend */
|
||||
/****************************************************************************/
|
||||
void
|
||||
InvalidateSharedInvalid(void (*invalFunction) (),
|
||||
void (*resetFunction) ())
|
||||
InvalidateSharedInvalid(void (*invalFunction) (),
|
||||
void (*resetFunction) ())
|
||||
{
|
||||
SpinAcquire(SInvalLock);
|
||||
SIReadEntryData(shmInvalBuffer, MyBackendId,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.6 1997/09/07 04:48:44 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.7 1997/09/08 02:29:01 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -49,19 +49,19 @@
|
||||
* ----------------
|
||||
*/
|
||||
#ifdef HAS_TEST_AND_SET
|
||||
int SharedInvalidationLockId;
|
||||
int SharedInvalidationLockId;
|
||||
|
||||
#else
|
||||
IpcSemaphoreId SharedInvalidationSemaphore;
|
||||
IpcSemaphoreId SharedInvalidationSemaphore;
|
||||
|
||||
#endif
|
||||
|
||||
SISeg *shmInvalBuffer;
|
||||
SISeg *shmInvalBuffer;
|
||||
extern BackendId MyBackendId;
|
||||
|
||||
static void CleanupInvalidationState(int status, SISeg * segInOutP);
|
||||
static void CleanupInvalidationState(int status, SISeg * segInOutP);
|
||||
static BackendId SIAssignBackendId(SISeg * segInOutP, BackendTag backendTag);
|
||||
static int SIGetNumEntries(SISeg * segP);
|
||||
static int SIGetNumEntries(SISeg * segP);
|
||||
|
||||
/************************************************************************/
|
||||
/* SISetActiveProcess(segP, backendId) set the backend status active */
|
||||
@@ -85,8 +85,8 @@ SISetActiveProcess(SISeg * segInOutP, BackendId backendId)
|
||||
int
|
||||
SIBackendInit(SISeg * segInOutP)
|
||||
{
|
||||
LRelId LtCreateRelId();
|
||||
TransactionId LMITransactionIdCopy();
|
||||
LRelId LtCreateRelId();
|
||||
TransactionId LMITransactionIdCopy();
|
||||
|
||||
Assert(MyBackendTag > 0);
|
||||
|
||||
@@ -108,11 +108,11 @@ SIBackendInit(SISeg * segInOutP)
|
||||
* SIAssignBackendId
|
||||
* ----------------
|
||||
*/
|
||||
static BackendId
|
||||
static BackendId
|
||||
SIAssignBackendId(SISeg * segInOutP, BackendTag backendTag)
|
||||
{
|
||||
Index index;
|
||||
ProcState *stateP;
|
||||
Index index;
|
||||
ProcState *stateP;
|
||||
|
||||
stateP = NULL;
|
||||
|
||||
@@ -211,12 +211,12 @@ CleanupInvalidationState(int status, /* XXX */
|
||||
static SISegOffsets *
|
||||
SIComputeSize(int *segSize)
|
||||
{
|
||||
int A,
|
||||
B,
|
||||
a,
|
||||
b,
|
||||
totalSize;
|
||||
SISegOffsets *oP;
|
||||
int A,
|
||||
B,
|
||||
a,
|
||||
b,
|
||||
totalSize;
|
||||
SISegOffsets *oP;
|
||||
|
||||
A = 0;
|
||||
a = SizeSISeg; /* offset to first data entry */
|
||||
@@ -245,7 +245,7 @@ SISetStartEntrySection(SISeg * segP, Offset offset)
|
||||
/************************************************************************/
|
||||
/* SIGetStartEntrySection(segP) - returnss the offset */
|
||||
/************************************************************************/
|
||||
static Offset
|
||||
static Offset
|
||||
SIGetStartEntrySection(SISeg * segP)
|
||||
{
|
||||
return (segP->startEntrySection);
|
||||
@@ -273,7 +273,7 @@ SISetEndEntryChain(SISeg * segP, Offset offset)
|
||||
/************************************************************************/
|
||||
/* SIGetEndEntryChain(segP) - returnss the offset */
|
||||
/************************************************************************/
|
||||
static Offset
|
||||
static Offset
|
||||
SIGetEndEntryChain(SISeg * segP)
|
||||
{
|
||||
return (segP->endEntryChain);
|
||||
@@ -291,7 +291,7 @@ SISetStartEntryChain(SISeg * segP, Offset offset)
|
||||
/************************************************************************/
|
||||
/* SIGetStartEntryChain(segP) - returns the offset */
|
||||
/************************************************************************/
|
||||
static Offset
|
||||
static Offset
|
||||
SIGetStartEntryChain(SISeg * segP)
|
||||
{
|
||||
return (segP->startEntryChain);
|
||||
@@ -300,7 +300,7 @@ SIGetStartEntryChain(SISeg * segP)
|
||||
/************************************************************************/
|
||||
/* SISetNumEntries(segP, num) sets the current nuber of entries */
|
||||
/************************************************************************/
|
||||
static bool
|
||||
static bool
|
||||
SISetNumEntries(SISeg * segP, int num)
|
||||
{
|
||||
if (num <= MAXNUMMESSAGES)
|
||||
@@ -327,7 +327,7 @@ SIGetNumEntries(SISeg * segP)
|
||||
/************************************************************************/
|
||||
/* SISetMaxNumEntries(segP, num) sets the maximal number of entries */
|
||||
/************************************************************************/
|
||||
static bool
|
||||
static bool
|
||||
SISetMaxNumEntries(SISeg * segP, int num)
|
||||
{
|
||||
if (num <= MAXNUMMESSAGES)
|
||||
@@ -354,7 +354,7 @@ SIGetProcStateLimit(SISeg * segP, int i)
|
||||
/************************************************************************/
|
||||
/* SIIncNumEntries(segP, num) increments the current nuber of entries */
|
||||
/************************************************************************/
|
||||
static bool
|
||||
static bool
|
||||
SIIncNumEntries(SISeg * segP, int num)
|
||||
{
|
||||
if ((segP->numEntries + num) <= MAXNUMMESSAGES)
|
||||
@@ -371,7 +371,7 @@ SIIncNumEntries(SISeg * segP, int num)
|
||||
/************************************************************************/
|
||||
/* SIDecNumEntries(segP, num) decrements the current nuber of entries */
|
||||
/************************************************************************/
|
||||
static bool
|
||||
static bool
|
||||
SIDecNumEntries(SISeg * segP, int num)
|
||||
{
|
||||
if ((segP->numEntries - num) >= 0)
|
||||
@@ -397,7 +397,7 @@ SISetStartFreeSpace(SISeg * segP, Offset offset)
|
||||
/************************************************************************/
|
||||
/* SIGetStartFreeSpace(segP) - returns the offset */
|
||||
/************************************************************************/
|
||||
static Offset
|
||||
static Offset
|
||||
SIGetStartFreeSpace(SISeg * segP)
|
||||
{
|
||||
return (segP->startFreeSpace);
|
||||
@@ -411,8 +411,8 @@ SIGetStartFreeSpace(SISeg * segP)
|
||||
static SISegEntry *
|
||||
SIGetFirstDataEntry(SISeg * segP)
|
||||
{
|
||||
SISegEntry *eP;
|
||||
Offset startChain;
|
||||
SISegEntry *eP;
|
||||
Offset startChain;
|
||||
|
||||
startChain = SIGetStartEntryChain(segP);
|
||||
|
||||
@@ -432,8 +432,8 @@ SIGetFirstDataEntry(SISeg * segP)
|
||||
static SISegEntry *
|
||||
SIGetLastDataEntry(SISeg * segP)
|
||||
{
|
||||
SISegEntry *eP;
|
||||
Offset endChain;
|
||||
SISegEntry *eP;
|
||||
Offset endChain;
|
||||
|
||||
endChain = SIGetEndEntryChain(segP);
|
||||
|
||||
@@ -452,7 +452,7 @@ SIGetLastDataEntry(SISeg * segP)
|
||||
static SISegEntry *
|
||||
SIGetNextDataEntry(SISeg * segP, Offset offset)
|
||||
{
|
||||
SISegEntry *eP;
|
||||
SISegEntry *eP;
|
||||
|
||||
if (offset == InvalidOffset)
|
||||
return (NULL);
|
||||
@@ -471,8 +471,8 @@ static SISegEntry *
|
||||
SIGetNthDataEntry(SISeg * segP,
|
||||
int n) /* must range from 1 to MaxMessages */
|
||||
{
|
||||
SISegEntry *eP;
|
||||
int i;
|
||||
SISegEntry *eP;
|
||||
int i;
|
||||
|
||||
if (n <= 0)
|
||||
return (NULL);
|
||||
@@ -490,7 +490,7 @@ SIGetNthDataEntry(SISeg * segP,
|
||||
/************************************************************************/
|
||||
/* SIEntryOffset(segP, entryP) returns the offset for an pointer */
|
||||
/************************************************************************/
|
||||
static Offset
|
||||
static Offset
|
||||
SIEntryOffset(SISeg * segP, SISegEntry * entryP)
|
||||
{
|
||||
/* relative to B !! */
|
||||
@@ -506,9 +506,9 @@ SIEntryOffset(SISeg * segP, SISegEntry * entryP)
|
||||
bool
|
||||
SISetDataEntry(SISeg * segP, SharedInvalidData * data)
|
||||
{
|
||||
Offset offsetToNewData;
|
||||
SISegEntry *eP,
|
||||
*lastP;
|
||||
Offset offsetToNewData;
|
||||
SISegEntry *eP,
|
||||
*lastP;
|
||||
|
||||
if (!SIIncNumEntries(segP, 1))
|
||||
return (false); /* no space */
|
||||
@@ -545,7 +545,7 @@ SISetDataEntry(SISeg * segP, SharedInvalidData * data)
|
||||
static void
|
||||
SIDecProcLimit(SISeg * segP, int num)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MaxBackendId; i++)
|
||||
{
|
||||
@@ -570,7 +570,7 @@ SIDecProcLimit(SISeg * segP, int num)
|
||||
bool
|
||||
SIDelDataEntry(SISeg * segP)
|
||||
{
|
||||
SISegEntry *e1P;
|
||||
SISegEntry *e1P;
|
||||
|
||||
if (!SIDecNumEntries(segP, 1))
|
||||
{
|
||||
@@ -602,7 +602,7 @@ SIDelDataEntry(SISeg * segP)
|
||||
void
|
||||
SISetProcStateInvalid(SISeg * segP)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MaxBackendId; i++)
|
||||
{
|
||||
@@ -630,8 +630,8 @@ SIReadEntryData(SISeg * segP,
|
||||
void (*invalFunction) (),
|
||||
void (*resetFunction) ())
|
||||
{
|
||||
int i = 0;
|
||||
SISegEntry *data;
|
||||
int i = 0;
|
||||
SISegEntry *data;
|
||||
|
||||
Assert(segP->procState[backendId - 1].tag == MyBackendTag);
|
||||
|
||||
@@ -675,9 +675,9 @@ SIReadEntryData(SISeg * segP,
|
||||
void
|
||||
SIDelExpiredDataEntries(SISeg * segP)
|
||||
{
|
||||
int min,
|
||||
i,
|
||||
h;
|
||||
int min,
|
||||
i,
|
||||
h;
|
||||
|
||||
min = 9999999;
|
||||
for (i = 0; i < MaxBackendId; i++)
|
||||
@@ -711,10 +711,10 @@ SIDelExpiredDataEntries(SISeg * segP)
|
||||
static void
|
||||
SISegInit(SISeg * segP)
|
||||
{
|
||||
SISegOffsets *oP;
|
||||
int segSize,
|
||||
i;
|
||||
SISegEntry *eP;
|
||||
SISegOffsets *oP;
|
||||
int segSize,
|
||||
i;
|
||||
SISegEntry *eP;
|
||||
|
||||
oP = SIComputeSize(&segSize);
|
||||
/* set sempahore ids in the segment */
|
||||
@@ -771,12 +771,12 @@ SISegmentKill(int key) /* the corresponding key for the segment */
|
||||
/* SISegmentGet(key, size) - get a shared segment of size <size> */
|
||||
/* returns a segment id */
|
||||
/************************************************************************/
|
||||
static IpcMemoryId
|
||||
static IpcMemoryId
|
||||
SISegmentGet(int key, /* the corresponding key for the segment */
|
||||
int size, /* size of segment in bytes */
|
||||
bool create)
|
||||
{
|
||||
IpcMemoryId shmid;
|
||||
IpcMemoryId shmid;
|
||||
|
||||
if (create)
|
||||
{
|
||||
@@ -811,10 +811,10 @@ SISegmentAttach(IpcMemoryId shmid)
|
||||
int
|
||||
SISegmentInit(bool killExistingSegment, IPCKey key)
|
||||
{
|
||||
SISegOffsets *oP;
|
||||
int segSize;
|
||||
IpcMemoryId shmId;
|
||||
bool create;
|
||||
SISegOffsets *oP;
|
||||
int segSize;
|
||||
IpcMemoryId shmId;
|
||||
bool create;
|
||||
|
||||
if (killExistingSegment)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.7 1997/09/07 04:48:45 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.8 1997/09/08 02:29:02 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -36,7 +36,7 @@
|
||||
#endif
|
||||
|
||||
/* globals used in this file */
|
||||
IpcSemaphoreId SpinLockId;
|
||||
IpcSemaphoreId SpinLockId;
|
||||
|
||||
#ifdef HAS_TEST_AND_SET
|
||||
/* real spin lock implementations */
|
||||
@@ -97,8 +97,8 @@ SpinRelease(SPINLOCK lock)
|
||||
#else /* HAS_TEST_AND_SET */
|
||||
/* Spinlocks are implemented using SysV semaphores */
|
||||
|
||||
static bool AttachSpinLocks(IPCKey key);
|
||||
static bool SpinIsLocked(SPINLOCK lock);
|
||||
static bool AttachSpinLocks(IPCKey key);
|
||||
static bool SpinIsLocked(SPINLOCK lock);
|
||||
|
||||
/*
|
||||
* SpinAcquire -- try to grab a spinlock
|
||||
@@ -125,10 +125,10 @@ SpinRelease(SPINLOCK lock)
|
||||
IpcSemaphoreUnlock(SpinLockId, lock, IpcExclusiveLock);
|
||||
}
|
||||
|
||||
static bool
|
||||
static bool
|
||||
SpinIsLocked(SPINLOCK lock)
|
||||
{
|
||||
int semval;
|
||||
int semval;
|
||||
|
||||
semval = IpcSemaphoreGetValue(SpinLockId, lock);
|
||||
return (semval < IpcSemaphoreDefaultStartValue);
|
||||
@@ -143,8 +143,8 @@ bool
|
||||
CreateSpinlocks(IPCKey key)
|
||||
{
|
||||
|
||||
int status;
|
||||
IpcSemaphoreId semid;
|
||||
int status;
|
||||
IpcSemaphoreId semid;
|
||||
|
||||
semid = IpcSemaphoreCreate(key, MAX_SPINS, IPCProtection,
|
||||
IpcSemaphoreDefaultStartValue, 1, &status);
|
||||
@@ -169,10 +169,10 @@ CreateSpinlocks(IPCKey key)
|
||||
/*
|
||||
* Attach to existing spinlock set
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
AttachSpinLocks(IPCKey key)
|
||||
{
|
||||
IpcSemaphoreId id;
|
||||
IpcSemaphoreId id;
|
||||
|
||||
id = semget(key, MAX_SPINS, 0);
|
||||
if (id < 0)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.14 1997/09/07 04:48:46 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.15 1997/09/08 02:29:06 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -67,12 +67,12 @@ static HeapTuple
|
||||
inv_newtuple(LargeObjectDesc * obj_desc, Buffer buffer,
|
||||
Page page, char *dbuf, int nwrite);
|
||||
static HeapTuple inv_fetchtup(LargeObjectDesc * obj_desc, Buffer * bufP);
|
||||
static int inv_wrnew(LargeObjectDesc * obj_desc, char *buf, int nbytes);
|
||||
static int inv_wrnew(LargeObjectDesc * obj_desc, char *buf, int nbytes);
|
||||
static int
|
||||
inv_wrold(LargeObjectDesc * obj_desc, char *dbuf, int nbytes,
|
||||
HeapTuple htup, Buffer buffer);
|
||||
static void inv_indextup(LargeObjectDesc * obj_desc, HeapTuple htup);
|
||||
static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln);
|
||||
static void inv_indextup(LargeObjectDesc * obj_desc, HeapTuple htup);
|
||||
static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln);
|
||||
|
||||
/*
|
||||
* inv_create -- create a new large object.
|
||||
@@ -86,17 +86,17 @@ static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln);
|
||||
LargeObjectDesc *
|
||||
inv_create(int flags)
|
||||
{
|
||||
int file_oid;
|
||||
int file_oid;
|
||||
LargeObjectDesc *retval;
|
||||
Relation r;
|
||||
Relation indr;
|
||||
int smgr;
|
||||
char archchar;
|
||||
TupleDesc tupdesc;
|
||||
AttrNumber attNums[1];
|
||||
Oid classObjectId[1];
|
||||
char objname[NAMEDATALEN];
|
||||
char indname[NAMEDATALEN];
|
||||
Relation r;
|
||||
Relation indr;
|
||||
int smgr;
|
||||
char archchar;
|
||||
TupleDesc tupdesc;
|
||||
AttrNumber attNums[1];
|
||||
Oid classObjectId[1];
|
||||
char objname[NAMEDATALEN];
|
||||
char indname[NAMEDATALEN];
|
||||
|
||||
/* parse flags */
|
||||
smgr = flags & INV_SMGRMASK;
|
||||
@@ -217,9 +217,9 @@ LargeObjectDesc *
|
||||
inv_open(Oid lobjId, int flags)
|
||||
{
|
||||
LargeObjectDesc *retval;
|
||||
Relation r;
|
||||
char *indname;
|
||||
Relation indrel;
|
||||
Relation r;
|
||||
char *indname;
|
||||
Relation indrel;
|
||||
|
||||
r = heap_open(lobjId);
|
||||
|
||||
@@ -288,7 +288,7 @@ inv_close(LargeObjectDesc * obj_desc)
|
||||
int
|
||||
inv_destroy(Oid lobjId)
|
||||
{
|
||||
Relation r;
|
||||
Relation r;
|
||||
|
||||
r = (Relation) RelationIdGetRelation(lobjId);
|
||||
if (!RelationIsValid(r) || r->rd_rel->relkind == RELKIND_INDEX)
|
||||
@@ -348,9 +348,9 @@ inv_stat(LargeObjectDesc * obj_desc, struct pgstat * stbuf)
|
||||
int
|
||||
inv_seek(LargeObjectDesc * obj_desc, int offset, int whence)
|
||||
{
|
||||
int oldOffset;
|
||||
Datum d;
|
||||
ScanKeyData skey;
|
||||
int oldOffset;
|
||||
Datum d;
|
||||
ScanKeyData skey;
|
||||
|
||||
Assert(PointerIsValid(obj_desc));
|
||||
|
||||
@@ -433,14 +433,14 @@ inv_tell(LargeObjectDesc * obj_desc)
|
||||
int
|
||||
inv_read(LargeObjectDesc * obj_desc, char *buf, int nbytes)
|
||||
{
|
||||
HeapTuple htup;
|
||||
Buffer b;
|
||||
int nread;
|
||||
int off;
|
||||
int ncopy;
|
||||
Datum d;
|
||||
HeapTuple htup;
|
||||
Buffer b;
|
||||
int nread;
|
||||
int off;
|
||||
int ncopy;
|
||||
Datum d;
|
||||
struct varlena *fsblock;
|
||||
bool isNull;
|
||||
bool isNull;
|
||||
|
||||
Assert(PointerIsValid(obj_desc));
|
||||
Assert(buf != NULL);
|
||||
@@ -497,10 +497,10 @@ inv_read(LargeObjectDesc * obj_desc, char *buf, int nbytes)
|
||||
int
|
||||
inv_write(LargeObjectDesc * obj_desc, char *buf, int nbytes)
|
||||
{
|
||||
HeapTuple htup;
|
||||
Buffer b;
|
||||
int nwritten;
|
||||
int tuplen;
|
||||
HeapTuple htup;
|
||||
Buffer b;
|
||||
int nwritten;
|
||||
int tuplen;
|
||||
|
||||
Assert(PointerIsValid(obj_desc));
|
||||
Assert(buf != NULL);
|
||||
@@ -575,16 +575,16 @@ inv_write(LargeObjectDesc * obj_desc, char *buf, int nbytes)
|
||||
* A heap tuple containing the desired block, or NULL if no
|
||||
* such tuple exists.
|
||||
*/
|
||||
static HeapTuple
|
||||
static HeapTuple
|
||||
inv_fetchtup(LargeObjectDesc * obj_desc, Buffer * bufP)
|
||||
{
|
||||
HeapTuple htup;
|
||||
HeapTuple htup;
|
||||
RetrieveIndexResult res;
|
||||
Datum d;
|
||||
int firstbyte,
|
||||
lastbyte;
|
||||
Datum d;
|
||||
int firstbyte,
|
||||
lastbyte;
|
||||
struct varlena *fsblock;
|
||||
bool isNull;
|
||||
bool isNull;
|
||||
|
||||
/*
|
||||
* If we've exhausted the current block, we need to get the next one.
|
||||
@@ -601,7 +601,7 @@ inv_fetchtup(LargeObjectDesc * obj_desc, Buffer * bufP)
|
||||
/* initialize scan key if not done */
|
||||
if (obj_desc->iscan == (IndexScanDesc) NULL)
|
||||
{
|
||||
ScanKeyData skey;
|
||||
ScanKeyData skey;
|
||||
|
||||
ScanKeyEntryInitialize(&skey, 0x0, 1, INT4GE_PROC_OID,
|
||||
Int32GetDatum(0));
|
||||
@@ -693,12 +693,12 @@ inv_fetchtup(LargeObjectDesc * obj_desc, Buffer * bufP)
|
||||
static int
|
||||
inv_wrnew(LargeObjectDesc * obj_desc, char *buf, int nbytes)
|
||||
{
|
||||
Relation hr;
|
||||
HeapTuple ntup;
|
||||
Buffer buffer;
|
||||
Page page;
|
||||
int nblocks;
|
||||
int nwritten;
|
||||
Relation hr;
|
||||
HeapTuple ntup;
|
||||
Buffer buffer;
|
||||
Page page;
|
||||
int nblocks;
|
||||
int nwritten;
|
||||
|
||||
hr = obj_desc->heap_r;
|
||||
|
||||
@@ -768,19 +768,19 @@ inv_wrold(LargeObjectDesc * obj_desc,
|
||||
HeapTuple htup,
|
||||
Buffer buffer)
|
||||
{
|
||||
Relation hr;
|
||||
HeapTuple ntup;
|
||||
Buffer newbuf;
|
||||
Page page;
|
||||
Page newpage;
|
||||
int tupbytes;
|
||||
Datum d;
|
||||
Relation hr;
|
||||
HeapTuple ntup;
|
||||
Buffer newbuf;
|
||||
Page page;
|
||||
Page newpage;
|
||||
int tupbytes;
|
||||
Datum d;
|
||||
struct varlena *fsblock;
|
||||
int nwritten,
|
||||
nblocks,
|
||||
freespc;
|
||||
bool isNull;
|
||||
int keep_offset;
|
||||
int nwritten,
|
||||
nblocks,
|
||||
freespc;
|
||||
bool isNull;
|
||||
int keep_offset;
|
||||
|
||||
/*
|
||||
* Since we're using a no-overwrite storage manager, the way we
|
||||
@@ -938,23 +938,23 @@ inv_wrold(LargeObjectDesc * obj_desc,
|
||||
return (nwritten);
|
||||
}
|
||||
|
||||
static HeapTuple
|
||||
static HeapTuple
|
||||
inv_newtuple(LargeObjectDesc * obj_desc,
|
||||
Buffer buffer,
|
||||
Page page,
|
||||
char *dbuf,
|
||||
int nwrite)
|
||||
{
|
||||
HeapTuple ntup;
|
||||
PageHeader ph;
|
||||
int tupsize;
|
||||
int hoff;
|
||||
Offset lower;
|
||||
Offset upper;
|
||||
ItemId itemId;
|
||||
OffsetNumber off;
|
||||
OffsetNumber limit;
|
||||
char *attptr;
|
||||
HeapTuple ntup;
|
||||
PageHeader ph;
|
||||
int tupsize;
|
||||
int hoff;
|
||||
Offset lower;
|
||||
Offset upper;
|
||||
ItemId itemId;
|
||||
OffsetNumber off;
|
||||
OffsetNumber limit;
|
||||
char *attptr;
|
||||
|
||||
/* compute tuple size -- no nulls */
|
||||
hoff = sizeof(HeapTupleData) - sizeof(ntup->t_bits);
|
||||
@@ -1035,7 +1035,7 @@ inv_newtuple(LargeObjectDesc * obj_desc,
|
||||
* * mer fixed disk layout of varlenas to get rid of the need for
|
||||
* this. *
|
||||
*
|
||||
* *((int32 *) attptr) = nwrite + sizeof(int32); * attptr +=
|
||||
*((int32 *) attptr) = nwrite + sizeof(int32); * attptr +=
|
||||
* sizeof(int32);
|
||||
*/
|
||||
|
||||
@@ -1064,8 +1064,8 @@ static void
|
||||
inv_indextup(LargeObjectDesc * obj_desc, HeapTuple htup)
|
||||
{
|
||||
InsertIndexResult res;
|
||||
Datum v[1];
|
||||
char n[1];
|
||||
Datum v[1];
|
||||
char n[1];
|
||||
|
||||
n[0] = ' ';
|
||||
v[0] = Int32GetDatum(obj_desc->highbyte);
|
||||
@@ -1173,13 +1173,13 @@ ItemPointerFormExternal(ItemPointer pointer)
|
||||
static int
|
||||
_inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln)
|
||||
{
|
||||
IndexScanDesc iscan;
|
||||
IndexScanDesc iscan;
|
||||
RetrieveIndexResult res;
|
||||
Buffer buf;
|
||||
HeapTuple htup;
|
||||
Datum d;
|
||||
long size;
|
||||
bool isNull;
|
||||
Buffer buf;
|
||||
HeapTuple htup;
|
||||
Datum d;
|
||||
long size;
|
||||
bool isNull;
|
||||
|
||||
/* scan backwards from end */
|
||||
iscan = index_beginscan(ireln, (bool) 1, 0, (ScanKey) NULL);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.6 1997/09/07 04:48:51 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.7 1997/09/08 02:29:10 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -48,7 +48,7 @@
|
||||
#include "storage/bufmgr.h"
|
||||
#include "access/transam.h" /* for AmiTransactionId */
|
||||
|
||||
static void LRelIdAssign(LRelId * lRelId, Oid dbId, Oid relId);
|
||||
static void LRelIdAssign(LRelId * lRelId, Oid dbId, Oid relId);
|
||||
|
||||
/* ----------------
|
||||
*
|
||||
@@ -67,9 +67,9 @@ static void LRelIdAssign(LRelId * lRelId, Oid dbId, Oid relId);
|
||||
|
||||
#define TupleLevelLockLimit 10
|
||||
|
||||
extern Oid MyDatabaseId;
|
||||
extern Oid MyDatabaseId;
|
||||
|
||||
static LRelId VariableRelationLRelId = {
|
||||
static LRelId VariableRelationLRelId = {
|
||||
RelOid_pg_variable,
|
||||
InvalidOid
|
||||
};
|
||||
@@ -93,7 +93,7 @@ elog(NOTICE, "RelationGetLRelId(%s) invalid lockInfo", \
|
||||
LRelId
|
||||
RelationGetLRelId(Relation relation)
|
||||
{
|
||||
LockInfo linfo;
|
||||
LockInfo linfo;
|
||||
|
||||
/* ----------------
|
||||
* sanity checks
|
||||
@@ -199,11 +199,11 @@ LRelIdContainsMyDatabaseId(LRelId lRelId)
|
||||
void
|
||||
RelationInitLockInfo(Relation relation)
|
||||
{
|
||||
LockInfo info;
|
||||
char *relname;
|
||||
Oid relationid;
|
||||
bool processingVariable;
|
||||
extern Oid MyDatabaseId; /* XXX use include */
|
||||
LockInfo info;
|
||||
char *relname;
|
||||
Oid relationid;
|
||||
bool processingVariable;
|
||||
extern Oid MyDatabaseId; /* XXX use include */
|
||||
extern GlobalMemory CacheCxt;
|
||||
|
||||
/* ----------------
|
||||
@@ -228,7 +228,7 @@ RelationInitLockInfo(Relation relation)
|
||||
*/
|
||||
if (!PointerIsValid(info))
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
|
||||
info = (LockInfo) palloc(sizeof(LockInfoData));
|
||||
@@ -366,7 +366,7 @@ elog(DEBUG, "RelationSetLockForRead(%s[%d,%d]) called", \
|
||||
void
|
||||
RelationSetLockForRead(Relation relation)
|
||||
{
|
||||
LockInfo linfo;
|
||||
LockInfo linfo;
|
||||
|
||||
/* ----------------
|
||||
* sanity checks
|
||||
@@ -416,7 +416,7 @@ elog(DEBUG, "RelationUnsetLockForRead(%s[%d,%d]) called", \
|
||||
void
|
||||
RelationUnsetLockForRead(Relation relation)
|
||||
{
|
||||
LockInfo linfo;
|
||||
LockInfo linfo;
|
||||
|
||||
/* ----------------
|
||||
* sanity check
|
||||
@@ -462,7 +462,7 @@ elog(DEBUG, "RelationSetLockForWrite(%s[%d,%d]) called", \
|
||||
void
|
||||
RelationSetLockForWrite(Relation relation)
|
||||
{
|
||||
LockInfo linfo;
|
||||
LockInfo linfo;
|
||||
|
||||
/* ----------------
|
||||
* sanity checks
|
||||
@@ -512,7 +512,7 @@ elog(DEBUG, "RelationUnsetLockForWrite(%s[%d,%d]) called", \
|
||||
void
|
||||
RelationUnsetLockForWrite(Relation relation)
|
||||
{
|
||||
LockInfo linfo;
|
||||
LockInfo linfo;
|
||||
|
||||
/* ----------------
|
||||
* sanity checks
|
||||
@@ -560,8 +560,8 @@ elog(DEBUG, "RelationSetLockForTupleRead(%s[%d,%d], 0x%x) called", \
|
||||
void
|
||||
RelationSetLockForTupleRead(Relation relation, ItemPointer itemPointer)
|
||||
{
|
||||
LockInfo linfo;
|
||||
TransactionId curXact;
|
||||
LockInfo linfo;
|
||||
TransactionId curXact;
|
||||
|
||||
/* ----------------
|
||||
* sanity checks
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.12 1997/09/07 04:48:58 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.13 1997/09/08 02:29:15 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Outside modules can create a lock table and acquire/release
|
||||
@@ -63,9 +63,9 @@ WaitOnLock(LOCKTAB * ltable, LockTableId tableId, LOCK * lock,
|
||||
|
||||
#else /* LOCK_MGR_DEBUG */
|
||||
|
||||
int lockDebug = 0;
|
||||
unsigned int lock_debug_oid_min = BootstrapObjectIdData;
|
||||
static char *lock_types[] = {
|
||||
int lockDebug = 0;
|
||||
unsigned int lock_debug_oid_min = BootstrapObjectIdData;
|
||||
static char *lock_types[] = {
|
||||
"NONE",
|
||||
"WRITE",
|
||||
"READ",
|
||||
@@ -127,19 +127,19 @@ static char *lock_types[] = {
|
||||
|
||||
#endif /* LOCK_MGR_DEBUG */
|
||||
|
||||
SPINLOCK LockMgrLock; /* in Shmem or created in
|
||||
SPINLOCK LockMgrLock; /* in Shmem or created in
|
||||
* CreateSpinlocks() */
|
||||
|
||||
/* This is to simplify/speed up some bit arithmetic */
|
||||
|
||||
static MASK BITS_OFF[MAX_LOCKTYPES];
|
||||
static MASK BITS_ON[MAX_LOCKTYPES];
|
||||
static MASK BITS_OFF[MAX_LOCKTYPES];
|
||||
static MASK BITS_ON[MAX_LOCKTYPES];
|
||||
|
||||
/* -----------------
|
||||
* XXX Want to move this to this file
|
||||
* -----------------
|
||||
*/
|
||||
static bool LockingIsDisabled;
|
||||
static bool LockingIsDisabled;
|
||||
|
||||
/* -------------------
|
||||
* map from tableId to the lock table structure
|
||||
@@ -151,7 +151,7 @@ static LOCKTAB *AllTables[MAX_TABLES];
|
||||
* no zero-th table
|
||||
* -------------------
|
||||
*/
|
||||
static int NumTables = 1;
|
||||
static int NumTables = 1;
|
||||
|
||||
/* -------------------
|
||||
* InitLocks -- Init the lock module. Create a private data
|
||||
@@ -161,8 +161,8 @@ static int NumTables = 1;
|
||||
void
|
||||
InitLocks()
|
||||
{
|
||||
int i;
|
||||
int bit;
|
||||
int i;
|
||||
int bit;
|
||||
|
||||
bit = 1;
|
||||
/* -------------------
|
||||
@@ -199,7 +199,7 @@ LockTypeInit(LOCKTAB * ltable,
|
||||
int *prioP,
|
||||
int ntypes)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
ltable->ctl->nLockTypes = ntypes;
|
||||
ntypes++;
|
||||
@@ -226,12 +226,12 @@ LockTabInit(char *tabName,
|
||||
int *prioP,
|
||||
int ntypes)
|
||||
{
|
||||
LOCKTAB *ltable;
|
||||
char *shmemName;
|
||||
HASHCTL info;
|
||||
int hash_flags;
|
||||
bool found;
|
||||
int status = TRUE;
|
||||
LOCKTAB *ltable;
|
||||
char *shmemName;
|
||||
HASHCTL info;
|
||||
int hash_flags;
|
||||
bool found;
|
||||
int status = TRUE;
|
||||
|
||||
if (ntypes > MAX_LOCKTYPES)
|
||||
{
|
||||
@@ -378,7 +378,7 @@ LockTabInit(char *tabName,
|
||||
LockTableId
|
||||
LockTabRename(LockTableId tableId)
|
||||
{
|
||||
LockTableId newTableId;
|
||||
LockTableId newTableId;
|
||||
|
||||
if (NumTables >= MAX_TABLES)
|
||||
{
|
||||
@@ -454,18 +454,18 @@ LockTabRename(LockTableId tableId)
|
||||
bool
|
||||
LockAcquire(LockTableId tableId, LOCKTAG * lockName, LOCKT lockt)
|
||||
{
|
||||
XIDLookupEnt *result,
|
||||
item;
|
||||
HTAB *xidTable;
|
||||
bool found;
|
||||
LOCK *lock = NULL;
|
||||
SPINLOCK masterLock;
|
||||
LOCKTAB *ltable;
|
||||
int status;
|
||||
TransactionId myXid;
|
||||
XIDLookupEnt *result,
|
||||
item;
|
||||
HTAB *xidTable;
|
||||
bool found;
|
||||
LOCK *lock = NULL;
|
||||
SPINLOCK masterLock;
|
||||
LOCKTAB *ltable;
|
||||
int status;
|
||||
TransactionId myXid;
|
||||
|
||||
#ifdef USER_LOCKS
|
||||
int is_user_lock;
|
||||
int is_user_lock;
|
||||
|
||||
is_user_lock = (tableId == 0);
|
||||
if (is_user_lock)
|
||||
@@ -661,15 +661,15 @@ LockResolveConflicts(LOCKTAB * ltable,
|
||||
LOCKT lockt,
|
||||
TransactionId xid)
|
||||
{
|
||||
XIDLookupEnt *result,
|
||||
item;
|
||||
int *myHolders;
|
||||
int nLockTypes;
|
||||
HTAB *xidTable;
|
||||
bool found;
|
||||
int bitmask;
|
||||
int i,
|
||||
tmpMask;
|
||||
XIDLookupEnt *result,
|
||||
item;
|
||||
int *myHolders;
|
||||
int nLockTypes;
|
||||
HTAB *xidTable;
|
||||
bool found;
|
||||
int bitmask;
|
||||
int i,
|
||||
tmpMask;
|
||||
|
||||
nLockTypes = ltable->ctl->nLockTypes;
|
||||
xidTable = ltable->xidHash;
|
||||
@@ -772,9 +772,9 @@ LockResolveConflicts(LOCKTAB * ltable,
|
||||
static int
|
||||
WaitOnLock(LOCKTAB * ltable, LockTableId tableId, LOCK * lock, LOCKT lockt)
|
||||
{
|
||||
PROC_QUEUE *waitQueue = &(lock->waitProcs);
|
||||
PROC_QUEUE *waitQueue = &(lock->waitProcs);
|
||||
|
||||
int prio = ltable->ctl->prio[lockt];
|
||||
int prio = ltable->ctl->prio[lockt];
|
||||
|
||||
/*
|
||||
* the waitqueue is ordered by priority. I insert myself according to
|
||||
@@ -821,17 +821,17 @@ WaitOnLock(LOCKTAB * ltable, LockTableId tableId, LOCK * lock, LOCKT lockt)
|
||||
bool
|
||||
LockRelease(LockTableId tableId, LOCKTAG * lockName, LOCKT lockt)
|
||||
{
|
||||
LOCK *lock = NULL;
|
||||
SPINLOCK masterLock;
|
||||
bool found;
|
||||
LOCKTAB *ltable;
|
||||
XIDLookupEnt *result,
|
||||
item;
|
||||
HTAB *xidTable;
|
||||
bool wakeupNeeded = true;
|
||||
LOCK *lock = NULL;
|
||||
SPINLOCK masterLock;
|
||||
bool found;
|
||||
LOCKTAB *ltable;
|
||||
XIDLookupEnt *result,
|
||||
item;
|
||||
HTAB *xidTable;
|
||||
bool wakeupNeeded = true;
|
||||
|
||||
#ifdef USER_LOCKS
|
||||
int is_user_lock;
|
||||
int is_user_lock;
|
||||
|
||||
is_user_lock = (tableId == 0);
|
||||
if (is_user_lock)
|
||||
@@ -1125,23 +1125,23 @@ GrantLock(LOCK * lock, LOCKT lockt)
|
||||
bool
|
||||
LockReleaseAll(LockTableId tableId, SHM_QUEUE * lockQueue)
|
||||
{
|
||||
PROC_QUEUE *waitQueue;
|
||||
int done;
|
||||
XIDLookupEnt *xidLook = NULL;
|
||||
XIDLookupEnt *tmp = NULL;
|
||||
SHMEM_OFFSET end = MAKE_OFFSET(lockQueue);
|
||||
SPINLOCK masterLock;
|
||||
LOCKTAB *ltable;
|
||||
int i,
|
||||
nLockTypes;
|
||||
LOCK *lock;
|
||||
bool found;
|
||||
PROC_QUEUE *waitQueue;
|
||||
int done;
|
||||
XIDLookupEnt *xidLook = NULL;
|
||||
XIDLookupEnt *tmp = NULL;
|
||||
SHMEM_OFFSET end = MAKE_OFFSET(lockQueue);
|
||||
SPINLOCK masterLock;
|
||||
LOCKTAB *ltable;
|
||||
int i,
|
||||
nLockTypes;
|
||||
LOCK *lock;
|
||||
bool found;
|
||||
|
||||
#ifdef USER_LOCKS
|
||||
int is_user_lock_table,
|
||||
my_pid,
|
||||
count,
|
||||
nskip;
|
||||
int is_user_lock_table,
|
||||
my_pid,
|
||||
count,
|
||||
nskip;
|
||||
|
||||
is_user_lock_table = (tableId == 0);
|
||||
my_pid = getpid();
|
||||
@@ -1359,11 +1359,11 @@ next_item:
|
||||
int
|
||||
LockShmemSize()
|
||||
{
|
||||
int size = 0;
|
||||
int nLockBuckets,
|
||||
nLockSegs;
|
||||
int nXidBuckets,
|
||||
nXidSegs;
|
||||
int size = 0;
|
||||
int nLockBuckets,
|
||||
nLockSegs;
|
||||
int nXidBuckets,
|
||||
nXidSegs;
|
||||
|
||||
nLockBuckets = 1 << (int) my_log2((NLOCKENTS - 1) / DEF_FFACTOR + 1);
|
||||
nLockSegs = 1 << (int) my_log2((nLockBuckets - 1) / DEF_SEGSIZE + 1);
|
||||
@@ -1409,20 +1409,20 @@ LockingDisabled()
|
||||
void
|
||||
DumpLocks()
|
||||
{
|
||||
SHMEM_OFFSET location;
|
||||
PROC *proc;
|
||||
SHM_QUEUE *lockQueue;
|
||||
int done;
|
||||
XIDLookupEnt *xidLook = NULL;
|
||||
XIDLookupEnt *tmp = NULL;
|
||||
SHMEM_OFFSET end;
|
||||
SPINLOCK masterLock;
|
||||
int nLockTypes;
|
||||
LOCK *lock;
|
||||
int pid,
|
||||
count;
|
||||
int tableId = 1;
|
||||
LOCKTAB *ltable;
|
||||
SHMEM_OFFSET location;
|
||||
PROC *proc;
|
||||
SHM_QUEUE *lockQueue;
|
||||
int done;
|
||||
XIDLookupEnt *xidLook = NULL;
|
||||
XIDLookupEnt *tmp = NULL;
|
||||
SHMEM_OFFSET end;
|
||||
SPINLOCK masterLock;
|
||||
int nLockTypes;
|
||||
LOCK *lock;
|
||||
int pid,
|
||||
count;
|
||||
int tableId = 1;
|
||||
LOCKTAB *ltable;
|
||||
|
||||
pid = getpid();
|
||||
ShmemPIDLookup(pid, &location);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.5 1997/09/07 04:49:02 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.6 1997/09/08 02:29:16 momjian Exp $
|
||||
*
|
||||
* NOTES:
|
||||
* (1) The lock.c module assumes that the caller here is doing
|
||||
@@ -43,7 +43,7 @@ MultiRelease(LockTableId tableId, LOCKTAG * tag, LOCKT lockt,
|
||||
* WRITE conflict between the tuple's intent lock and the relation's
|
||||
* write lock.
|
||||
*/
|
||||
static int MultiConflicts[] = {
|
||||
static int MultiConflicts[] = {
|
||||
(int) NULL,
|
||||
/* All reads and writes at any level conflict with a write lock */
|
||||
(1 << WRITE_LOCK) | (1 << WRITE_INTENT) | (1 << READ_LOCK) | (1 << READ_INTENT),
|
||||
@@ -65,7 +65,7 @@ static int MultiConflicts[] = {
|
||||
* write locks have higher priority than read locks and extend locks. May
|
||||
* want to treat INTENT locks differently.
|
||||
*/
|
||||
static int MultiPrios[] = {
|
||||
static int MultiPrios[] = {
|
||||
(int) NULL,
|
||||
2,
|
||||
1,
|
||||
@@ -78,8 +78,8 @@ static int MultiPrios[] = {
|
||||
* Lock table identifier for this lock table. The multi-level
|
||||
* lock table is ONE lock table, not three.
|
||||
*/
|
||||
LockTableId MultiTableId = (LockTableId) NULL;
|
||||
LockTableId ShortTermTableId = (LockTableId) NULL;
|
||||
LockTableId MultiTableId = (LockTableId) NULL;
|
||||
LockTableId ShortTermTableId = (LockTableId) NULL;
|
||||
|
||||
/*
|
||||
* Create the lock table described by MultiConflicts and Multiprio.
|
||||
@@ -87,7 +87,7 @@ LockTableId ShortTermTableId = (LockTableId) NULL;
|
||||
LockTableId
|
||||
InitMultiLevelLockm()
|
||||
{
|
||||
int tableId;
|
||||
int tableId;
|
||||
|
||||
/* -----------------------
|
||||
* If we're already initialized just return the table id.
|
||||
@@ -122,7 +122,7 @@ InitMultiLevelLockm()
|
||||
bool
|
||||
MultiLockReln(LockInfo linfo, LOCKT lockt)
|
||||
{
|
||||
LOCKTAG tag;
|
||||
LOCKTAG tag;
|
||||
|
||||
/*
|
||||
* LOCKTAG has two bytes of padding, unfortunately. The hash function
|
||||
@@ -145,7 +145,7 @@ MultiLockReln(LockInfo linfo, LOCKT lockt)
|
||||
bool
|
||||
MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
|
||||
{
|
||||
LOCKTAG tag;
|
||||
LOCKTAG tag;
|
||||
|
||||
/*
|
||||
* LOCKTAG has two bytes of padding, unfortunately. The hash function
|
||||
@@ -167,7 +167,7 @@ MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
|
||||
bool
|
||||
MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
|
||||
{
|
||||
LOCKTAG tag;
|
||||
LOCKTAG tag;
|
||||
|
||||
/*
|
||||
* LOCKTAG has two bytes of padding, unfortunately. The hash function
|
||||
@@ -197,18 +197,18 @@ MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
|
||||
* Returns: TRUE if lock is set, FALSE if not
|
||||
* Side Effects:
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
MultiAcquire(LockTableId tableId,
|
||||
LOCKTAG * tag,
|
||||
LOCKT lockt,
|
||||
LOCK_LEVEL level)
|
||||
{
|
||||
LOCKT locks[N_LEVELS];
|
||||
int i,
|
||||
status;
|
||||
LOCKTAG xxTag,
|
||||
*tmpTag = &xxTag;
|
||||
int retStatus = TRUE;
|
||||
LOCKT locks[N_LEVELS];
|
||||
int i,
|
||||
status;
|
||||
LOCKTAG xxTag,
|
||||
*tmpTag = &xxTag;
|
||||
int retStatus = TRUE;
|
||||
|
||||
/*
|
||||
* Three levels implemented. If we set a low level (e.g. Tuple) lock,
|
||||
@@ -221,24 +221,24 @@ MultiAcquire(LockTableId tableId,
|
||||
*/
|
||||
switch (level)
|
||||
{
|
||||
case RELN_LEVEL:
|
||||
locks[0] = lockt;
|
||||
locks[1] = NO_LOCK;
|
||||
locks[2] = NO_LOCK;
|
||||
break;
|
||||
case PAGE_LEVEL:
|
||||
locks[0] = lockt + INTENT;
|
||||
locks[1] = lockt;
|
||||
locks[2] = NO_LOCK;
|
||||
break;
|
||||
case TUPLE_LEVEL:
|
||||
locks[0] = lockt + INTENT;
|
||||
locks[1] = lockt + INTENT;
|
||||
locks[2] = lockt;
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "MultiAcquire: bad lock level");
|
||||
return (FALSE);
|
||||
case RELN_LEVEL:
|
||||
locks[0] = lockt;
|
||||
locks[1] = NO_LOCK;
|
||||
locks[2] = NO_LOCK;
|
||||
break;
|
||||
case PAGE_LEVEL:
|
||||
locks[0] = lockt + INTENT;
|
||||
locks[1] = lockt;
|
||||
locks[2] = NO_LOCK;
|
||||
break;
|
||||
case TUPLE_LEVEL:
|
||||
locks[0] = lockt + INTENT;
|
||||
locks[1] = lockt + INTENT;
|
||||
locks[2] = lockt;
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "MultiAcquire: bad lock level");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -257,30 +257,30 @@ MultiAcquire(LockTableId tableId,
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case RELN_LEVEL:
|
||||
/* -------------
|
||||
* Set the block # and offset to invalid
|
||||
* -------------
|
||||
*/
|
||||
BlockIdSet(&(tmpTag->tupleId.ip_blkid), InvalidBlockNumber);
|
||||
tmpTag->tupleId.ip_posid = InvalidOffsetNumber;
|
||||
break;
|
||||
case PAGE_LEVEL:
|
||||
/* -------------
|
||||
* Copy the block #, set the offset to invalid
|
||||
* -------------
|
||||
*/
|
||||
BlockIdCopy(&(tmpTag->tupleId.ip_blkid),
|
||||
&(tag->tupleId.ip_blkid));
|
||||
tmpTag->tupleId.ip_posid = InvalidOffsetNumber;
|
||||
break;
|
||||
case TUPLE_LEVEL:
|
||||
/* --------------
|
||||
* Copy the entire tuple id.
|
||||
* --------------
|
||||
*/
|
||||
ItemPointerCopy(&tmpTag->tupleId, &tag->tupleId);
|
||||
break;
|
||||
case RELN_LEVEL:
|
||||
/* -------------
|
||||
* Set the block # and offset to invalid
|
||||
* -------------
|
||||
*/
|
||||
BlockIdSet(&(tmpTag->tupleId.ip_blkid), InvalidBlockNumber);
|
||||
tmpTag->tupleId.ip_posid = InvalidOffsetNumber;
|
||||
break;
|
||||
case PAGE_LEVEL:
|
||||
/* -------------
|
||||
* Copy the block #, set the offset to invalid
|
||||
* -------------
|
||||
*/
|
||||
BlockIdCopy(&(tmpTag->tupleId.ip_blkid),
|
||||
&(tag->tupleId.ip_blkid));
|
||||
tmpTag->tupleId.ip_posid = InvalidOffsetNumber;
|
||||
break;
|
||||
case TUPLE_LEVEL:
|
||||
/* --------------
|
||||
* Copy the entire tuple id.
|
||||
* --------------
|
||||
*/
|
||||
ItemPointerCopy(&tmpTag->tupleId, &tag->tupleId);
|
||||
break;
|
||||
}
|
||||
|
||||
status = LockAcquire(tableId, tmpTag, locks[i]);
|
||||
@@ -311,7 +311,7 @@ MultiAcquire(LockTableId tableId,
|
||||
bool
|
||||
MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
|
||||
{
|
||||
LOCKTAG tag;
|
||||
LOCKTAG tag;
|
||||
|
||||
/* ------------------
|
||||
* LOCKTAG has two bytes of padding, unfortunately. The
|
||||
@@ -337,7 +337,7 @@ MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
|
||||
bool
|
||||
MultiReleaseReln(LockInfo linfo, LOCKT lockt)
|
||||
{
|
||||
LOCKTAG tag;
|
||||
LOCKTAG tag;
|
||||
|
||||
/* ------------------
|
||||
* LOCKTAG has two bytes of padding, unfortunately. The
|
||||
@@ -357,40 +357,40 @@ MultiReleaseReln(LockInfo linfo, LOCKT lockt)
|
||||
*
|
||||
* Returns: TRUE if successful, FALSE otherwise.
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
MultiRelease(LockTableId tableId,
|
||||
LOCKTAG * tag,
|
||||
LOCKT lockt,
|
||||
LOCK_LEVEL level)
|
||||
{
|
||||
LOCKT locks[N_LEVELS];
|
||||
int i,
|
||||
status;
|
||||
LOCKTAG xxTag,
|
||||
*tmpTag = &xxTag;
|
||||
LOCKT locks[N_LEVELS];
|
||||
int i,
|
||||
status;
|
||||
LOCKTAG xxTag,
|
||||
*tmpTag = &xxTag;
|
||||
|
||||
/*
|
||||
* same level scheme as MultiAcquire().
|
||||
*/
|
||||
switch (level)
|
||||
{
|
||||
case RELN_LEVEL:
|
||||
locks[0] = lockt;
|
||||
locks[1] = NO_LOCK;
|
||||
locks[2] = NO_LOCK;
|
||||
break;
|
||||
case PAGE_LEVEL:
|
||||
locks[0] = lockt + INTENT;
|
||||
locks[1] = lockt;
|
||||
locks[2] = NO_LOCK;
|
||||
break;
|
||||
case TUPLE_LEVEL:
|
||||
locks[0] = lockt + INTENT;
|
||||
locks[1] = lockt + INTENT;
|
||||
locks[2] = lockt;
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "MultiRelease: bad lockt");
|
||||
case RELN_LEVEL:
|
||||
locks[0] = lockt;
|
||||
locks[1] = NO_LOCK;
|
||||
locks[2] = NO_LOCK;
|
||||
break;
|
||||
case PAGE_LEVEL:
|
||||
locks[0] = lockt + INTENT;
|
||||
locks[1] = lockt;
|
||||
locks[2] = NO_LOCK;
|
||||
break;
|
||||
case TUPLE_LEVEL:
|
||||
locks[0] = lockt + INTENT;
|
||||
locks[1] = lockt + INTENT;
|
||||
locks[2] = lockt;
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "MultiRelease: bad lockt");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -411,26 +411,26 @@ MultiRelease(LockTableId tableId,
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case RELN_LEVEL:
|
||||
/* -------------
|
||||
* Set the block # and offset to invalid
|
||||
* -------------
|
||||
*/
|
||||
BlockIdSet(&(tmpTag->tupleId.ip_blkid), InvalidBlockNumber);
|
||||
tmpTag->tupleId.ip_posid = InvalidOffsetNumber;
|
||||
break;
|
||||
case PAGE_LEVEL:
|
||||
/* -------------
|
||||
* Copy the block #, set the offset to invalid
|
||||
* -------------
|
||||
*/
|
||||
BlockIdCopy(&(tmpTag->tupleId.ip_blkid),
|
||||
&(tag->tupleId.ip_blkid));
|
||||
tmpTag->tupleId.ip_posid = InvalidOffsetNumber;
|
||||
break;
|
||||
case TUPLE_LEVEL:
|
||||
ItemPointerCopy(&tmpTag->tupleId, &tag->tupleId);
|
||||
break;
|
||||
case RELN_LEVEL:
|
||||
/* -------------
|
||||
* Set the block # and offset to invalid
|
||||
* -------------
|
||||
*/
|
||||
BlockIdSet(&(tmpTag->tupleId.ip_blkid), InvalidBlockNumber);
|
||||
tmpTag->tupleId.ip_posid = InvalidOffsetNumber;
|
||||
break;
|
||||
case PAGE_LEVEL:
|
||||
/* -------------
|
||||
* Copy the block #, set the offset to invalid
|
||||
* -------------
|
||||
*/
|
||||
BlockIdCopy(&(tmpTag->tupleId.ip_blkid),
|
||||
&(tag->tupleId.ip_blkid));
|
||||
tmpTag->tupleId.ip_posid = InvalidOffsetNumber;
|
||||
break;
|
||||
case TUPLE_LEVEL:
|
||||
ItemPointerCopy(&tmpTag->tupleId, &tag->tupleId);
|
||||
break;
|
||||
}
|
||||
status = LockRelease(tableId, tmpTag, locks[i]);
|
||||
if (!status)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.19 1997/09/07 04:49:03 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.20 1997/09/08 02:29:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -46,7 +46,7 @@
|
||||
* This is so that we can support more backends. (system-wide semaphore
|
||||
* sets run out pretty fast.) -ay 4/95
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.19 1997/09/07 04:49:03 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.20 1997/09/08 02:29:17 momjian Exp $
|
||||
*/
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
@@ -76,8 +76,8 @@
|
||||
#include "storage/spin.h"
|
||||
#include "storage/proc.h"
|
||||
|
||||
static void HandleDeadLock(int sig);
|
||||
static PROC *ProcWakeup(PROC * proc, int errType);
|
||||
static void HandleDeadLock(int sig);
|
||||
static PROC *ProcWakeup(PROC * proc, int errType);
|
||||
|
||||
/*
|
||||
* timeout (in seconds) for resolving possible deadlock
|
||||
@@ -93,21 +93,21 @@ static PROC *ProcWakeup(PROC * proc, int errType);
|
||||
* memory. -mer 17 July 1991
|
||||
* --------------------
|
||||
*/
|
||||
SPINLOCK ProcStructLock;
|
||||
SPINLOCK ProcStructLock;
|
||||
|
||||
/*
|
||||
* For cleanup routines. Don't cleanup if the initialization
|
||||
* has not happened.
|
||||
*/
|
||||
static bool ProcInitialized = FALSE;
|
||||
static bool ProcInitialized = FALSE;
|
||||
|
||||
static PROC_HDR *ProcGlobal = NULL;
|
||||
|
||||
PROC *MyProc = NULL;
|
||||
PROC *MyProc = NULL;
|
||||
|
||||
static void ProcKill(int exitStatus, int pid);
|
||||
static void ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum);
|
||||
static void ProcFreeSem(IpcSemaphoreKey semKey, int semNum);
|
||||
static void ProcKill(int exitStatus, int pid);
|
||||
static void ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum);
|
||||
static void ProcFreeSem(IpcSemaphoreKey semKey, int semNum);
|
||||
|
||||
/*
|
||||
* InitProcGlobal -
|
||||
@@ -120,7 +120,7 @@ static void ProcFreeSem(IpcSemaphoreKey semKey, int semNum);
|
||||
void
|
||||
InitProcGlobal(IPCKey key)
|
||||
{
|
||||
bool found = false;
|
||||
bool found = false;
|
||||
|
||||
/* attach to the free list */
|
||||
ProcGlobal = (PROC_HDR *)
|
||||
@@ -132,7 +132,7 @@ InitProcGlobal(IPCKey key)
|
||||
*/
|
||||
if (!found)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
ProcGlobal->numProcs = 0;
|
||||
ProcGlobal->freeProcs = INVALID_OFFSET;
|
||||
@@ -150,11 +150,11 @@ InitProcGlobal(IPCKey key)
|
||||
void
|
||||
InitProcess(IPCKey key)
|
||||
{
|
||||
bool found = false;
|
||||
int pid;
|
||||
int semstat;
|
||||
unsigned long location,
|
||||
myOffset;
|
||||
bool found = false;
|
||||
int pid;
|
||||
int semstat;
|
||||
unsigned long location,
|
||||
myOffset;
|
||||
|
||||
/* ------------------
|
||||
* Routine called if deadlock timer goes off. See ProcSleep()
|
||||
@@ -223,10 +223,10 @@ InitProcess(IPCKey key)
|
||||
|
||||
if (IsUnderPostmaster)
|
||||
{
|
||||
IPCKey semKey;
|
||||
int semNum;
|
||||
int semId;
|
||||
union semun semun;
|
||||
IPCKey semKey;
|
||||
int semNum;
|
||||
int semId;
|
||||
union semun semun;
|
||||
|
||||
ProcGetNewSemKeyAndNum(&semKey, &semNum);
|
||||
|
||||
@@ -318,8 +318,8 @@ ProcReleaseLocks()
|
||||
bool
|
||||
ProcRemove(int pid)
|
||||
{
|
||||
SHMEM_OFFSET location;
|
||||
PROC *proc;
|
||||
SHMEM_OFFSET location;
|
||||
PROC *proc;
|
||||
|
||||
location = INVALID_OFFSET;
|
||||
|
||||
@@ -347,8 +347,8 @@ ProcRemove(int pid)
|
||||
static void
|
||||
ProcKill(int exitStatus, int pid)
|
||||
{
|
||||
PROC *proc;
|
||||
SHMEM_OFFSET location;
|
||||
PROC *proc;
|
||||
SHMEM_OFFSET location;
|
||||
|
||||
/* --------------------
|
||||
* If this is a FATAL exit the postmaster will have to kill all the
|
||||
@@ -417,11 +417,11 @@ ProcKill(int exitStatus, int pid)
|
||||
* Side Effects: Initializes the queue if we allocated one
|
||||
*/
|
||||
#ifdef NOT_USED
|
||||
PROC_QUEUE *
|
||||
PROC_QUEUE *
|
||||
ProcQueueAlloc(char *name)
|
||||
{
|
||||
bool found;
|
||||
PROC_QUEUE *queue = (PROC_QUEUE *)
|
||||
bool found;
|
||||
PROC_QUEUE *queue = (PROC_QUEUE *)
|
||||
ShmemInitStruct(name, (unsigned) sizeof(PROC_QUEUE), &found);
|
||||
|
||||
if (!queue)
|
||||
@@ -468,10 +468,10 @@ ProcSleep(PROC_QUEUE * queue,
|
||||
int prio,
|
||||
LOCK * lock)
|
||||
{
|
||||
int i;
|
||||
PROC *proc;
|
||||
int i;
|
||||
PROC *proc;
|
||||
struct itimerval timeval,
|
||||
dummy;
|
||||
dummy;
|
||||
|
||||
proc = (PROC *) MAKE_PTR(queue->links.prev);
|
||||
for (i = 0; i < queue->size; i++)
|
||||
@@ -555,10 +555,10 @@ ProcSleep(PROC_QUEUE * queue,
|
||||
* remove the process from the wait queue and set its links invalid.
|
||||
* RETURN: the next process in the wait queue.
|
||||
*/
|
||||
static PROC *
|
||||
static PROC *
|
||||
ProcWakeup(PROC * proc, int errType)
|
||||
{
|
||||
PROC *retProc;
|
||||
PROC *retProc;
|
||||
|
||||
/* assume that spinlock has been acquired */
|
||||
|
||||
@@ -599,8 +599,8 @@ ProcGetId()
|
||||
int
|
||||
ProcLockWakeup(PROC_QUEUE * queue, char *ltable, char *lock)
|
||||
{
|
||||
PROC *proc;
|
||||
int count;
|
||||
PROC *proc;
|
||||
int count;
|
||||
|
||||
if (!queue->size)
|
||||
return (STATUS_NOT_FOUND);
|
||||
@@ -659,8 +659,8 @@ ProcAddLock(SHM_QUEUE * elem)
|
||||
static void
|
||||
HandleDeadLock(int sig)
|
||||
{
|
||||
LOCK *lock;
|
||||
int size;
|
||||
LOCK *lock;
|
||||
int size;
|
||||
|
||||
LockLockTable();
|
||||
|
||||
@@ -743,7 +743,7 @@ HandleDeadLock(int sig)
|
||||
void
|
||||
ProcReleaseSpins(PROC * proc)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (!proc)
|
||||
proc = MyProc;
|
||||
@@ -774,9 +774,9 @@ ProcReleaseSpins(PROC * proc)
|
||||
static void
|
||||
ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum)
|
||||
{
|
||||
int i;
|
||||
int32 *freeSemMap = ProcGlobal->freeSemMap;
|
||||
unsigned int fullmask;
|
||||
int i;
|
||||
int32 *freeSemMap = ProcGlobal->freeSemMap;
|
||||
unsigned int fullmask;
|
||||
|
||||
/*
|
||||
* we hold ProcStructLock when entering this routine. We scan through
|
||||
@@ -785,8 +785,8 @@ ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum)
|
||||
fullmask = ~0 >> (32 - PROC_NSEMS_PER_SET);
|
||||
for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++)
|
||||
{
|
||||
int mask = 1;
|
||||
int j;
|
||||
int mask = 1;
|
||||
int j;
|
||||
|
||||
if (freeSemMap[i] == fullmask)
|
||||
continue; /* none free for this set */
|
||||
@@ -821,9 +821,9 @@ ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum)
|
||||
static void
|
||||
ProcFreeSem(IpcSemaphoreKey semKey, int semNum)
|
||||
{
|
||||
int mask;
|
||||
int i;
|
||||
int32 *freeSemMap = ProcGlobal->freeSemMap;
|
||||
int mask;
|
||||
int i;
|
||||
int32 *freeSemMap = ProcGlobal->freeSemMap;
|
||||
|
||||
i = semKey - ProcGlobal->currKey;
|
||||
mask = ~(1 << semNum);
|
||||
@@ -841,8 +841,8 @@ ProcFreeSem(IpcSemaphoreKey semKey, int semNum)
|
||||
void
|
||||
ProcFreeAllSemaphores()
|
||||
{
|
||||
int i;
|
||||
int32 *freeSemMap = ProcGlobal->freeSemMap;
|
||||
int i;
|
||||
int32 *freeSemMap = ProcGlobal->freeSemMap;
|
||||
|
||||
for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/single.c,v 1.3 1997/09/07 04:49:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/single.c,v 1.4 1997/09/08 02:29:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -34,7 +34,7 @@
|
||||
bool
|
||||
SingleLockReln(LockInfo linfo, LOCKT lockt, int action)
|
||||
{
|
||||
LOCKTAG tag;
|
||||
LOCKTAG tag;
|
||||
|
||||
/*
|
||||
* LOCKTAG has two bytes of padding, unfortunately. The hash function
|
||||
@@ -66,7 +66,7 @@ SingleLockPage(LockInfo linfo,
|
||||
LOCKT lockt,
|
||||
int action)
|
||||
{
|
||||
LOCKTAG tag;
|
||||
LOCKTAG tag;
|
||||
|
||||
/*
|
||||
* LOCKTAG has two bytes of padding, unfortunately. The hash function
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.9 1997/09/07 04:49:06 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.10 1997/09/08 02:29:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ static void
|
||||
PageIndexTupleDeleteAdjustLinePointers(PageHeader phdr,
|
||||
char *location, Size size);
|
||||
|
||||
static bool PageManagerShuffle = true; /* default is shuffle mode */
|
||||
static bool PageManagerShuffle = true; /* default is shuffle mode */
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* Page support functions
|
||||
@@ -44,7 +44,7 @@ static bool PageManagerShuffle = true; /* default is shuffle mode */
|
||||
void
|
||||
PageInit(Page page, Size pageSize, Size specialSize)
|
||||
{
|
||||
PageHeader p = (PageHeader) page;
|
||||
PageHeader p = (PageHeader) page;
|
||||
|
||||
Assert(pageSize == BLCKSZ);
|
||||
Assert(pageSize >
|
||||
@@ -98,16 +98,16 @@ PageAddItem(Page page,
|
||||
OffsetNumber offsetNumber,
|
||||
ItemIdFlags flags)
|
||||
{
|
||||
register i;
|
||||
Size alignedSize;
|
||||
Offset lower;
|
||||
Offset upper;
|
||||
ItemId itemId;
|
||||
ItemId fromitemId,
|
||||
toitemId;
|
||||
OffsetNumber limit;
|
||||
register i;
|
||||
Size alignedSize;
|
||||
Offset lower;
|
||||
Offset upper;
|
||||
ItemId itemId;
|
||||
ItemId fromitemId,
|
||||
toitemId;
|
||||
OffsetNumber limit;
|
||||
|
||||
bool shuffled = false;
|
||||
bool shuffled = false;
|
||||
|
||||
/*
|
||||
* Find first unallocated offsetNumber
|
||||
@@ -185,10 +185,10 @@ PageAddItem(Page page,
|
||||
Page
|
||||
PageGetTempPage(Page page, Size specialSize)
|
||||
{
|
||||
Size pageSize;
|
||||
Size size;
|
||||
Page temp;
|
||||
PageHeader thdr;
|
||||
Size pageSize;
|
||||
Size size;
|
||||
Page temp;
|
||||
PageHeader thdr;
|
||||
|
||||
pageSize = PageGetPageSize(page);
|
||||
|
||||
@@ -219,7 +219,7 @@ PageGetTempPage(Page page, Size specialSize)
|
||||
void
|
||||
PageRestoreTempPage(Page tempPage, Page oldPage)
|
||||
{
|
||||
Size pageSize;
|
||||
Size pageSize;
|
||||
|
||||
pageSize = PageGetPageSize(tempPage);
|
||||
memmove((char *) oldPage, (char *) tempPage, pageSize);
|
||||
@@ -238,8 +238,8 @@ PageRestoreTempPage(Page tempPage, Page oldPage)
|
||||
OffsetNumber
|
||||
PageGetMaxOffsetNumber(Page page)
|
||||
{
|
||||
LocationIndex low;
|
||||
OffsetNumber i;
|
||||
LocationIndex low;
|
||||
OffsetNumber i;
|
||||
|
||||
low = ((PageHeader) page)->pd_lower;
|
||||
i = (low - (sizeof(PageHeaderData) - sizeof(ItemIdData)))
|
||||
@@ -254,8 +254,8 @@ PageGetMaxOffsetNumber(Page page)
|
||||
*/
|
||||
struct itemIdSortData
|
||||
{
|
||||
int offsetindex;/* linp array index */
|
||||
ItemIdData itemiddata;
|
||||
int offsetindex; /* linp array index */
|
||||
ItemIdData itemiddata;
|
||||
};
|
||||
|
||||
static int
|
||||
@@ -278,14 +278,14 @@ itemidcompare(void *itemidp1, void *itemidp2)
|
||||
void
|
||||
PageRepairFragmentation(Page page)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
struct itemIdSortData *itemidbase,
|
||||
*itemidptr;
|
||||
ItemId lp;
|
||||
int nline,
|
||||
nused;
|
||||
Offset upper;
|
||||
Size alignedSize;
|
||||
*itemidptr;
|
||||
ItemId lp;
|
||||
int nline,
|
||||
nused;
|
||||
Offset upper;
|
||||
Size alignedSize;
|
||||
|
||||
nline = (int16) PageGetMaxOffsetNumber(page);
|
||||
nused = 0;
|
||||
@@ -359,7 +359,7 @@ PageRepairFragmentation(Page page)
|
||||
Size
|
||||
PageGetFreeSpace(Page page)
|
||||
{
|
||||
Size space;
|
||||
Size space;
|
||||
|
||||
|
||||
space = ((PageHeader) page)->pd_upper - ((PageHeader) page)->pd_lower;
|
||||
@@ -400,13 +400,13 @@ PageManagerModeSet(PageManagerMode mode)
|
||||
void
|
||||
PageIndexTupleDelete(Page page, OffsetNumber offnum)
|
||||
{
|
||||
PageHeader phdr;
|
||||
char *addr;
|
||||
ItemId tup;
|
||||
Size size;
|
||||
char *locn;
|
||||
int nbytes;
|
||||
int offidx;
|
||||
PageHeader phdr;
|
||||
char *addr;
|
||||
ItemId tup;
|
||||
Size size;
|
||||
char *locn;
|
||||
int nbytes;
|
||||
int offidx;
|
||||
|
||||
phdr = (PageHeader) page;
|
||||
|
||||
@@ -478,8 +478,8 @@ PageIndexTupleDeleteAdjustLinePointers(PageHeader phdr,
|
||||
char *location,
|
||||
Size size)
|
||||
{
|
||||
int i;
|
||||
unsigned offset;
|
||||
int i;
|
||||
unsigned offset;
|
||||
|
||||
/* location is an index into the page... */
|
||||
offset = (unsigned) (location - (char *) phdr);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.19 1997/09/07 04:49:17 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.20 1997/09/08 02:29:28 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -43,17 +43,17 @@
|
||||
|
||||
typedef struct _MdfdVec
|
||||
{
|
||||
int mdfd_vfd; /* fd number in vfd pool */
|
||||
uint16 mdfd_flags; /* clean, dirty, free */
|
||||
int mdfd_lstbcnt; /* most recent block count */
|
||||
int mdfd_nextFree; /* next free vector */
|
||||
int mdfd_vfd; /* fd number in vfd pool */
|
||||
uint16 mdfd_flags; /* clean, dirty, free */
|
||||
int mdfd_lstbcnt; /* most recent block count */
|
||||
int mdfd_nextFree; /* next free vector */
|
||||
struct _MdfdVec *mdfd_chain;/* for large relations */
|
||||
} MdfdVec;
|
||||
} MdfdVec;
|
||||
|
||||
static int Nfds = 100;
|
||||
static int Nfds = 100;
|
||||
static MdfdVec *Md_fdvec = (MdfdVec *) NULL;
|
||||
static int Md_Free = -1;
|
||||
static int CurFd = 0;
|
||||
static int Md_Free = -1;
|
||||
static int CurFd = 0;
|
||||
static MemoryContext MdCxt;
|
||||
|
||||
#define MDFD_DIRTY (uint16) 0x01
|
||||
@@ -64,8 +64,8 @@ static MemoryContext MdCxt;
|
||||
/* routines declared here */
|
||||
static MdfdVec *_mdfd_openseg(Relation reln, int segno, int oflags);
|
||||
static MdfdVec *_mdfd_getseg(Relation reln, int blkno, int oflag);
|
||||
static int _fdvec_alloc(void);
|
||||
static void _fdvec_free(int);
|
||||
static int _fdvec_alloc(void);
|
||||
static void _fdvec_free(int);
|
||||
static BlockNumber _mdnblocks(File file, Size blcksz);
|
||||
|
||||
/*
|
||||
@@ -82,8 +82,8 @@ static BlockNumber _mdnblocks(File file, Size blcksz);
|
||||
int
|
||||
mdinit()
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
int i;
|
||||
MemoryContext oldcxt;
|
||||
int i;
|
||||
|
||||
MdCxt = (MemoryContext) CreateGlobalMemory("MdSmgr");
|
||||
if (MdCxt == (MemoryContext) NULL)
|
||||
@@ -113,9 +113,9 @@ mdinit()
|
||||
int
|
||||
mdcreate(Relation reln)
|
||||
{
|
||||
int fd,
|
||||
vfd;
|
||||
char *path;
|
||||
int fd,
|
||||
vfd;
|
||||
char *path;
|
||||
|
||||
path = relpath(&(reln->rd_rel->relname.data[0]));
|
||||
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
@@ -158,13 +158,13 @@ mdcreate(Relation reln)
|
||||
int
|
||||
mdunlink(Relation reln)
|
||||
{
|
||||
int fd;
|
||||
int i;
|
||||
MdfdVec *v,
|
||||
*ov;
|
||||
MemoryContext oldcxt;
|
||||
char fname[NAMEDATALEN];
|
||||
char tname[NAMEDATALEN + 10]; /* leave room for overflow
|
||||
int fd;
|
||||
int i;
|
||||
MdfdVec *v,
|
||||
*ov;
|
||||
MemoryContext oldcxt;
|
||||
char fname[NAMEDATALEN];
|
||||
char tname[NAMEDATALEN + 10]; /* leave room for overflow
|
||||
* suffixes */
|
||||
|
||||
/*
|
||||
@@ -215,9 +215,9 @@ mdunlink(Relation reln)
|
||||
int
|
||||
mdextend(Relation reln, char *buffer)
|
||||
{
|
||||
long pos;
|
||||
int nblocks;
|
||||
MdfdVec *v;
|
||||
long pos;
|
||||
int nblocks;
|
||||
MdfdVec *v;
|
||||
|
||||
nblocks = mdnblocks(reln);
|
||||
v = _mdfd_getseg(reln, nblocks, O_CREAT);
|
||||
@@ -250,9 +250,9 @@ mdextend(Relation reln, char *buffer)
|
||||
int
|
||||
mdopen(Relation reln)
|
||||
{
|
||||
char *path;
|
||||
int fd;
|
||||
int vfd;
|
||||
char *path;
|
||||
int fd;
|
||||
int vfd;
|
||||
|
||||
path = relpath(&(reln->rd_rel->relname.data[0]));
|
||||
|
||||
@@ -290,10 +290,10 @@ mdopen(Relation reln)
|
||||
int
|
||||
mdclose(Relation reln)
|
||||
{
|
||||
int fd;
|
||||
MdfdVec *v,
|
||||
*ov;
|
||||
MemoryContext oldcxt;
|
||||
int fd;
|
||||
MdfdVec *v,
|
||||
*ov;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
fd = RelationGetFile(reln);
|
||||
|
||||
@@ -338,10 +338,10 @@ mdclose(Relation reln)
|
||||
int
|
||||
mdread(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
{
|
||||
int status;
|
||||
long seekpos;
|
||||
int nbytes;
|
||||
MdfdVec *v;
|
||||
int status;
|
||||
long seekpos;
|
||||
int nbytes;
|
||||
MdfdVec *v;
|
||||
|
||||
v = _mdfd_getseg(reln, blocknum, 0);
|
||||
|
||||
@@ -381,9 +381,9 @@ mdread(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
int
|
||||
mdwrite(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
{
|
||||
int status;
|
||||
long seekpos;
|
||||
MdfdVec *v;
|
||||
int status;
|
||||
long seekpos;
|
||||
MdfdVec *v;
|
||||
|
||||
v = _mdfd_getseg(reln, blocknum, 0);
|
||||
|
||||
@@ -416,9 +416,9 @@ mdwrite(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
int
|
||||
mdflush(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
{
|
||||
int status;
|
||||
long seekpos;
|
||||
MdfdVec *v;
|
||||
int status;
|
||||
long seekpos;
|
||||
MdfdVec *v;
|
||||
|
||||
v = _mdfd_getseg(reln, blocknum, 0);
|
||||
|
||||
@@ -465,12 +465,12 @@ mdblindwrt(char *dbstr,
|
||||
BlockNumber blkno,
|
||||
char *buffer)
|
||||
{
|
||||
int fd;
|
||||
int segno;
|
||||
long seekpos;
|
||||
int status;
|
||||
char *path;
|
||||
int nchars;
|
||||
int fd;
|
||||
int segno;
|
||||
long seekpos;
|
||||
int status;
|
||||
char *path;
|
||||
int nchars;
|
||||
|
||||
/* be sure we have enough space for the '.segno', if any */
|
||||
segno = blkno / RELSEG_SIZE;
|
||||
@@ -532,10 +532,10 @@ mdblindwrt(char *dbstr,
|
||||
int
|
||||
mdnblocks(Relation reln)
|
||||
{
|
||||
int fd;
|
||||
MdfdVec *v;
|
||||
int nblocks;
|
||||
int segno;
|
||||
int fd;
|
||||
MdfdVec *v;
|
||||
int nblocks;
|
||||
int segno;
|
||||
|
||||
fd = RelationGetFile(reln);
|
||||
v = &Md_fdvec[fd];
|
||||
@@ -580,9 +580,9 @@ mdnblocks(Relation reln)
|
||||
int
|
||||
mdtruncate(Relation reln, int nblocks)
|
||||
{
|
||||
int fd;
|
||||
MdfdVec *v;
|
||||
int curnblk;
|
||||
int fd;
|
||||
MdfdVec *v;
|
||||
int curnblk;
|
||||
|
||||
curnblk = mdnblocks(reln);
|
||||
if (curnblk / RELSEG_SIZE > 0)
|
||||
@@ -615,8 +615,8 @@ mdtruncate(Relation reln, int nblocks)
|
||||
int
|
||||
mdcommit()
|
||||
{
|
||||
int i;
|
||||
MdfdVec *v;
|
||||
int i;
|
||||
MdfdVec *v;
|
||||
|
||||
for (i = 0; i < CurFd; i++)
|
||||
{
|
||||
@@ -644,8 +644,8 @@ mdcommit()
|
||||
int
|
||||
mdabort()
|
||||
{
|
||||
int i;
|
||||
MdfdVec *v;
|
||||
int i;
|
||||
MdfdVec *v;
|
||||
|
||||
for (i = 0; i < CurFd; i++)
|
||||
{
|
||||
@@ -666,10 +666,10 @@ static
|
||||
int
|
||||
_fdvec_alloc()
|
||||
{
|
||||
MdfdVec *nvec;
|
||||
int fdvec,
|
||||
i;
|
||||
MemoryContext oldcxt;
|
||||
MdfdVec *nvec;
|
||||
int fdvec,
|
||||
i;
|
||||
MemoryContext oldcxt;
|
||||
|
||||
if (Md_Free >= 0) /* get from free list */
|
||||
{
|
||||
@@ -738,12 +738,12 @@ _fdvec_free(int fdvec)
|
||||
static MdfdVec *
|
||||
_mdfd_openseg(Relation reln, int segno, int oflags)
|
||||
{
|
||||
MemoryContext oldcxt;
|
||||
MdfdVec *v;
|
||||
int fd;
|
||||
bool dofree;
|
||||
char *path,
|
||||
*fullpath;
|
||||
MemoryContext oldcxt;
|
||||
MdfdVec *v;
|
||||
int fd;
|
||||
bool dofree;
|
||||
char *path,
|
||||
*fullpath;
|
||||
|
||||
/* be sure we have enough space for the '.segno', if any */
|
||||
path = relpath(RelationGetRelationName(reln)->data);
|
||||
@@ -790,10 +790,10 @@ _mdfd_openseg(Relation reln, int segno, int oflags)
|
||||
static MdfdVec *
|
||||
_mdfd_getseg(Relation reln, int blkno, int oflag)
|
||||
{
|
||||
MdfdVec *v;
|
||||
int segno;
|
||||
int fd;
|
||||
int i;
|
||||
MdfdVec *v;
|
||||
int segno;
|
||||
int fd;
|
||||
int i;
|
||||
|
||||
fd = RelationGetFile(reln);
|
||||
if (fd < 0)
|
||||
@@ -823,10 +823,10 @@ _mdfd_getseg(Relation reln, int blkno, int oflag)
|
||||
return (v);
|
||||
}
|
||||
|
||||
static BlockNumber
|
||||
static BlockNumber
|
||||
_mdnblocks(File file, Size blcksz)
|
||||
{
|
||||
long len;
|
||||
long len;
|
||||
|
||||
len = FileSeek(file, 0L, SEEK_END) - 1;
|
||||
return ((BlockNumber) ((len < 0) ? 0 : 1 + len / blcksz));
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.5 1997/09/07 04:49:22 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.6 1997/09/08 02:29:33 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,10 +37,10 @@
|
||||
|
||||
typedef struct MMCacheTag
|
||||
{
|
||||
Oid mmct_dbid;
|
||||
Oid mmct_relid;
|
||||
BlockNumber mmct_blkno;
|
||||
} MMCacheTag;
|
||||
Oid mmct_dbid;
|
||||
Oid mmct_relid;
|
||||
BlockNumber mmct_blkno;
|
||||
} MMCacheTag;
|
||||
|
||||
/*
|
||||
* Shared-memory hash table for main memory relations contains
|
||||
@@ -49,9 +49,9 @@ typedef struct MMCacheTag
|
||||
|
||||
typedef struct MMHashEntry
|
||||
{
|
||||
MMCacheTag mmhe_tag;
|
||||
int mmhe_bufno;
|
||||
} MMHashEntry;
|
||||
MMCacheTag mmhe_tag;
|
||||
int mmhe_bufno;
|
||||
} MMHashEntry;
|
||||
|
||||
/*
|
||||
* MMRelTag -- Unique identifier for each relation that is stored in the
|
||||
@@ -60,9 +60,9 @@ typedef struct MMHashEntry
|
||||
|
||||
typedef struct MMRelTag
|
||||
{
|
||||
Oid mmrt_dbid;
|
||||
Oid mmrt_relid;
|
||||
} MMRelTag;
|
||||
Oid mmrt_dbid;
|
||||
Oid mmrt_relid;
|
||||
} MMRelTag;
|
||||
|
||||
/*
|
||||
* Shared-memory hash table for # blocks in main memory relations contains
|
||||
@@ -71,31 +71,31 @@ typedef struct MMRelTag
|
||||
|
||||
typedef struct MMRelHashEntry
|
||||
{
|
||||
MMRelTag mmrhe_tag;
|
||||
int mmrhe_nblocks;
|
||||
} MMRelHashEntry;
|
||||
MMRelTag mmrhe_tag;
|
||||
int mmrhe_nblocks;
|
||||
} MMRelHashEntry;
|
||||
|
||||
#define MMNBUFFERS 10
|
||||
#define MMNRELATIONS 2
|
||||
|
||||
SPINLOCK MMCacheLock;
|
||||
extern bool IsPostmaster;
|
||||
extern Oid MyDatabaseId;
|
||||
SPINLOCK MMCacheLock;
|
||||
extern bool IsPostmaster;
|
||||
extern Oid MyDatabaseId;
|
||||
|
||||
static int *MMCurTop;
|
||||
static int *MMCurRelno;
|
||||
static int *MMCurTop;
|
||||
static int *MMCurRelno;
|
||||
static MMCacheTag *MMBlockTags;
|
||||
static char *MMBlockCache;
|
||||
static HTAB *MMCacheHT;
|
||||
static HTAB *MMRelCacheHT;
|
||||
static char *MMBlockCache;
|
||||
static HTAB *MMCacheHT;
|
||||
static HTAB *MMRelCacheHT;
|
||||
|
||||
int
|
||||
mminit()
|
||||
{
|
||||
char *mmcacheblk;
|
||||
int mmsize = 0;
|
||||
bool found;
|
||||
HASHCTL info;
|
||||
char *mmcacheblk;
|
||||
int mmsize = 0;
|
||||
bool found;
|
||||
HASHCTL info;
|
||||
|
||||
SpinAcquire(MMCacheLock);
|
||||
|
||||
@@ -169,8 +169,8 @@ int
|
||||
mmcreate(Relation reln)
|
||||
{
|
||||
MMRelHashEntry *entry;
|
||||
bool found;
|
||||
MMRelTag tag;
|
||||
bool found;
|
||||
MMRelTag tag;
|
||||
|
||||
SpinAcquire(MMCacheLock);
|
||||
|
||||
@@ -217,12 +217,12 @@ mmcreate(Relation reln)
|
||||
int
|
||||
mmunlink(Relation reln)
|
||||
{
|
||||
int i;
|
||||
Oid reldbid;
|
||||
MMHashEntry *entry;
|
||||
int i;
|
||||
Oid reldbid;
|
||||
MMHashEntry *entry;
|
||||
MMRelHashEntry *rentry;
|
||||
bool found;
|
||||
MMRelTag rtag;
|
||||
bool found;
|
||||
MMRelTag rtag;
|
||||
|
||||
if (reln->rd_rel->relisshared)
|
||||
reldbid = (Oid) 0;
|
||||
@@ -277,13 +277,13 @@ int
|
||||
mmextend(Relation reln, char *buffer)
|
||||
{
|
||||
MMRelHashEntry *rentry;
|
||||
MMHashEntry *entry;
|
||||
int i;
|
||||
Oid reldbid;
|
||||
int offset;
|
||||
bool found;
|
||||
MMRelTag rtag;
|
||||
MMCacheTag tag;
|
||||
MMHashEntry *entry;
|
||||
int i;
|
||||
Oid reldbid;
|
||||
int offset;
|
||||
bool found;
|
||||
MMRelTag rtag;
|
||||
MMCacheTag tag;
|
||||
|
||||
if (reln->rd_rel->relisshared)
|
||||
reldbid = (Oid) 0;
|
||||
@@ -380,10 +380,10 @@ mmclose(Relation reln)
|
||||
int
|
||||
mmread(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
{
|
||||
MMHashEntry *entry;
|
||||
bool found;
|
||||
int offset;
|
||||
MMCacheTag tag;
|
||||
MMHashEntry *entry;
|
||||
bool found;
|
||||
int offset;
|
||||
MMCacheTag tag;
|
||||
|
||||
if (reln->rd_rel->relisshared)
|
||||
tag.mmct_dbid = (Oid) 0;
|
||||
@@ -427,10 +427,10 @@ mmread(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
int
|
||||
mmwrite(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
{
|
||||
MMHashEntry *entry;
|
||||
bool found;
|
||||
int offset;
|
||||
MMCacheTag tag;
|
||||
MMHashEntry *entry;
|
||||
bool found;
|
||||
int offset;
|
||||
MMCacheTag tag;
|
||||
|
||||
if (reln->rd_rel->relisshared)
|
||||
tag.mmct_dbid = (Oid) 0;
|
||||
@@ -500,10 +500,10 @@ mmblindwrt(char *dbstr,
|
||||
int
|
||||
mmnblocks(Relation reln)
|
||||
{
|
||||
MMRelTag rtag;
|
||||
MMRelTag rtag;
|
||||
MMRelHashEntry *rentry;
|
||||
bool found;
|
||||
int nblocks;
|
||||
bool found;
|
||||
int nblocks;
|
||||
|
||||
if (reln->rd_rel->relisshared)
|
||||
rtag.mmrt_dbid = (Oid) 0;
|
||||
@@ -565,10 +565,10 @@ mmabort()
|
||||
int
|
||||
MMShmemSize()
|
||||
{
|
||||
int size = 0;
|
||||
int nbuckets;
|
||||
int nsegs;
|
||||
int tmp;
|
||||
int size = 0;
|
||||
int nbuckets;
|
||||
int nsegs;
|
||||
int tmp;
|
||||
|
||||
/*
|
||||
* first compute space occupied by the (dbid,relid,blkno) hash table
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.9 1997/09/07 04:49:25 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.10 1997/09/08 02:29:36 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -23,33 +23,33 @@
|
||||
#include "utils/rel.h"
|
||||
#include "utils/palloc.h"
|
||||
|
||||
static void smgrshutdown(int dummy);
|
||||
static void smgrshutdown(int dummy);
|
||||
|
||||
typedef struct f_smgr
|
||||
{
|
||||
int (*smgr_init) (); /* may be NULL */
|
||||
int (*smgr_shutdown) (); /* may be NULL */
|
||||
int (*smgr_create) ();
|
||||
int (*smgr_unlink) ();
|
||||
int (*smgr_extend) ();
|
||||
int (*smgr_open) ();
|
||||
int (*smgr_close) ();
|
||||
int (*smgr_read) ();
|
||||
int (*smgr_write) ();
|
||||
int (*smgr_flush) ();
|
||||
int (*smgr_blindwrt) ();
|
||||
int (*smgr_nblocks) ();
|
||||
int (*smgr_truncate) ();
|
||||
int (*smgr_commit) (); /* may be NULL */
|
||||
int (*smgr_abort) (); /* may be NULL */
|
||||
} f_smgr;
|
||||
int (*smgr_init) ();/* may be NULL */
|
||||
int (*smgr_shutdown) (); /* may be NULL */
|
||||
int (*smgr_create) ();
|
||||
int (*smgr_unlink) ();
|
||||
int (*smgr_extend) ();
|
||||
int (*smgr_open) ();
|
||||
int (*smgr_close) ();
|
||||
int (*smgr_read) ();
|
||||
int (*smgr_write) ();
|
||||
int (*smgr_flush) ();
|
||||
int (*smgr_blindwrt) ();
|
||||
int (*smgr_nblocks) ();
|
||||
int (*smgr_truncate) ();
|
||||
int (*smgr_commit) (); /* may be NULL */
|
||||
int (*smgr_abort) (); /* may be NULL */
|
||||
} f_smgr;
|
||||
|
||||
/*
|
||||
* The weird placement of commas in this init block is to keep the compiler
|
||||
* happy, regardless of what storage managers we have (or don't have).
|
||||
*/
|
||||
|
||||
static f_smgr smgrsw[] = {
|
||||
static f_smgr smgrsw[] = {
|
||||
|
||||
/* magnetic disk */
|
||||
{mdinit, NULL, mdcreate, mdunlink, mdextend, mdopen, mdclose,
|
||||
@@ -72,13 +72,13 @@ static f_smgr smgrsw[] = {
|
||||
* write-once storage managers.
|
||||
*/
|
||||
|
||||
static bool smgrwo[] = {
|
||||
static bool smgrwo[] = {
|
||||
false, /* magnetic disk */
|
||||
#ifdef MAIN_MEMORY
|
||||
false, /* main memory */
|
||||
#endif /* MAIN_MEMORY */
|
||||
};
|
||||
static int NSmgr = lengthof(smgrsw);
|
||||
static int NSmgr = lengthof(smgrsw);
|
||||
|
||||
/*
|
||||
* smgrinit(), smgrshutdown() -- Initialize or shut down all storage
|
||||
@@ -88,7 +88,7 @@ static int NSmgr = lengthof(smgrsw);
|
||||
int
|
||||
smgrinit()
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NSmgr; i++)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ smgrinit()
|
||||
static void
|
||||
smgrshutdown(int dummy)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NSmgr; i++)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ smgrshutdown(int dummy)
|
||||
int
|
||||
smgrcreate(int16 which, Relation reln)
|
||||
{
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
if ((fd = (*(smgrsw[which].smgr_create)) (reln)) < 0)
|
||||
elog(WARN, "cannot open %s",
|
||||
@@ -146,7 +146,7 @@ smgrcreate(int16 which, Relation reln)
|
||||
int
|
||||
smgrunlink(int16 which, Relation reln)
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
|
||||
if ((status = (*(smgrsw[which].smgr_unlink)) (reln)) == SM_FAIL)
|
||||
elog(WARN, "cannot unlink %s",
|
||||
@@ -164,7 +164,7 @@ smgrunlink(int16 which, Relation reln)
|
||||
int
|
||||
smgrextend(int16 which, Relation reln, char *buffer)
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
|
||||
status = (*(smgrsw[which].smgr_extend)) (reln, buffer);
|
||||
|
||||
@@ -184,7 +184,7 @@ smgrextend(int16 which, Relation reln, char *buffer)
|
||||
int
|
||||
smgropen(int16 which, Relation reln)
|
||||
{
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
if ((fd = (*(smgrsw[which].smgr_open)) (reln)) < 0)
|
||||
elog(WARN, "cannot open %s",
|
||||
@@ -228,7 +228,7 @@ smgrclose(int16 which, Relation reln)
|
||||
int
|
||||
smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
|
||||
status = (*(smgrsw[which].smgr_read)) (reln, blocknum, buffer);
|
||||
|
||||
@@ -250,7 +250,7 @@ smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
|
||||
int
|
||||
smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
|
||||
status = (*(smgrsw[which].smgr_write)) (reln, blocknum, buffer);
|
||||
|
||||
@@ -267,7 +267,7 @@ smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
|
||||
int
|
||||
smgrflush(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
|
||||
status = (*(smgrsw[which].smgr_flush)) (reln, blocknum, buffer);
|
||||
|
||||
@@ -299,9 +299,9 @@ smgrblindwrt(int16 which,
|
||||
BlockNumber blkno,
|
||||
char *buffer)
|
||||
{
|
||||
char *dbstr;
|
||||
char *relstr;
|
||||
int status;
|
||||
char *dbstr;
|
||||
char *relstr;
|
||||
int status;
|
||||
|
||||
dbstr = pstrdup(dbname);
|
||||
relstr = pstrdup(relname);
|
||||
@@ -329,7 +329,7 @@ smgrblindwrt(int16 which,
|
||||
int
|
||||
smgrnblocks(int16 which, Relation reln)
|
||||
{
|
||||
int nblocks;
|
||||
int nblocks;
|
||||
|
||||
if ((nblocks = (*(smgrsw[which].smgr_nblocks)) (reln)) < 0)
|
||||
elog(WARN, "cannot count blocks for %s",
|
||||
@@ -348,7 +348,7 @@ smgrnblocks(int16 which, Relation reln)
|
||||
int
|
||||
smgrtruncate(int16 which, Relation reln, int nblocks)
|
||||
{
|
||||
int newblks;
|
||||
int newblks;
|
||||
|
||||
newblks = nblocks;
|
||||
if (smgrsw[which].smgr_truncate)
|
||||
@@ -368,7 +368,7 @@ smgrtruncate(int16 which, Relation reln, int nblocks)
|
||||
int
|
||||
smgrcommit()
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NSmgr; i++)
|
||||
{
|
||||
@@ -386,7 +386,7 @@ smgrcommit()
|
||||
int
|
||||
smgrabort()
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NSmgr; i++)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.3 1997/09/07 04:49:26 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.4 1997/09/08 02:29:37 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
typedef struct smgrid
|
||||
{
|
||||
char *smgr_name;
|
||||
} smgrid;
|
||||
char *smgr_name;
|
||||
} smgrid;
|
||||
|
||||
/*
|
||||
* StorageManager[] -- List of defined storage managers.
|
||||
@@ -30,19 +30,19 @@ typedef struct smgrid
|
||||
* which of these is (or is not) defined.
|
||||
*/
|
||||
|
||||
static smgrid StorageManager[] = {
|
||||
static smgrid StorageManager[] = {
|
||||
{"magnetic disk"},
|
||||
#ifdef MAIN_MEMORY
|
||||
{"main memory"}
|
||||
#endif /* MAIN_MEMORY */
|
||||
};
|
||||
|
||||
static int NStorageManagers = lengthof(StorageManager);
|
||||
static int NStorageManagers = lengthof(StorageManager);
|
||||
|
||||
int2
|
||||
smgrin(char *s)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NStorageManagers; i++)
|
||||
{
|
||||
@@ -53,10 +53,10 @@ smgrin(char *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
smgrout(int2 i)
|
||||
{
|
||||
char *s;
|
||||
char *s;
|
||||
|
||||
if (i >= NStorageManagers || i < 0)
|
||||
elog(WARN, "Illegal storage manager id %d", i);
|
||||
|
||||
Reference in New Issue
Block a user