1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

pgindent run over code.

This commit is contained in:
Bruce Momjian
1999-05-25 16:15:34 +00:00
parent 4b04b01aaa
commit 07842084fe
413 changed files with 11723 additions and 10769 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.22 1999/02/22 06:16:50 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.23 1999/05/25 16:10:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,6 +61,7 @@ BufferBlock BufferBlocks;
#ifndef HAS_TEST_AND_SET
long *NWaitIOBackendP;
#endif
extern IpcSemaphoreId WaitIOSemId;
@@ -238,14 +239,14 @@ InitBufferPool(IPCKey key)
WaitIOSemId = IpcSemaphoreCreate(IPCKeyGetWaitIOSemaphoreKey(key),
1, IPCProtection, 0, 1, &status);
WaitCLSemId = IpcSemaphoreCreate(IPCKeyGetWaitCLSemaphoreKey(key),
1, IPCProtection,
IpcSemaphoreDefaultStartValue,
1, IPCProtection,
IpcSemaphoreDefaultStartValue,
1, &status);
}
#endif
PrivateRefCount = (long *) calloc(NBuffers, sizeof(long));
LastRefCount = (long *) calloc(NBuffers, sizeof(long));
BufferLocks = (bits8*) calloc (NBuffers, sizeof(bits8));
BufferLocks = (bits8 *) calloc(NBuffers, sizeof(bits8));
CommitInfoNeedsSave = (long *) calloc(NBuffers, sizeof(long));
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.51 1999/05/10 00:45:35 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.52 1999/05/25 16:10:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -86,6 +86,7 @@ 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 */
#endif /* HAS_TEST_AND_SET */
static Buffer ReadBufferWithBufferLock(Relation relation, BlockNumber blockNum,
@@ -95,7 +96,7 @@ static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum,
static int FlushBuffer(Buffer buffer, bool release);
static void BufferSync(void);
static int BufferReplace(BufferDesc *bufHdr, bool bufferLockHeld);
void PrintBufferDescs(void);
void PrintBufferDescs(void);
/* not static but used by vacuum only ... */
int BlowawayRelationBuffers(Relation rel, BlockNumber block);
@@ -161,7 +162,7 @@ extern int ShowPinTrace;
* defined */
/*
* ReadBuffer
* ReadBuffer
*
*/
Buffer
@@ -1116,7 +1117,7 @@ WaitIO(BufferDesc *buf, SPINLOCK spinlock)
}
/*
* SignalIO
* SignalIO
*/
static void
SignalIO(BufferDesc *buf)
@@ -1217,7 +1218,7 @@ BufferPoolCheckLeak()
BufferDesc *buf = &(BufferDescriptors[i - 1]);
elog(NOTICE,
"Buffer Leak: [%03d] (freeNext=%d, freePrev=%d, \
"Buffer Leak: [%03d] (freeNext=%d, freePrev=%d, \
relname=%s, blockNum=%d, flags=0x%x, refcount=%d %d)",
i - 1, buf->freeNext, buf->freePrev,
buf->sb_relname, buf->tag.blockNum, buf->flags,
@@ -1246,7 +1247,7 @@ FlushBufferPool(int StableMainMemoryFlag)
}
/*
* BufferGetBlockNumber
* BufferGetBlockNumber
* Returns the block number associated with a buffer.
*
* Note:
@@ -1266,7 +1267,7 @@ BufferGetBlockNumber(Buffer buffer)
#ifdef NOT_USED
/*
* BufferGetRelation
* BufferGetRelation
* Returns the relation desciptor associated with a buffer.
*
* Note:
@@ -1299,6 +1300,7 @@ BufferGetRelation(Buffer buffer)
return relation;
}
#endif
/*
@@ -1363,7 +1365,7 @@ BufferReplace(BufferDesc *bufHdr, bool bufferLockHeld)
}
/*
* RelationGetNumberOfBlocks
* RelationGetNumberOfBlocks
* Returns the buffer descriptor associated with a page in a relation.
*
* Note:
@@ -1375,7 +1377,7 @@ BlockNumber
RelationGetNumberOfBlocks(Relation relation)
{
return ((relation->rd_myxactonly) ? relation->rd_nblocks :
smgrnblocks(DEFAULT_SMGR, relation));
smgrnblocks(DEFAULT_SMGR, relation));
}
/* ---------------------------------------------------------------------
@@ -1941,8 +1943,8 @@ UnlockBuffers()
{
if (BufferLocks[i] == 0)
continue;
Assert(BufferIsValid(i+1));
Assert(BufferIsValid(i + 1));
buf = &(BufferDescriptors[i]);
#ifdef HAS_TEST_AND_SET
@@ -1976,7 +1978,7 @@ UnlockBuffers()
}
void
LockBuffer (Buffer buffer, int mode)
LockBuffer(Buffer buffer, int mode)
{
BufferDesc *buf;
@@ -1984,31 +1986,31 @@ LockBuffer (Buffer buffer, int mode)
if (BufferIsLocal(buffer))
return;
buf = &(BufferDescriptors[buffer-1]);
buf = &(BufferDescriptors[buffer - 1]);
#ifdef HAS_TEST_AND_SET
S_LOCK(&(buf->cntx_lock));
S_LOCK(&(buf->cntx_lock));
#else
IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock);
IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock);
#endif
if (mode == BUFFER_LOCK_UNLOCK)
{
if (BufferLocks[buffer-1] & BL_R_LOCK)
if (BufferLocks[buffer - 1] & BL_R_LOCK)
{
Assert(buf->r_locks > 0);
Assert(!(buf->w_lock));
Assert(!(BufferLocks[buffer-1] & (BL_W_LOCK | BL_RI_LOCK)))
(buf->r_locks)--;
BufferLocks[buffer-1] &= ~BL_R_LOCK;
Assert(!(BufferLocks[buffer - 1] & (BL_W_LOCK | BL_RI_LOCK)))
(buf->r_locks)--;
BufferLocks[buffer - 1] &= ~BL_R_LOCK;
}
else if (BufferLocks[buffer-1] & BL_W_LOCK)
else if (BufferLocks[buffer - 1] & BL_W_LOCK)
{
Assert(buf->w_lock);
Assert(buf->r_locks == 0 && !buf->ri_lock);
Assert(!(BufferLocks[buffer-1] & (BL_R_LOCK | BL_RI_LOCK)))
buf->w_lock = false;
BufferLocks[buffer-1] &= ~BL_W_LOCK;
Assert(!(BufferLocks[buffer - 1] & (BL_R_LOCK | BL_RI_LOCK)))
buf->w_lock = false;
BufferLocks[buffer - 1] &= ~BL_W_LOCK;
}
else
elog(ERROR, "UNLockBuffer: buffer %u is not locked", buffer);
@@ -2017,7 +2019,7 @@ LockBuffer (Buffer buffer, int mode)
{
unsigned i = 0;
Assert(!(BufferLocks[buffer-1] & (BL_R_LOCK | BL_W_LOCK | BL_RI_LOCK)));
Assert(!(BufferLocks[buffer - 1] & (BL_R_LOCK | BL_W_LOCK | BL_RI_LOCK)));
while (buf->ri_lock || buf->w_lock)
{
#ifdef HAS_TEST_AND_SET
@@ -2027,23 +2029,23 @@ LockBuffer (Buffer buffer, int mode)
#else
IpcSemaphoreUnlock(WaitCLSemId, 0, IpcExclusiveLock);
s_lock_sleep(i++)
IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock);
IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock);
#endif
}
(buf->r_locks)++;
BufferLocks[buffer-1] |= BL_R_LOCK;
BufferLocks[buffer - 1] |= BL_R_LOCK;
}
else if (mode == BUFFER_LOCK_EXCLUSIVE)
{
unsigned i = 0;
Assert(!(BufferLocks[buffer-1] & (BL_R_LOCK | BL_W_LOCK | BL_RI_LOCK)));
Assert(!(BufferLocks[buffer - 1] & (BL_R_LOCK | BL_W_LOCK | BL_RI_LOCK)));
while (buf->r_locks > 0 || buf->w_lock)
{
if (buf->r_locks > 3)
{
if (!(BufferLocks[buffer-1] & BL_RI_LOCK))
BufferLocks[buffer-1] |= BL_RI_LOCK;
if (!(BufferLocks[buffer - 1] & BL_RI_LOCK))
BufferLocks[buffer - 1] |= BL_RI_LOCK;
buf->ri_lock = true;
}
#ifdef HAS_TEST_AND_SET
@@ -2053,24 +2055,24 @@ LockBuffer (Buffer buffer, int mode)
#else
IpcSemaphoreUnlock(WaitCLSemId, 0, IpcExclusiveLock);
s_lock_sleep(i++)
IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock);
IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock);
#endif
}
buf->w_lock = true;
BufferLocks[buffer-1] |= BL_W_LOCK;
if (BufferLocks[buffer-1] & BL_RI_LOCK)
BufferLocks[buffer - 1] |= BL_W_LOCK;
if (BufferLocks[buffer - 1] & BL_RI_LOCK)
{
buf->ri_lock = false;
BufferLocks[buffer-1] &= ~BL_RI_LOCK;
BufferLocks[buffer - 1] &= ~BL_RI_LOCK;
}
}
else
elog(ERROR, "LockBuffer: unknown lock mode %d", mode);
#ifdef HAS_TEST_AND_SET
S_UNLOCK(&(buf->cntx_lock));
S_UNLOCK(&(buf->cntx_lock));
#else
IpcSemaphoreUnlock(WaitCLSemId, 0, IpcExclusiveLock);
IpcSemaphoreUnlock(WaitCLSemId, 0, IpcExclusiveLock);
#endif
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.14 1999/02/13 23:17:59 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.15 1999/05/25 16:10:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -55,7 +55,7 @@ extern SPINLOCK BufMgrLock;
/*
* AddBufferToFreelist
* AddBufferToFreelist
*
* In theory, this is the only routine that needs to be changed
* if the buffer replacement strategy changes. Just change

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/s_lock.c,v 1.18 1999/03/14 16:03:00 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/s_lock.c,v 1.19 1999/05/25 16:11:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -100,7 +100,8 @@ s_lock(volatile slock_t *lock, const char *file, const int line)
#if defined(__m68k__)
static void
tas_dummy() /* really means: extern int tas(slock_t **lock); */
tas_dummy() /* really means: extern int tas(slock_t
* **lock); */
{
__asm__(" \n\
.global _tas \n\
@@ -163,7 +164,8 @@ fail: \n\
j $31 \n\
");
}
#endif /* __mips */
#endif /* __mips */
#else /* defined(__GNUC__) */
/***************************************************************************

View File

@@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Id: fd.c,v 1.39 1999/05/09 00:52:07 tgl Exp $
* $Id: fd.c,v 1.40 1999/05/25 16:11:03 momjian Exp $
*
* NOTES:
*
@@ -103,11 +103,11 @@ typedef struct vfd
unsigned short fdstate; /* bitflags for VFD's state */
/* these are the assigned bits in fdstate: */
#define FD_DIRTY (1 << 0) /* written to, but not yet fsync'd */
#define FD_TEMPORARY (1 << 1) /* should be unlinked when closed */
#define FD_DIRTY (1 << 0)/* written to, but not yet fsync'd */
#define FD_TEMPORARY (1 << 1)/* should be unlinked when closed */
File nextFree; /* link to next free VFD, if in freelist */
File lruMoreRecently; /* doubly linked recency-of-use list */
File lruMoreRecently;/* doubly linked recency-of-use list */
File lruLessRecently;
long seekPos; /* current logical file position */
char *fileName; /* name of file, or NULL for unused VFD */
@@ -118,7 +118,7 @@ typedef struct vfd
/*
* Virtual File Descriptor array pointer and size. This grows as
* needed. 'File' values are indexes into this array.
* needed. 'File' values are indexes into this array.
* Note that VfdCache[0] is not a usable VFD, just a list header.
*/
static Vfd *VfdCache;
@@ -139,7 +139,7 @@ static int nfile = 0;
#define MAX_ALLOCATED_FILES 32
static int numAllocatedFiles = 0;
static FILE * allocatedFiles[MAX_ALLOCATED_FILES];
static FILE *allocatedFiles[MAX_ALLOCATED_FILES];
/*
* Number of temporary files opened during the current transaction;
@@ -348,7 +348,7 @@ LruInsert(File file)
if (FileIsNotOpen(file))
{
while (nfile+numAllocatedFiles >= pg_nofile())
while (nfile + numAllocatedFiles >= pg_nofile())
ReleaseLruFile();
/*
@@ -434,12 +434,13 @@ AllocateVfd()
if (VfdCache[0].nextFree == 0)
{
/*
* The free list is empty so it is time to increase the size of
* the array. We choose to double it each time this happens.
* However, there's not much point in starting *real* small.
*/
Size newCacheSize = SizeVfdCache * 2;
Size newCacheSize = SizeVfdCache * 2;
if (newCacheSize < 32)
newCacheSize = 32;
@@ -532,8 +533,9 @@ FileAccess(File file)
file, VfdCache[file].fileName));
/*
* Is the file open? If not, open it and put it at the head of the LRU
* ring (possibly closing the least recently used file to get an FD).
* Is the file open? If not, open it and put it at the head of the
* LRU ring (possibly closing the least recently used file to get an
* FD).
*/
if (FileIsNotOpen(file))
@@ -589,7 +591,7 @@ fileNameOpenFile(FileName fileName,
file = AllocateVfd();
vfdP = &VfdCache[file];
while (nfile+numAllocatedFiles >= pg_nofile())
while (nfile + numAllocatedFiles >= pg_nofile())
ReleaseLruFile();
tryAgain:
@@ -659,10 +661,13 @@ PathNameOpenFile(FileName fileName, int fileFlags, int fileMode)
File
OpenTemporaryFile(void)
{
char tempfilename[64];
File file;
char tempfilename[64];
File file;
/* Generate a tempfile name that's unique within the current transaction */
/*
* Generate a tempfile name that's unique within the current
* transaction
*/
snprintf(tempfilename, sizeof(tempfilename),
"pg_temp%d.%ld", (int) getpid(), tempFileCounter++);
@@ -723,9 +728,7 @@ FileClose(File file)
* Delete the file if it was temporary
*/
if (VfdCache[file].fdstate & FD_TEMPORARY)
{
unlink(VfdCache[file].fileName);
}
/*
* Return the Vfd slot to the free list
@@ -817,9 +820,7 @@ FileSeek(File file, long offset, int whence)
}
}
else
{
VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence);
}
return VfdCache[file].seekPos;
}
@@ -893,7 +894,7 @@ FileNameUnlink(char *filename)
/*
* Routines that want to use stdio (ie, FILE*) should use AllocateFile
* rather than plain fopen(). This lets fd.c deal with freeing FDs if
* necessary to open the file. When done, call FreeFile rather than fclose.
* necessary to open the file. When done, call FreeFile rather than fclose.
*
* Note that files that will be open for any significant length of time
* should NOT be handled this way, since they cannot share kernel file
@@ -929,21 +930,19 @@ TryAgain:
}
}
else
{
allocatedFiles[numAllocatedFiles++] = file;
}
return file;
}
void
FreeFile(FILE *file)
{
int i;
int i;
DO_DB(elog(DEBUG, "FreeFile: Allocated %d.", numAllocatedFiles));
/* Remove file from list of allocated files, if it's present */
for (i = numAllocatedFiles; --i >= 0; )
for (i = numAllocatedFiles; --i >= 0;)
{
if (allocatedFiles[i] == file)
{
@@ -971,7 +970,7 @@ closeAllVfds()
if (SizeVfdCache > 0)
{
Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */
Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */
for (i = 1; i < SizeVfdCache; i++)
{
if (!FileIsNotOpen(i))
@@ -995,7 +994,7 @@ AtEOXact_Files(void)
if (SizeVfdCache > 0)
{
Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */
Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */
for (i = 1; i < SizeVfdCache; i++)
{
if ((VfdCache[i].fdstate & FD_TEMPORARY) &&
@@ -1005,12 +1004,11 @@ AtEOXact_Files(void)
}
while (numAllocatedFiles > 0)
{
FreeFile(allocatedFiles[0]);
}
/* Reset the tempfile name counter to 0; not really necessary,
* but helps keep the names from growing unreasonably long.
/*
* Reset the tempfile name counter to 0; not really necessary, but
* helps keep the names from growing unreasonably long.
*/
tempFileCounter = 0;
}
@@ -1018,7 +1016,7 @@ AtEOXact_Files(void)
/*
* Operations on BufFiles --- a very incomplete emulation of stdio
* atop virtual Files. Currently, we only support the buffered-I/O
* atop virtual Files. Currently, we only support the buffered-I/O
* aspect of stdio: a read or write of the low-level File occurs only
* when the buffer is filled or emptied. This is an even bigger win
* for virtual Files than ordinary kernel files, since reducing the
@@ -1032,12 +1030,13 @@ AtEOXact_Files(void)
* by elog(ERROR).
*/
struct BufFile {
File file; /* the underlying virtual File */
bool dirty; /* does buffer need to be written? */
int pos; /* next read/write position in buffer */
int nbytes; /* total # of valid bytes in buffer */
char buffer[BLCKSZ];
struct BufFile
{
File file; /* the underlying virtual File */
bool dirty; /* does buffer need to be written? */
int pos; /* next read/write position in buffer */
int nbytes; /* total # of valid bytes in buffer */
char buffer[BLCKSZ];
};
@@ -1046,10 +1045,10 @@ struct BufFile {
*
* This is comparable to fdopen() in stdio.
*/
BufFile *
BufFile *
BufFileCreate(File file)
{
BufFile *bfile = (BufFile *) palloc(sizeof(BufFile));
BufFile *bfile = (BufFile *) palloc(sizeof(BufFile));
bfile->file = file;
bfile->dirty = false;
@@ -1065,7 +1064,7 @@ BufFileCreate(File file)
* Like fclose(), this also implicitly FileCloses the underlying File.
*/
void
BufFileClose(BufFile *file)
BufFileClose(BufFile * file)
{
/* flush any unwritten data */
BufFileFlush(file);
@@ -1080,10 +1079,10 @@ BufFileClose(BufFile *file)
* Like fread() except we assume 1-byte element size.
*/
size_t
BufFileRead(BufFile *file, void *ptr, size_t size)
BufFileRead(BufFile * file, void *ptr, size_t size)
{
size_t nread = 0;
size_t nthistime;
size_t nread = 0;
size_t nthistime;
if (file->dirty)
{
@@ -1126,10 +1125,10 @@ BufFileRead(BufFile *file, void *ptr, size_t size)
* Like fwrite() except we assume 1-byte element size.
*/
size_t
BufFileWrite(BufFile *file, void *ptr, size_t size)
BufFileWrite(BufFile * file, void *ptr, size_t size)
{
size_t nwritten = 0;
size_t nthistime;
size_t nwritten = 0;
size_t nthistime;
while (size > 0)
{
@@ -1170,7 +1169,7 @@ BufFileWrite(BufFile *file, void *ptr, size_t size)
* Like fflush()
*/
int
BufFileFlush(BufFile *file)
BufFileFlush(BufFile * file)
{
if (file->dirty)
{
@@ -1188,7 +1187,7 @@ BufFileFlush(BufFile *file)
* the new file offset (or -1 in case of error).
*/
long
BufFileSeek(BufFile *file, long offset, int whence)
BufFileSeek(BufFile * file, long offset, int whence)
{
if (BufFileFlush(file) < 0)
return -1L;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.36 1999/02/21 01:41:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.37 1999/05/25 16:11:07 momjian Exp $
*
* NOTES
*
@@ -680,7 +680,7 @@ struct ipcdummy
SLock slocks[MAX_SPINS + 1];
};
#define SLOCKMEMORYSIZE sizeof(struct ipcdummy)
#define SLOCKMEMORYSIZE sizeof(struct ipcdummy)
void
CreateAndInitSLockMemory(IPCKey key)
@@ -747,4 +747,5 @@ IpcConfigTip(void)
fprintf(stderr, "shared memory or System V IPC semaphore configuration.\n");
fprintf(stderr, "See the FAQ for more detailed information\n");
}
#endif

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.23 1999/03/06 21:17:41 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.24 1999/05/25 16:11:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -25,7 +25,7 @@
#include "miscadmin.h" /* for DebugLvl */
/*
* SystemPortAddressCreateMemoryKey
* SystemPortAddressCreateMemoryKey
* Returns a memory key given a port address.
*/
IPCKey
@@ -37,7 +37,7 @@ SystemPortAddressCreateIPCKey(SystemPortAddress address)
}
/*
* CreateSharedMemoryAndSemaphores
* CreateSharedMemoryAndSemaphores
* Creates and initializes shared memory and semaphores.
*/
/**************************************************
@@ -75,8 +75,8 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
/*
* Size of the primary shared-memory block is estimated via
* moderately-accurate estimates for the big hogs, plus 100K for
* the stuff that's too small to bother with estimating.
* moderately-accurate estimates for the big hogs, plus 100K for the
* stuff that's too small to bother with estimating.
*/
size = BufferShmemSize() + LockShmemSize(maxBackends);
#ifdef STABLE_MEMORY_STORAGE
@@ -113,7 +113,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
/*
* AttachSharedMemoryAndSemaphores
* AttachSharedMemoryAndSemaphores
* Attachs existant shared memory and semaphores.
*/
void

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.39 1999/04/02 04:51:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.40 1999/05/25 16:11:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -106,7 +106,7 @@ ShmemIndexReset(void)
}
/*
* CreateSharedRegion()
* CreateSharedRegion()
*
* This routine is called once by the postmaster to
* initialize the shared buffer pool. Assume there is
@@ -348,10 +348,10 @@ ShmemInitHash(char *name, /* table string name for shmem index */
long *location;
/*
* Hash tables allocated in shared memory have a fixed directory;
* it can't grow or other backends wouldn't be able to find it.
* The segbase is for calculating pointer values.
* The shared memory allocator must be specified too.
* Hash tables allocated in shared memory have a fixed directory; it
* can't grow or other backends wouldn't be able to find it. The
* segbase is for calculating pointer values. The shared memory
* allocator must be specified too.
*/
infoP->dsize = infoP->max_dsize = DEF_DIRSIZE;
infoP->segbase = (long *) ShmemBase;
@@ -360,7 +360,7 @@ ShmemInitHash(char *name, /* table string name for shmem index */
/* look it up in the shmem index */
location = ShmemInitStruct(name,
sizeof(HHDR) + DEF_DIRSIZE * sizeof(SEG_OFFSET),
sizeof(HHDR) + DEF_DIRSIZE * sizeof(SEG_OFFSET),
&found);
/*
@@ -379,7 +379,7 @@ ShmemInitHash(char *name, /* table string name for shmem index */
/* Now provide the header and directory pointers */
infoP->hctl = (long *) location;
infoP->dir = (long *) (((char*) location) + sizeof(HHDR));
infoP->dir = (long *) (((char *) location) + sizeof(HHDR));
return hash_create(init_size, infoP, hash_flags);
}
@@ -636,13 +636,13 @@ TransactionIdIsInProgress(TransactionId xid)
Snapshot
GetSnapshotData(bool serializable)
{
Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData));
ShmemIndexEnt *result;
PROC *proc;
TransactionId cid = GetCurrentTransactionId();
TransactionId xid;
uint32 count = 0;
uint32 have = 32;
Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData));
ShmemIndexEnt *result;
PROC *proc;
TransactionId cid = GetCurrentTransactionId();
TransactionId xid;
uint32 count = 0;
uint32 have = 32;
Assert(ShmemIndex);
@@ -670,7 +670,7 @@ GetSnapshotData(bool serializable)
strncmp(result->key, "PID ", 4) != 0)
continue;
proc = (PROC *) MAKE_PTR(result->location);
xid = proc->xid; /* we don't use spin-locking in xact.c ! */
xid = proc->xid; /* we don't use spin-locking in xact.c ! */
if (proc == MyProc || xid < FirstTransactionId)
continue;
if (xid < snapshot->xmin)
@@ -697,18 +697,18 @@ GetSnapshotData(bool serializable)
/*
* GetXmaxRecent -- returns oldest transaction that was running
* when all current transaction was started.
* It's used by vacuum to decide what deleted
* tuples must be preserved in a table.
* when all current transaction was started.
* It's used by vacuum to decide what deleted
* tuples must be preserved in a table.
*
* And yet another strange func for this place... - vadim 03/18/99
*/
void
GetXmaxRecent(TransactionId *XmaxRecent)
{
ShmemIndexEnt *result;
PROC *proc;
TransactionId xmin;
ShmemIndexEnt *result;
PROC *proc;
TransactionId xmin;
Assert(ShmemIndex);
@@ -728,7 +728,7 @@ GetXmaxRecent(TransactionId *XmaxRecent)
strncmp(result->key, "PID ", 4) != 0)
continue;
proc = (PROC *) MAKE_PTR(result->location);
xmin = proc->xmin; /* we don't use spin-locking in xact.c ! */
xmin = proc->xmin; /* we don't use spin-locking in xact.c ! */
if (proc == MyProc || xmin < FirstTransactionId)
continue;
if (xmin < *XmaxRecent)

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.13 1999/02/13 23:18:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.14 1999/05/25 16:11:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -87,7 +87,7 @@ InitSharedInvalidationState(void)
}
/*
* RegisterSharedInvalid
* RegisterSharedInvalid
* Returns a new local cache invalidation state containing a new entry.
*
* Note:
@@ -147,7 +147,7 @@ RegisterSharedInvalid(int cacheId, /* XXX */
}
/*
* InvalidateSharedInvalid
* InvalidateSharedInvalid
* Processes all entries in a shared cache invalidation state.
*/
/****************************************************************************/

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.18 1999/05/10 00:45:37 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.19 1999/05/25 16:11:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -144,9 +144,7 @@ SIAssignBackendId(SISeg *segInOutP, BackendTag backendTag)
for (index++; index < MAXBACKENDS; index++)
{
if (segInOutP->procState[index].tag == backendTag)
{
elog(FATAL, "SIAssignBackendId: tag %d found twice", backendTag);
}
}
Assert(stateP);
@@ -187,7 +185,7 @@ SISetDeadProcess(SISeg *segP, int backendId)
}
/*
* CleanupInvalidationState
* CleanupInvalidationState
* Note:
* This is a temporary hack. ExitBackend should call this instead
* of exit (via on_shmem_exit).

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.52 1999/05/10 00:45:41 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.53 1999/05/25 16:11:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -131,7 +131,7 @@ inv_create(int flags)
if (RelnameFindRelid(indname) != InvalidOid)
{
elog(ERROR,
"internal error: %s already exists -- cannot create large obj",
"internal error: %s already exists -- cannot create large obj",
indname);
}
@@ -437,13 +437,13 @@ inv_tell(LargeObjectDesc *obj_desc)
int
inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
{
HeapTupleData tuple;
int nread;
int off;
int ncopy;
Datum d;
HeapTupleData tuple;
int nread;
int off;
int ncopy;
Datum d;
struct varlena *fsblock;
bool isNull;
bool isNull;
Assert(PointerIsValid(obj_desc));
Assert(buf != NULL);
@@ -499,9 +499,9 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
int
inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
{
HeapTupleData tuple;
int nwritten;
int tuplen;
HeapTupleData tuple;
int nwritten;
int tuplen;
Assert(PointerIsValid(obj_desc));
Assert(buf != NULL);
@@ -549,10 +549,12 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
}
else
tuplen = inv_wrold(obj_desc, buf, nbytes - nwritten, &tuple, buffer);
/* inv_wrold() has already issued WriteBuffer()
which has decremented local reference counter
(LocalRefCount). So we should not call
ReleaseBuffer() here. -- Tatsuo 99/2/4 */
/*
* inv_wrold() has already issued WriteBuffer() which has
* decremented local reference counter (LocalRefCount). So we
* should not call ReleaseBuffer() here. -- Tatsuo 99/2/4
*/
}
/* move pointers past the amount we just wrote */
@@ -626,25 +628,26 @@ inv_fetchtup(LargeObjectDesc *obj_desc, HeapTuple tuple, Buffer *buffer)
|| obj_desc->offset < obj_desc->lowbyte
|| !ItemPointerIsValid(&(obj_desc->htid)))
{
ScanKeyData skey;
ScanKeyData skey;
ScanKeyEntryInitialize(&skey, 0x0, 1, F_INT4GE,
Int32GetDatum(obj_desc->offset));
Int32GetDatum(obj_desc->offset));
/* initialize scan key if not done */
if (obj_desc->iscan == (IndexScanDesc) NULL)
{
/*
* As scan index may be prematurely closed (on commit), we
* must use object current offset (was 0) to reinitialize the
* entry [ PA ].
*/
obj_desc->iscan = index_beginscan(obj_desc->index_r,
(bool) 0, (uint16) 1,
&skey);
} else {
index_rescan(obj_desc->iscan, false, &skey);
}
(bool) 0, (uint16) 1,
&skey);
}
else
index_rescan(obj_desc->iscan, false, &skey);
do
{
res = index_getnext(obj_desc->iscan, ForwardScanDirection);
@@ -671,15 +674,14 @@ inv_fetchtup(LargeObjectDesc *obj_desc, HeapTuple tuple, Buffer *buffer)
} while (tuple->t_data == NULL);
/* remember this tid -- we may need it for later reads/writes */
ItemPointerCopy(&(tuple->t_self), &obj_desc->htid);
ItemPointerCopy(&(tuple->t_self), &obj_desc->htid);
}
else
{
tuple->t_self = obj_desc->htid;
heap_fetch(obj_desc->heap_r, SnapshotNow, tuple, buffer);
if (tuple->t_data == NULL) {
if (tuple->t_data == NULL)
elog(ERROR, "inv_fetchtup: heap_fetch failed");
}
}
/*
@@ -751,11 +753,13 @@ inv_wrnew(LargeObjectDesc *obj_desc, char *buf, int nbytes)
nblocks = RelationGetNumberOfBlocks(hr);
if (nblocks > 0) {
if (nblocks > 0)
{
buffer = ReadBuffer(hr, nblocks - 1);
page = BufferGetPage(buffer);
}
else {
else
{
buffer = ReadBuffer(hr, P_NEW);
page = BufferGetPage(buffer);
PageInit(page, BufferGetPageSize(buffer), 0);
@@ -794,7 +798,7 @@ inv_wrnew(LargeObjectDesc *obj_desc, char *buf, int nbytes)
ntup = inv_newtuple(obj_desc, buffer, page, buf, nwritten);
inv_indextup(obj_desc, ntup);
pfree (ntup);
pfree(ntup);
/* new tuple is inserted */
WriteBuffer(buffer);
@@ -874,11 +878,13 @@ inv_wrold(LargeObjectDesc *obj_desc,
nblocks = RelationGetNumberOfBlocks(hr);
if (nblocks > 0) {
if (nblocks > 0)
{
newbuf = ReadBuffer(hr, nblocks - 1);
newpage = BufferGetPage(newbuf);
}
else {
else
{
newbuf = ReadBuffer(hr, P_NEW);
newpage = BufferGetPage(newbuf);
PageInit(newpage, BufferGetPageSize(newbuf), 0);
@@ -966,7 +972,7 @@ inv_wrold(LargeObjectDesc *obj_desc,
/* index the new tuple */
inv_indextup(obj_desc, ntup);
pfree (ntup);
pfree(ntup);
/*
* move the scandesc forward so we don't reread the newly inserted
@@ -1002,7 +1008,7 @@ inv_newtuple(LargeObjectDesc *obj_desc,
char *dbuf,
int nwrite)
{
HeapTuple ntup = (HeapTuple) palloc (sizeof(HeapTupleData));
HeapTuple ntup = (HeapTuple) palloc(sizeof(HeapTupleData));
PageHeader ph;
int tupsize;
int hoff;
@@ -1227,7 +1233,7 @@ _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln)
{
IndexScanDesc iscan;
RetrieveIndexResult res;
HeapTupleData tuple;
HeapTupleData tuple;
Datum d;
long size;
bool isNull;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.23 1999/05/07 01:23:02 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.24 1999/05/25 16:11:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -76,7 +76,7 @@ static MASK LockConflicts[] = {
/* AccessExclusiveLock */
(1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) | (1 << ShareLock) |
(1 << RowExclusiveLock) | (1 << RowShareLock) | (1 << AccessExclusiveLock) |
(1 << RowExclusiveLock) | (1 << RowShareLock) | (1 << AccessExclusiveLock) |
(1 << AccessShareLock),
};
@@ -92,7 +92,7 @@ static int LockPrios[] = {
7
};
LOCKMETHOD LockTableId = (LOCKMETHOD) NULL;
LOCKMETHOD LockTableId = (LOCKMETHOD) NULL;
LOCKMETHOD LongTermTableId = (LOCKMETHOD) NULL;
/*
@@ -104,12 +104,14 @@ InitLockTable()
int lockmethod;
lockmethod = LockMethodTableInit("LockTable",
LockConflicts, LockPrios, MAX_LOCKMODES - 1);
LockConflicts, LockPrios, MAX_LOCKMODES - 1);
LockTableId = lockmethod;
if (!(LockTableId))
elog(ERROR, "InitLockTable: couldnt initialize lock table");
#ifdef USER_LOCKS
/*
* Allocate another tableId for long-term locks
*/
@@ -125,7 +127,7 @@ InitLockTable()
}
/*
* RelationInitLockInfo
* RelationInitLockInfo
* Initializes the lock information in a relation descriptor.
*/
void
@@ -322,10 +324,10 @@ XactLockTableWait(TransactionId xid)
LockAcquire(LockTableId, &tag, ShareLock);
TransactionIdFlushCache();
/*
* Transaction was committed/aborted/crashed -
* we have to update pg_log if transaction is still
* marked as running.
* Transaction was committed/aborted/crashed - we have to update
* pg_log if transaction is still marked as running.
*/
if (!TransactionIdDidCommit(xid) && !TransactionIdDidAbort(xid))
TransactionIdAbort(xid);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.52 1999/05/13 15:55:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.53 1999/05/25 16:11:21 momjian Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
@@ -50,7 +50,7 @@
#include "utils/trace.h"
#include "utils/ps_status.h"
static int WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode);
static int WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode);
/*
* lockDebugRelation can be used to trace unconditionally a single relation,
@@ -658,22 +658,22 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
*/
if (lockMethodTable->ctl->conflictTab[lockmode] & lock->waitMask)
{
int i = 1;
int i = 1;
/*
* If I don't hold locks or my locks don't conflict
* with waiters then force to sleep.
* If I don't hold locks or my locks don't conflict with waiters
* then force to sleep.
*/
if (result->nHolding > 0)
{
for ( ; i <= lockMethodTable->ctl->numLockModes; i++)
for (; i <= lockMethodTable->ctl->numLockModes; i++)
{
if (result->holders[i] > 0 &&
if (result->holders[i] > 0 &&
lockMethodTable->ctl->conflictTab[i] & lock->waitMask)
break; /* conflict */
break; /* conflict */
}
}
if (result->nHolding == 0 || i > lockMethodTable->ctl->numLockModes)
{
XID_PRINT("LockAcquire: higher priority proc waiting",
@@ -718,17 +718,18 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
return FALSE;
}
#endif
/*
* Construct bitmask of locks we hold before going to sleep.
*/
MyProc->holdLock = 0;
if (result->nHolding > 0)
{
int i,
tmpMask = 2;
int i,
tmpMask = 2;
for (i = 1; i <= lockMethodTable->ctl->numLockModes;
i++, tmpMask <<= 1)
for (i = 1; i <= lockMethodTable->ctl->numLockModes;
i++, tmpMask <<= 1)
{
if (result->holders[i] > 0)
MyProc->holdLock |= tmpMask;
@@ -1166,14 +1167,15 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
wakeupNeeded = false;
else
#endif
/*
* Above is not valid any more (due to MVCC lock modes).
* Actually we should compare activeHolders[lockmode] with
* number of waiters holding lock of this type and try to
* wakeup only if these numbers are equal (and lock released
* conflicts with locks requested by waiters). For the moment
* we only check the last condition.
*/
/*
* Above is not valid any more (due to MVCC lock modes). Actually
* we should compare activeHolders[lockmode] with number of
* waiters holding lock of this type and try to wakeup only if
* these numbers are equal (and lock released conflicts with locks
* requested by waiters). For the moment we only check the last
* condition.
*/
if (lockMethodTable->ctl->conflictTab[lockmode] & lock->waitMask)
wakeupNeeded = true;
@@ -1238,14 +1240,12 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
}
if (wakeupNeeded)
{
ProcLockWakeup(&(lock->waitProcs), lockmethod, lock);
}
else
{
if (((LOCKDEBUG(LOCK_LOCKMETHOD(*(lock))) >= 1) \
&& (lock->tag.relId >= lockDebugOidMin)) \
|| \
&&(lock->tag.relId >= lockDebugOidMin)) \
||\
(lockDebugRelation && (lock->tag.relId == lockDebugRelation)))
TPRINTF(TRACE_ALL, "LockRelease: no wakeup needed");
}
@@ -1309,7 +1309,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
for (;;)
{
bool wakeupNeeded = false;
bool wakeupNeeded = false;
/*
* Sometimes the queue appears to be messed up.
@@ -1377,7 +1377,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
goto next_item;
}
TPRINTF(TRACE_USERLOCKS,
"LockReleaseAll: releasing user lock [%u] [%d,%d,%d]",
"LockReleaseAll: releasing user lock [%u] [%d,%d,%d]",
lock->tag.objId.blkno,
xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
}
@@ -1391,7 +1391,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
if (xidLook->tag.pid != 0)
{
TPRINTF(TRACE_LOCKS,
"LockReleaseAll: skiping user lock [%u] [%d,%d,%d]",
"LockReleaseAll: skiping user lock [%u] [%d,%d,%d]",
lock->tag.objId.blkno,
xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
nleft++;
@@ -1415,10 +1415,11 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
&&(lock->activeHolders[i] >= 0));
if (!lock->activeHolders[i])
lock->mask &= BITS_OFF[i];
/*
* Read comments in LockRelease
*/
if (!wakeupNeeded && xidLook->holders[i] > 0 &&
if (!wakeupNeeded && xidLook->holders[i] > 0 &&
lockMethodTable->ctl->conflictTab[i] & lock->waitMask)
wakeupNeeded = true;
}
@@ -1521,7 +1522,7 @@ LockShmemSize(int maxBackends)
int size = 0;
size += MAXALIGN(sizeof(PROC_HDR)); /* ProcGlobal */
size += MAXALIGN(maxBackends * sizeof(PROC)); /* each MyProc */
size += MAXALIGN(maxBackends * sizeof(PROC)); /* each MyProc */
size += MAXALIGN(maxBackends * sizeof(LOCKMETHODCTL)); /* each
* lockMethodTable->ctl */
@@ -1535,8 +1536,9 @@ LockShmemSize(int maxBackends)
SHMEM_XIDTAB_KEYSIZE,
SHMEM_XIDTAB_DATASIZE);
/* Since the lockHash entry count above is only an estimate,
* add 10% safety margin.
/*
* Since the lockHash entry count above is only an estimate, add 10%
* safety margin.
*/
size += size / 10;
@@ -1569,21 +1571,21 @@ LockingDisabled()
bool
DeadLockCheck(void *proc, LOCK *findlock)
{
XIDLookupEnt *xidLook = NULL;
XIDLookupEnt *tmp = NULL;
PROC *thisProc = (PROC*) proc,
*waitProc;
SHM_QUEUE *lockQueue = &(thisProc->lockQueue);
SHMEM_OFFSET end = MAKE_OFFSET(lockQueue);
LOCK *lock;
PROC_QUEUE *waitQueue;
int i,
j;
bool first_run = (thisProc == MyProc),
done;
XIDLookupEnt *xidLook = NULL;
XIDLookupEnt *tmp = NULL;
PROC *thisProc = (PROC *) proc,
*waitProc;
SHM_QUEUE *lockQueue = &(thisProc->lockQueue);
SHMEM_OFFSET end = MAKE_OFFSET(lockQueue);
LOCK *lock;
PROC_QUEUE *waitQueue;
int i,
j;
bool first_run = (thisProc == MyProc),
done;
static PROC *checked_procs[MAXBACKENDS];
static int nprocs;
static PROC *checked_procs[MAXBACKENDS];
static int nprocs;
/* initialize at start of recursion */
if (first_run)
@@ -1606,39 +1608,38 @@ DeadLockCheck(void *proc, LOCK *findlock)
LOCK_PRINT("DeadLockCheck", lock, 0);
if (lock->tag.relId == 0) /* user' lock */
if (lock->tag.relId == 0) /* user' lock */
goto nxtl;
/*
* waitLock is always in lockQueue of waiting proc,
* if !first_run then upper caller will handle waitProcs
* queue of waitLock.
* waitLock is always in lockQueue of waiting proc, if !first_run
* then upper caller will handle waitProcs queue of waitLock.
*/
if (thisProc->waitLock == lock && !first_run)
goto nxtl;
/*
* If we found proc holding findlock and sleeping on some my
* other lock then we have to check does it block me or
* another waiters.
* If we found proc holding findlock and sleeping on some my other
* lock then we have to check does it block me or another waiters.
*/
if (lock == findlock && !first_run)
{
LOCKMETHODCTL *lockctl =
LockMethodTable[DEFAULT_LOCKMETHOD]->ctl;
int lm;
LOCKMETHODCTL *lockctl =
LockMethodTable[DEFAULT_LOCKMETHOD]->ctl;
int lm;
Assert(xidLook->nHolding > 0);
for (lm = 1; lm <= lockctl->numLockModes; lm++)
{
if (xidLook->holders[lm] > 0 &&
if (xidLook->holders[lm] > 0 &&
lockctl->conflictTab[lm] & findlock->waitMask)
return true;
}
/*
* Else - get the next lock from thisProc's lockQueue
*/
goto nxtl;
goto nxtl;
}
waitQueue = &(lock->waitProcs);
@@ -1653,10 +1654,10 @@ DeadLockCheck(void *proc, LOCK *findlock)
waitProc = (PROC *) MAKE_PTR(waitProc->links.prev);
continue;
}
if (lock == findlock) /* first_run also true */
if (lock == findlock) /* first_run also true */
{
LOCKMETHODCTL *lockctl =
LockMethodTable[DEFAULT_LOCKMETHOD]->ctl;
LOCKMETHODCTL *lockctl =
LockMethodTable[DEFAULT_LOCKMETHOD]->ctl;
/*
* If me blocked by his holdlock...
@@ -1670,17 +1671,19 @@ DeadLockCheck(void *proc, LOCK *findlock)
waitProc = (PROC *) MAKE_PTR(waitProc->links.prev);
continue;
}
/*
* If he isn't blocked by me and we request non-conflicting
* lock modes - no deadlock here because of he isn't
* blocked by me in any sence (explicitle or implicitly).
* Note that we don't do like test if !first_run
* (when thisProc is holder and non-waiter on lock) and so
* we call DeadLockCheck below for every waitProc in
* thisProc->lockQueue, even for waitProc-s un-blocked
* by thisProc. Should we? This could save us some time...
* If he isn't blocked by me and we request
* non-conflicting lock modes - no deadlock here because
* of he isn't blocked by me in any sence (explicitle or
* implicitly). Note that we don't do like test if
* !first_run (when thisProc is holder and non-waiter on
* lock) and so we call DeadLockCheck below for every
* waitProc in thisProc->lockQueue, even for waitProc-s
* un-blocked by thisProc. Should we? This could save us
* some time...
*/
if (!(lockctl->conflictTab[waitProc->token] & MyProc->holdLock) &&
if (!(lockctl->conflictTab[waitProc->token] & MyProc->holdLock) &&
!(lockctl->conflictTab[waitProc->token] & (1 << MyProc->token)))
{
waitProc = (PROC *) MAKE_PTR(waitProc->links.prev);
@@ -1689,7 +1692,8 @@ DeadLockCheck(void *proc, LOCK *findlock)
}
/*
* Look in lockQueue of this waitProc, if didn't do this before.
* Look in lockQueue of this waitProc, if didn't do this
* before.
*/
for (j = 0; j < nprocs; j++)
{
@@ -1703,9 +1707,9 @@ DeadLockCheck(void *proc, LOCK *findlock)
if (DeadLockCheck(waitProc, findlock))
{
LOCKMETHODCTL *lockctl =
LockMethodTable[DEFAULT_LOCKMETHOD]->ctl;
int holdLock;
LOCKMETHODCTL *lockctl =
LockMethodTable[DEFAULT_LOCKMETHOD]->ctl;
int holdLock;
/*
* Ok, but is waitProc waiting for me (thisProc) ?
@@ -1715,14 +1719,16 @@ DeadLockCheck(void *proc, LOCK *findlock)
Assert(first_run);
holdLock = thisProc->holdLock;
}
else /* should we cache holdLock ? */
else
/* should we cache holdLock ? */
{
int lm, tmpMask = 2;
int lm,
tmpMask = 2;
Assert(xidLook->nHolding > 0);
for (holdLock = 0, lm = 1;
lm <= lockctl->numLockModes;
lm++, tmpMask <<= 1)
for (holdLock = 0, lm = 1;
lm <= lockctl->numLockModes;
lm++, tmpMask <<= 1)
{
if (xidLook->holders[lm] > 0)
holdLock |= tmpMask;
@@ -1731,6 +1737,7 @@ DeadLockCheck(void *proc, LOCK *findlock)
}
if (lockctl->conflictTab[waitProc->token] & holdLock)
{
/*
* Last attempt to avoid deadlock - try to wakeup
* myself.
@@ -1751,6 +1758,7 @@ DeadLockCheck(void *proc, LOCK *findlock)
}
return true;
}
/*
* Hell! Is he blocked by any (other) holder ?
*/
@@ -1760,21 +1768,24 @@ DeadLockCheck(void *proc, LOCK *findlock)
waitProc->xid,
NULL) != STATUS_OK)
{
/*
* Blocked by others - no deadlock...
*/
#ifdef DEADLOCK_DEBUG
LOCK_PRINT("DeadLockCheck: blocked by others",
lock, waitProc->token);
LOCK_PRINT("DeadLockCheck: blocked by others",
lock, waitProc->token);
#endif
waitProc = (PROC *) MAKE_PTR(waitProc->links.prev);
continue;
}
/*
* Well - wakeup this guy! This is the case of
* implicit blocking: thisProc blocked someone who blocked
* waitProc by the fact that he (someone) is already
* waiting for lock (we do this for anti-starving).
* implicit blocking: thisProc blocked someone who
* blocked waitProc by the fact that he/someone is
* already waiting for lock. We do this for
* anti-starving.
*/
GrantLock(lock, waitProc->token);
waitQueue->size--;
@@ -1785,7 +1796,7 @@ DeadLockCheck(void *proc, LOCK *findlock)
waitProc = (PROC *) MAKE_PTR(waitProc->links.prev);
}
nxtl:;
nxtl: ;
if (done)
break;
SHMQueueFirst(&xidLook->queue, (Pointer *) &tmp, &tmp->queue);
@@ -1832,7 +1843,7 @@ LockOwners(LOCKMETHOD lockmethod, LOCKTAG *locktag)
if (is_user_lock)
{
TPRINTF(TRACE_USERLOCKS, "LockOwners: user lock tag [%u]",
locktag->objId.blkno;,
locktag->objId.blkno;
}
#endif
@@ -1981,6 +1992,7 @@ LockOwners(LOCKMETHOD lockmethod, LOCKTAG *locktag)
return array;
}
#endif
#ifdef DEADLOCK_DEBUG

View File

@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.28 1999/03/28 20:32:25 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.29 1999/05/25 16:11:22 momjian Exp $
*
* NOTES:
* (1) The lock.c module assumes that the caller here is doing
@@ -170,6 +170,7 @@ MultiLockTuple(LockInfo lockinfo, ItemPointer tidPtr, LOCKMODE lockmode)
tag.tupleId = *tidPtr;
return MultiAcquire(MultiTableId, &tag, lockmode, TUPLE_LEVEL);
}
#endif
/*

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.55 1999/05/13 15:55:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.56 1999/05/25 16:11:23 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.55 1999/05/13 15:55:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.56 1999/05/25 16:11:23 momjian Exp $
*/
#include <sys/time.h>
#include <unistd.h>
@@ -150,18 +150,20 @@ InitProcGlobal(IPCKey key, int maxBackends)
for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++)
ProcGlobal->freeSemMap[i] = 0;
/* Arrange to delete semas on exit --- set this up now so that
* we will clean up if pre-allocation fails...
/*
* Arrange to delete semas on exit --- set this up now so that we
* will clean up if pre-allocation fails...
*/
on_shmem_exit(ProcFreeAllSemaphores, NULL);
/* Pre-create the semaphores for the first maxBackends processes,
/*
* Pre-create the semaphores for the first maxBackends processes,
* unless we are running as a standalone backend.
*/
if (key != PrivateIPCKey)
{
for (i = 0;
i < (maxBackends+PROC_NSEMS_PER_SET-1) / PROC_NSEMS_PER_SET;
i < (maxBackends + PROC_NSEMS_PER_SET - 1) / PROC_NSEMS_PER_SET;
i++)
{
IPCKey semKey = ProcGlobal->currKey + i;
@@ -266,10 +268,11 @@ InitProcess(IPCKey key)
ProcGetNewSemKeyAndNum(&semKey, &semNum);
/* Note: because of the pre-allocation done in InitProcGlobal,
* this call should always attach to an existing semaphore.
* It will (try to) create a new group of semaphores only if
* the postmaster tries to start more backends than it said it would.
/*
* Note: because of the pre-allocation done in InitProcGlobal,
* this call should always attach to an existing semaphore. It
* will (try to) create a new group of semaphores only if the
* postmaster tries to start more backends than it said it would.
*/
semId = IpcSemaphoreCreate(semKey,
PROC_NSEMS_PER_SET,
@@ -489,7 +492,7 @@ ProcQueueInit(PROC_QUEUE *queue)
*/
int
ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */
LOCKMETHODCTL *lockctl,
LOCKMETHODCTL * lockctl,
int token, /* lockmode */
LOCK *lock)
{
@@ -534,23 +537,22 @@ ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */
}
/* if he waits for me */
else if (lockctl->conflictTab[proc->token] & MyProc->holdLock)
{
break;
}
/* if conflicting locks requested */
else if (lockctl->conflictTab[proc->token] & myMask)
{
/*
* If I request non self-conflicting lock and there
* are others requesting the same lock just before me -
* stay here.
* If I request non self-conflicting lock and there are others
* requesting the same lock just before me - stay here.
*/
if (!selfConflict && prevSame)
break;
}
/*
* Last attempt to don't move any more: if we don't conflict
* with rest waiters in queue.
* Last attempt to don't move any more: if we don't conflict with
* rest waiters in queue.
*/
else if (!(lockctl->conflictTab[token] & waitMask))
break;
@@ -558,7 +560,7 @@ ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */
prevSame = (proc->token == token);
(aheadHolders[proc->token])++;
if (aheadHolders[proc->token] == lock->holders[proc->token])
waitMask &= ~ (1 << proc->token);
waitMask &= ~(1 << proc->token);
proc = (PROC *) MAKE_PTR(proc->links.prev);
}
@@ -885,7 +887,7 @@ ProcGetNewSemKeyAndNum(IPCKey *key, int *semNum)
{
int i;
int32 *freeSemMap = ProcGlobal->freeSemMap;
int32 fullmask = (1 << (PROC_NSEMS_PER_SET+1)) - 1;
int32 fullmask = (1 << (PROC_NSEMS_PER_SET + 1)) - 1;
/*
* we hold ProcStructLock when entering this routine. We scan through
@@ -906,8 +908,8 @@ ProcGetNewSemKeyAndNum(IPCKey *key, int *semNum)
{
/*
* a free semaphore found. Mark it as allocated.
* Also set the bit indicating whole set is allocated.
* a free semaphore found. Mark it as allocated. Also set
* the bit indicating whole set is allocated.
*/
freeSemMap[i] |= mask + (1 << PROC_NSEMS_PER_SET);
@@ -938,9 +940,10 @@ ProcFreeSem(IpcSemaphoreKey semKey, int semNum)
mask = ~(1 << semNum);
freeSemMap[i] &= mask;
/* Formerly we'd release a semaphore set if it was now completely unused,
* but now we keep the semaphores to ensure we won't run out when
* starting new backends --- cf. InitProcGlobal. Note that the
/*
* Formerly we'd release a semaphore set if it was now completely
* unused, but now we keep the semaphores to ensure we won't run out
* when starting new backends --- cf. InitProcGlobal. Note that the
* PROC_NSEMS_PER_SET+1'st bit of the freeSemMap entry remains set to
* indicate it is still allocated; ProcFreeAllSemaphores() needs that.
*/

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.21 1999/02/13 23:18:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.22 1999/05/25 16:11:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,7 +35,7 @@ static bool PageManagerShuffle = true; /* default is shuffle mode */
*/
/*
* PageInit
* PageInit
* Initializes the contents of a page.
*/
void
@@ -56,7 +56,7 @@ PageInit(Page page, Size pageSize, Size specialSize)
}
/*
* PageAddItem
* PageAddItem
* Adds item to the given page.
*
* Note:
@@ -174,7 +174,7 @@ PageAddItem(Page page,
}
/*
* PageGetTempPage
* PageGetTempPage
* Get a temporary page in local memory for special processing
*/
Page
@@ -207,7 +207,7 @@ PageGetTempPage(Page page, Size specialSize)
}
/*
* PageRestoreTempPage
* PageRestoreTempPage
* Copy temporary page back to permanent page after special processing
* and release the temporary page.
*/
@@ -246,7 +246,7 @@ itemidcompare(const void *itemidp1, const void *itemidp2)
}
/*
* PageRepairFragmentation
* PageRepairFragmentation
* Frees fragmented space on a page.
*/
void
@@ -327,7 +327,7 @@ PageRepairFragmentation(Page page)
}
/*
* PageGetFreeSpace
* PageGetFreeSpace
* Returns the size of the free (allocatable) space on a page.
*/
Size
@@ -346,7 +346,7 @@ PageGetFreeSpace(Page page)
}
/*
* PageManagerModeSet
* PageManagerModeSet
*
* Sets mode to either: ShufflePageManagerMode (the default) or
* OverwritePageManagerMode. For use by access methods code

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/page/itemptr.c,v 1.5 1999/02/13 23:18:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/page/itemptr.c,v 1.6 1999/05/25 16:11:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,7 +19,7 @@
#include "storage/bufpage.h"
/*
* ItemPointerEquals
* ItemPointerEquals
* Returns true if both item pointers point to the same item,
* otherwise returns false.
*

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.43 1999/05/17 06:38:41 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.44 1999/05/25 16:11:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -712,9 +712,9 @@ mdtruncate(Relation reln, int nblocks)
#ifndef LET_OS_MANAGE_FILESIZE
int curnblk,
i,
oldsegno,
newsegno;
i,
oldsegno,
newsegno;
char fname[NAMEDATALEN];
char tname[NAMEDATALEN + 10];
@@ -724,13 +724,15 @@ mdtruncate(Relation reln, int nblocks)
StrNCpy(fname, RelationGetRelationName(reln)->data, NAMEDATALEN);
if (newsegno < oldsegno) {
for (i = (newsegno + 1);; i++) {
if (newsegno < oldsegno)
{
for (i = (newsegno + 1);; i++)
{
sprintf(tname, "%s.%d", fname, i);
if (FileNameUnlink(tname) < 0)
break;
}
}
}
#endif
fd = RelationGetFile(reln);

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.15 1999/03/06 21:17:50 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.16 1999/05/25 16:11:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -569,15 +569,15 @@ MMShmemSize()
* first compute space occupied by the (dbid,relid,blkno) hash table
*/
size += hash_estimate_size(MMNBUFFERS,
0, /* MMHashEntry includes key */
sizeof(MMHashEntry));
0, /* MMHashEntry includes key */
sizeof(MMHashEntry));
/*
* now do the same for the rel hash table
*/
size += hash_estimate_size(MMNRELATIONS,
0, /* MMRelHashEntry includes key */
sizeof(MMRelHashEntry));
0, /* MMRelHashEntry includes key */
sizeof(MMRelHashEntry));
/*
* finally, add in the memory block we use directly

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.23 1999/04/23 19:37:42 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.24 1999/05/25 16:11:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -79,6 +79,7 @@ static bool smgrwo[] = {
false, /* main memory */
#endif
};
#endif
static int NSmgr = lengthof(smgrsw);
@@ -408,4 +409,5 @@ smgriswo(int16 smgrno)
return smgrwo[smgrno];
}
#endif