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

pgindent run.

This commit is contained in:
Bruce Momjian
2002-09-04 20:31:48 +00:00
parent c91ceec21d
commit e50f52a074
446 changed files with 14942 additions and 13363 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.51 2002/09/02 02:47:03 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.52 2002/09/04 20:31:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -231,6 +231,7 @@ InitBufferPoolAccess(void)
BufferBlockPointers = (Block *) calloc(NBuffers, sizeof(Block));
PrivateRefCount = (long *) calloc(NBuffers, sizeof(long));
BufferLocks = (bits8 *) calloc(NBuffers, sizeof(bits8));
/*
* Convert shmem offsets into addresses as seen by this process. This
* is just to speed up the BufferGetBlock() macro.

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.131 2002/09/02 02:47:03 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.132 2002/09/04 20:31:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -75,6 +75,7 @@ static Buffer ReadBufferInternal(Relation reln, BlockNumber blockNum,
static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum,
bool *foundPtr);
static int BufferReplace(BufferDesc *bufHdr);
#ifdef NOT_USED
void PrintBufferDescs(void);
#endif
@@ -552,7 +553,7 @@ BufferAlloc(Relation reln,
/*
* write_buffer -- common functionality for
* WriteBuffer and WriteNoReleaseBuffer
* WriteBuffer and WriteNoReleaseBuffer
*/
static void
write_buffer(Buffer buffer, bool release)
@@ -870,14 +871,14 @@ ShowBufferUsage(void)
localhitrate = (float) LocalBufferHitCount *100.0 / ReadLocalBufferCount;
appendStringInfo(&str,
"!\tShared blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n",
"!\tShared blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n",
ReadBufferCount - BufferHitCount, BufferFlushCount, hitrate);
appendStringInfo(&str,
"!\tLocal blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n",
ReadLocalBufferCount - LocalBufferHitCount, LocalBufferFlushCount, localhitrate);
"!\tLocal blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n",
ReadLocalBufferCount - LocalBufferHitCount, LocalBufferFlushCount, localhitrate);
appendStringInfo(&str,
"!\tDirect blocks: %10ld read, %10ld written\n",
NDirectFileRead, NDirectFileWrite);
"!\tDirect blocks: %10ld read, %10ld written\n",
NDirectFileRead, NDirectFileWrite);
return str.data;
}
@@ -917,7 +918,7 @@ AtEOXact_Buffers(bool isCommit)
if (isCommit)
elog(WARNING,
"Buffer Leak: [%03d] (freeNext=%d, freePrev=%d, "
"rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)",
"rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)",
i, buf->freeNext, buf->freePrev,
buf->tag.rnode.tblNode, buf->tag.rnode.relNode,
buf->tag.blockNum, buf->flags,

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.45 2002/08/06 02:36:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.46 2002/09/04 20:31:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -83,8 +83,8 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
elog(ERROR, "no empty local buffer.");
/*
* this buffer is not referenced but it might still be dirty.
* if that's the case, write it out before reusing it!
* this buffer is not referenced but it might still be dirty. if
* that's the case, write it out before reusing it!
*/
if (bufHdr->flags & BM_DIRTY || bufHdr->cntxDirty)
{
@@ -108,9 +108,9 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
/*
* lazy memory allocation: allocate space on first use of a buffer.
*
* Note this path cannot be taken for a buffer that was previously
* in use, so it's okay to do it (and possibly error out) before
* marking the buffer as valid.
* Note this path cannot be taken for a buffer that was previously in
* use, so it's okay to do it (and possibly error out) before marking
* the buffer as valid.
*/
if (bufHdr->data == (SHMEM_OFFSET) 0)
{

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.12 2002/06/20 20:29:34 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.13 2002/09/04 20:31:25 momjian Exp $
*
*
* NOTES:
@@ -850,7 +850,7 @@ insert_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail,
FSMChunk *newChunk;
if ((newChunk = FreeSpaceMap->freeChunks) == NULL)
return false; /* can't do it */
return false; /* can't do it */
FreeSpaceMap->freeChunks = newChunk->next;
FreeSpaceMap->numFreeChunks--;
newChunk->next = NULL;
@@ -874,21 +874,25 @@ insert_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail,
}
}
/* Try to insert it the easy way, ie, just move down subsequent data */
/*
* Try to insert it the easy way, ie, just move down subsequent
* data
*/
if (chunk &&
push_fsm_page_entry(page, spaceAvail, chunk, chunkRelIndex))
{
fsmrel->numPages++;
fsmrel->nextPage++; /* don't return same page twice running */
fsmrel->nextPage++; /* don't return same page twice running */
return true;
}
/*
* There is space available, but evidently it's before the place where
* the page entry needs to go. Compact the list and try again. This
* will require us to redo the search for the appropriate place.
* Furthermore, compact_fsm_page_list deletes empty end chunks, so
* we may need to repeat the action of grabbing a new end chunk.
* There is space available, but evidently it's before the place
* where the page entry needs to go. Compact the list and try
* again. This will require us to redo the search for the
* appropriate place. Furthermore, compact_fsm_page_list deletes
* empty end chunks, so we may need to repeat the action of
* grabbing a new end chunk.
*/
compact_fsm_page_list(fsmrel);
if (lookup_fsm_page_entry(fsmrel, page, &chunk, &chunkRelIndex))

View File

@@ -4,7 +4,7 @@
* POSTGRES inter-process communication definitions.
*
* This file is misnamed, as it no longer has much of anything directly
* to do with IPC. The functionality here is concerned with managing
* to do with IPC. The functionality here is concerned with managing
* exit-time cleanup for either a postmaster or a backend.
*
*
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.80 2002/06/20 20:29:34 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.81 2002/09/04 20:31:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.66 2002/06/20 20:29:35 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.67 2002/09/04 20:31:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -133,6 +133,7 @@ ShmemAlloc(Size size)
{
uint32 newFree;
void *newSpace;
/* use volatile pointer to prevent code rearrangement */
volatile PGShmemHeader *shmemseghdr = ShmemSegHdr;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.51 2002/09/02 02:47:03 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.52 2002/09/04 20:31:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -96,7 +96,8 @@ ReceiveSharedInvalidMessages(
* The routines later in this file that use shared mode are okay with
* this, because they aren't looking at the ProcState fields
* associated with SI message transfer; they only use the
* ProcState array as an easy way to find all the PGPROC structures.
* ProcState array as an easy way to find all the PGPROC
* structures.
*/
LWLockAcquire(SInvalLock, LW_SHARED);
getResult = SIGetDataEntry(shmInvalBuffer, MyBackendId, &data);
@@ -380,9 +381,9 @@ GetSnapshotData(bool serializable)
* running a transaction, and xacts started since we read the
* next transaction ID. There's no need to store XIDs above
* what we got from ReadNewTransactionId, since we'll treat
* them as running anyway. We also assume that such xacts can't
* compute an xmin older than ours, so they needn't be considered
* in computing globalxmin.
* them as running anyway. We also assume that such xacts
* can't compute an xmin older than ours, so they needn't be
* considered in computing globalxmin.
*/
if (proc == MyProc ||
!TransactionIdIsNormal(xid) ||
@@ -411,9 +412,9 @@ GetSnapshotData(bool serializable)
Assert(TransactionIdIsValid(MyProc->xmin));
/*
* Update globalxmin to include actual process xids. This is a slightly
* different way of computing it than GetOldestXmin uses, but should give
* the same result.
* Update globalxmin to include actual process xids. This is a
* slightly different way of computing it than GetOldestXmin uses, but
* should give the same result.
*/
if (TransactionIdPrecedes(xmin, globalxmin))
globalxmin = xmin;
@@ -551,7 +552,7 @@ BackendIdGetProc(BackendId procId)
int
CountEmptyBackendSlots(void)
{
int count;
int count;
LWLockAcquire(SInvalLock, LW_SHARED);

View File

@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.12 2002/07/19 00:17:40 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.13 2002/09/04 20:31:25 momjian Exp $
*
* Interface:
*
@@ -66,7 +66,7 @@ static void PrintLockQueue(LOCK *lock, const char *info);
*/
/* Workspace for FindLockCycle */
static PGPROC **visitedProcs; /* Array of visited procs */
static PGPROC **visitedProcs; /* Array of visited procs */
static int nVisitedProcs;
/* Workspace for TopoSort */
@@ -77,7 +77,7 @@ static int *afterConstraints; /* List head for after-constraints */
/* Output area for ExpandConstraints */
static WAIT_ORDER *waitOrders; /* Array of proposed queue rearrangements */
static int nWaitOrders;
static PGPROC **waitOrderProcs; /* Space for waitOrders queue contents */
static PGPROC **waitOrderProcs; /* Space for waitOrders queue contents */
/* Current list of constraints being considered */
static EDGE *curConstraints;
@@ -377,7 +377,7 @@ FindLockCycleRecurse(PGPROC *checkProc,
{
PGPROC *proc;
LOCK *lock;
PROCLOCK *holder;
PROCLOCK *holder;
SHM_QUEUE *lockHolders;
LOCKMETHODTABLE *lockMethodTable;
PROC_QUEUE *waitQueue;
@@ -428,7 +428,7 @@ FindLockCycleRecurse(PGPROC *checkProc,
lockHolders = &(lock->lockHolders);
holder = (PROCLOCK *) SHMQueueNext(lockHolders, lockHolders,
offsetof(PROCLOCK, lockLink));
offsetof(PROCLOCK, lockLink));
while (holder)
{
@@ -452,7 +452,7 @@ FindLockCycleRecurse(PGPROC *checkProc,
}
holder = (PROCLOCK *) SHMQueueNext(lockHolders, &holder->lockLink,
offsetof(PROCLOCK, lockLink));
offsetof(PROCLOCK, lockLink));
}
/*

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.114 2002/09/02 02:47:03 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.115 2002/09/04 20:31:25 momjian Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
@@ -127,9 +127,9 @@ inline static void
PROCLOCK_PRINT(const char *where, const PROCLOCK *holderP)
{
if (
(((PROCLOCK_LOCKMETHOD(*holderP) == DEFAULT_LOCKMETHOD && Trace_locks)
|| (PROCLOCK_LOCKMETHOD(*holderP) == USER_LOCKMETHOD && Trace_userlocks))
&& (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId >= (Oid) Trace_lock_oidmin))
(((PROCLOCK_LOCKMETHOD(*holderP) == DEFAULT_LOCKMETHOD && Trace_locks)
|| (PROCLOCK_LOCKMETHOD(*holderP) == USER_LOCKMETHOD && Trace_userlocks))
&& (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId >= (Oid) Trace_lock_oidmin))
|| (Trace_lock_table && (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId == Trace_lock_table))
)
elog(LOG,
@@ -310,7 +310,7 @@ LockMethodTableInit(char *tabName,
Assert(lockMethodTable->lockHash->hash == tag_hash);
/*
* allocate a hash table for PROCLOCK structs. This is used to store
* allocate a hash table for PROCLOCK structs. This is used to store
* per-lock-holder information.
*/
info.keysize = sizeof(PROCLOCKTAG);
@@ -434,8 +434,8 @@ bool
LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
TransactionId xid, LOCKMODE lockmode, bool dontWait)
{
PROCLOCK *holder;
PROCLOCKTAG holdertag;
PROCLOCK *holder;
PROCLOCKTAG holdertag;
HTAB *holderTable;
bool found;
LOCK *lock;
@@ -507,7 +507,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
/*
* Create the hash key for the holder table.
*/
MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding,
MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding,
* needed */
holdertag.lock = MAKE_OFFSET(lock);
holdertag.proc = MAKE_OFFSET(MyProc);
@@ -518,8 +518,8 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
*/
holderTable = lockMethodTable->holderHash;
holder = (PROCLOCK *) hash_search(holderTable,
(void *) &holdertag,
HASH_ENTER, &found);
(void *) &holdertag,
HASH_ENTER, &found);
if (!holder)
{
LWLockRelease(masterLock);
@@ -645,8 +645,8 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
SHMQueueDelete(&holder->lockLink);
SHMQueueDelete(&holder->procLink);
holder = (PROCLOCK *) hash_search(holderTable,
(void *) holder,
HASH_REMOVE, NULL);
(void *) holder,
HASH_REMOVE, NULL);
if (!holder)
elog(WARNING, "LockAcquire: remove holder, table corrupted");
}
@@ -808,13 +808,13 @@ static void
LockCountMyLocks(SHMEM_OFFSET lockOffset, PGPROC *proc, int *myHolding)
{
SHM_QUEUE *procHolders = &(proc->procHolders);
PROCLOCK *holder;
PROCLOCK *holder;
int i;
MemSet(myHolding, 0, MAX_LOCKMODES * sizeof(int));
holder = (PROCLOCK *) SHMQueueNext(procHolders, procHolders,
offsetof(PROCLOCK, procLink));
offsetof(PROCLOCK, procLink));
while (holder)
{
@@ -825,7 +825,7 @@ LockCountMyLocks(SHMEM_OFFSET lockOffset, PGPROC *proc, int *myHolding)
}
holder = (PROCLOCK *) SHMQueueNext(procHolders, &holder->procLink,
offsetof(PROCLOCK, procLink));
offsetof(PROCLOCK, procLink));
}
}
@@ -978,8 +978,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
LOCK *lock;
LWLockId masterLock;
LOCKMETHODTABLE *lockMethodTable;
PROCLOCK *holder;
PROCLOCKTAG holdertag;
PROCLOCK *holder;
PROCLOCKTAG holdertag;
HTAB *holderTable;
bool wakeupNeeded = false;
@@ -1025,7 +1025,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
/*
* Find the holder entry for this holder.
*/
MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding,
MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding,
* needed */
holdertag.lock = MAKE_OFFSET(lock);
holdertag.proc = MAKE_OFFSET(MyProc);
@@ -1033,8 +1033,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
holderTable = lockMethodTable->holderHash;
holder = (PROCLOCK *) hash_search(holderTable,
(void *) &holdertag,
HASH_FIND_SAVE, NULL);
(void *) &holdertag,
HASH_FIND_SAVE, NULL);
if (!holder)
{
LWLockRelease(masterLock);
@@ -1135,8 +1135,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
SHMQueueDelete(&holder->lockLink);
SHMQueueDelete(&holder->procLink);
holder = (PROCLOCK *) hash_search(holderTable,
(void *) &holder,
HASH_REMOVE_SAVED, NULL);
(void *) &holder,
HASH_REMOVE_SAVED, NULL);
if (!holder)
{
LWLockRelease(masterLock);
@@ -1171,8 +1171,8 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
bool allxids, TransactionId xid)
{
SHM_QUEUE *procHolders = &(proc->procHolders);
PROCLOCK *holder;
PROCLOCK *nextHolder;
PROCLOCK *holder;
PROCLOCK *nextHolder;
LWLockId masterLock;
LOCKMETHODTABLE *lockMethodTable;
int i,
@@ -1199,7 +1199,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
LWLockAcquire(masterLock, LW_EXCLUSIVE);
holder = (PROCLOCK *) SHMQueueNext(procHolders, procHolders,
offsetof(PROCLOCK, procLink));
offsetof(PROCLOCK, procLink));
while (holder)
{
@@ -1207,7 +1207,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
/* Get link first, since we may unlink/delete this holder */
nextHolder = (PROCLOCK *) SHMQueueNext(procHolders, &holder->procLink,
offsetof(PROCLOCK, procLink));
offsetof(PROCLOCK, procLink));
Assert(holder->tag.proc == MAKE_OFFSET(proc));
@@ -1249,7 +1249,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
* Read comments in LockRelease
*/
if (!wakeupNeeded &&
lockMethodTable->conflictTab[i] & lock->waitMask)
lockMethodTable->conflictTab[i] & lock->waitMask)
wakeupNeeded = true;
}
}
@@ -1287,9 +1287,9 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
* remove the holder entry from the hashtable
*/
holder = (PROCLOCK *) hash_search(lockMethodTable->holderHash,
(void *) holder,
HASH_REMOVE,
NULL);
(void *) holder,
HASH_REMOVE,
NULL);
if (!holder)
{
LWLockRelease(masterLock);
@@ -1340,8 +1340,7 @@ LockShmemSize(int maxBackends)
size += MAXALIGN(sizeof(PROC_HDR)); /* ProcGlobal */
size += maxBackends * MAXALIGN(sizeof(PGPROC)); /* each MyProc */
size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODTABLE)); /* each
* lockMethodTable */
size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODTABLE)); /* each lockMethodTable */
/* lockHash table */
size += hash_estimate_size(max_table_size, sizeof(LOCK));
@@ -1375,11 +1374,11 @@ LockShmemSize(int maxBackends)
LockData *
GetLockStatusData(void)
{
LockData *data;
HTAB *holderTable;
PROCLOCK *holder;
LockData *data;
HTAB *holderTable;
PROCLOCK *holder;
HASH_SEQ_STATUS seqstat;
int i;
int i;
data = (LockData *) palloc(sizeof(LockData));
@@ -1400,10 +1399,10 @@ GetLockStatusData(void)
hash_seq_init(&seqstat, holderTable);
i = 0;
while ( (holder = hash_seq_search(&seqstat)) )
while ((holder = hash_seq_search(&seqstat)))
{
PGPROC *proc = (PGPROC *) MAKE_PTR(holder->tag.proc);
LOCK *lock = (LOCK *) MAKE_PTR(holder->tag.lock);
PGPROC *proc = (PGPROC *) MAKE_PTR(holder->tag.proc);
LOCK *lock = (LOCK *) MAKE_PTR(holder->tag.lock);
data->holderaddrs[i] = MAKE_OFFSET(holder);
memcpy(&(data->holders[i]), holder, sizeof(PROCLOCK));
@@ -1439,7 +1438,7 @@ DumpLocks(void)
{
PGPROC *proc;
SHM_QUEUE *procHolders;
PROCLOCK *holder;
PROCLOCK *holder;
LOCK *lock;
int lockmethod = DEFAULT_LOCKMETHOD;
LOCKMETHODTABLE *lockMethodTable;
@@ -1459,7 +1458,7 @@ DumpLocks(void)
LOCK_PRINT("DumpLocks: waiting on", proc->waitLock, 0);
holder = (PROCLOCK *) SHMQueueNext(procHolders, procHolders,
offsetof(PROCLOCK, procLink));
offsetof(PROCLOCK, procLink));
while (holder)
{
@@ -1471,7 +1470,7 @@ DumpLocks(void)
LOCK_PRINT("DumpLocks", lock, 0);
holder = (PROCLOCK *) SHMQueueNext(procHolders, &holder->procLink,
offsetof(PROCLOCK, procLink));
offsetof(PROCLOCK, procLink));
}
}
@@ -1482,7 +1481,7 @@ void
DumpAllLocks(void)
{
PGPROC *proc;
PROCLOCK *holder;
PROCLOCK *holder;
LOCK *lock;
int lockmethod = DEFAULT_LOCKMETHOD;
LOCKMETHODTABLE *lockMethodTable;

View File

@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.12 2002/06/20 20:29:35 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.13 2002/09/04 20:31:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -211,21 +211,21 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
HOLD_INTERRUPTS();
/*
* Loop here to try to acquire lock after each time we are signaled
* by LWLockRelease.
* Loop here to try to acquire lock after each time we are signaled by
* LWLockRelease.
*
* NOTE: it might seem better to have LWLockRelease actually grant us
* the lock, rather than retrying and possibly having to go back to
* sleep. But in practice that is no good because it means a process
* swap for every lock acquisition when two or more processes are
* contending for the same lock. Since LWLocks are normally used to
* protect not-very-long sections of computation, a process needs to
* be able to acquire and release the same lock many times during a
* single CPU time slice, even in the presence of contention. The
* efficiency of being able to do that outweighs the inefficiency of
* sometimes wasting a process dispatch cycle because the lock is not
* free when a released waiter finally gets to run. See pgsql-hackers
* archives for 29-Dec-01.
* NOTE: it might seem better to have LWLockRelease actually grant us the
* lock, rather than retrying and possibly having to go back to sleep.
* But in practice that is no good because it means a process swap for
* every lock acquisition when two or more processes are contending
* for the same lock. Since LWLocks are normally used to protect
* not-very-long sections of computation, a process needs to be able
* to acquire and release the same lock many times during a single CPU
* time slice, even in the presence of contention. The efficiency of
* being able to do that outweighs the inefficiency of sometimes
* wasting a process dispatch cycle because the lock is not free when
* a released waiter finally gets to run. See pgsql-hackers archives
* for 29-Dec-01.
*/
for (;;)
{
@@ -290,12 +290,12 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
*
* Since we share the process wait semaphore with the regular lock
* manager and ProcWaitForSignal, and we may need to acquire an
* LWLock while one of those is pending, it is possible that we get
* awakened for a reason other than being signaled by LWLockRelease.
* If so, loop back and wait again. Once we've gotten the LWLock,
* re-increment the sema by the number of additional signals
* received, so that the lock manager or signal manager will see
* the received signal when it next waits.
* LWLock while one of those is pending, it is possible that we
* get awakened for a reason other than being signaled by
* LWLockRelease. If so, loop back and wait again. Once we've
* gotten the LWLock, re-increment the sema by the number of
* additional signals received, so that the lock manager or signal
* manager will see the received signal when it next waits.
*/
LOG_LWDEBUG("LWLockAcquire", lockid, "waiting");
@@ -455,9 +455,7 @@ LWLockRelease(LWLockId lockid)
{
while (proc->lwWaitLink != NULL &&
!proc->lwWaitLink->lwExclusive)
{
proc = proc->lwWaitLink;
}
}
/* proc is now the last PGPROC to be released */
lock->head = proc->lwWaitLink;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.124 2002/07/19 00:17:40 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.125 2002/09/04 20:31:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -131,11 +131,12 @@ InitProcGlobal(int maxBackends)
ProcGlobal->freeProcs = INVALID_OFFSET;
/*
* Pre-create the PGPROC structures and create a semaphore for each.
* Pre-create the PGPROC structures and create a semaphore for
* each.
*/
for (i = 0; i < maxBackends; i++)
{
PGPROC *proc;
PGPROC *proc;
proc = (PGPROC *) ShmemAlloc(sizeof(PGPROC));
if (!proc)
@@ -147,8 +148,9 @@ InitProcGlobal(int maxBackends)
}
/*
* Pre-allocate a PGPROC structure for dummy (checkpoint) processes,
* too. This does not get linked into the freeProcs list.
* Pre-allocate a PGPROC structure for dummy (checkpoint)
* processes, too. This does not get linked into the freeProcs
* list.
*/
DummyProc = (PGPROC *) ShmemAlloc(sizeof(PGPROC));
if (!DummyProc)
@@ -170,6 +172,7 @@ void
InitProcess(void)
{
SHMEM_OFFSET myOffset;
/* use volatile pointer to prevent code rearrangement */
volatile PROC_HDR *procglobal = ProcGlobal;
@@ -184,8 +187,8 @@ InitProcess(void)
elog(ERROR, "InitProcess: you already exist");
/*
* Try to get a proc struct from the free list. If this fails,
* we must be out of PGPROC structures (not to mention semaphores).
* Try to get a proc struct from the free list. If this fails, we
* must be out of PGPROC structures (not to mention semaphores).
*/
SpinLockAcquire(ProcStructLock);
@@ -209,8 +212,8 @@ InitProcess(void)
}
/*
* Initialize all fields of MyProc, except for the semaphore which
* was prepared for us by InitProcGlobal.
* Initialize all fields of MyProc, except for the semaphore which was
* prepared for us by InitProcGlobal.
*/
SHMQueueElemInit(&(MyProc->links));
MyProc->errType = STATUS_OK;
@@ -638,7 +641,7 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable,
/*
* If someone wakes us between LWLockRelease and PGSemaphoreLock,
* PGSemaphoreLock will not block. The wakeup is "saved" by the
* PGSemaphoreLock will not block. The wakeup is "saved" by the
* semaphore implementation. Note also that if CheckDeadLock is
* invoked but does not detect a deadlock, PGSemaphoreLock() will
* continue to wait. There used to be a loop here, but it was useless
@@ -930,12 +933,18 @@ bool
enable_sig_alarm(int delayms, bool is_statement_timeout)
{
#ifndef __BEOS__
struct itimerval timeval, remaining;
struct itimerval timeval,
remaining;
#else
bigtime_t time_interval, remaining;
bigtime_t time_interval,
remaining;
#endif
/* Don't set timer if the statement timeout scheduled before next alarm. */
/*
* Don't set timer if the statement timeout scheduled before next
* alarm.
*/
if (alarm_is_statement_timeout &&
!is_statement_timeout &&
RemainingStatementTimeout <= delayms)
@@ -964,7 +973,7 @@ enable_sig_alarm(int delayms, bool is_statement_timeout)
#ifndef __BEOS__
/* We lose precision here because we convert to milliseconds */
RemainingStatementTimeout = remaining.it_value.tv_sec * 1000 +
remaining.it_value.tv_usec / 1000;
remaining.it_value.tv_usec / 1000;
#else
RemainingStatementTimeout = remaining / 1000;
#endif
@@ -983,7 +992,7 @@ enable_sig_alarm(int delayms, bool is_statement_timeout)
#ifndef __BEOS__
remaining.it_value.tv_sec = RemainingStatementTimeout / 1000;
remaining.it_value.tv_usec = (RemainingStatementTimeout % 1000) * 1000;
if (setitimer(ITIMER_REAL, &remaining, &timeval))
if (setitimer(ITIMER_REAL, &remaining, &timeval))
return false;
else
return true;
@@ -1020,10 +1029,12 @@ bool
disable_sig_alarm(bool is_statement_timeout)
{
#ifndef __BEOS__
struct itimerval timeval, remaining;
struct itimerval timeval,
remaining;
MemSet(&timeval, 0, sizeof(struct itimerval));
#else
bigtime_t time_interval = 0;
bigtime_t time_interval = 0;
#endif
if (!is_statement_timeout && RemainingStatementTimeout)
@@ -1034,7 +1045,7 @@ disable_sig_alarm(bool is_statement_timeout)
return false;
/* Add remaining time back because the timer didn't complete */
RemainingStatementTimeout += remaining.it_value.tv_sec * 1000 +
remaining.it_value.tv_usec / 1000;
remaining.it_value.tv_usec / 1000;
/* Prepare to set timer */
timeval.it_value.tv_sec = RemainingStatementTimeout / 1000;
timeval.it_value.tv_usec = (RemainingStatementTimeout % 1000) * 1000;
@@ -1048,9 +1059,10 @@ disable_sig_alarm(bool is_statement_timeout)
/* Restore remaining statement timeout value */
alarm_is_statement_timeout = true;
}
/*
* Optimization: is_statement_timeout && RemainingStatementTimeout == 0
* does nothing. This is for cases where no timeout was set.
* Optimization: is_statement_timeout && RemainingStatementTimeout ==
* 0 does nothing. This is for cases where no timeout was set.
*/
if (!is_statement_timeout || RemainingStatementTimeout)
{
@@ -1097,4 +1109,3 @@ handle_sig_alarm(SIGNAL_ARGS)
disable_sig_alarm(false);
}
}

View File

@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/spin.c,v 1.9 2002/06/20 20:29:35 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/spin.c,v 1.10 2002/09/04 20:31:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -52,11 +52,11 @@ int
SpinlockSemas(void)
{
/*
* It would be cleaner to distribute this logic into the affected modules,
* similar to the way shmem space estimation is handled.
* It would be cleaner to distribute this logic into the affected
* modules, similar to the way shmem space estimation is handled.
*
* For now, though, we just need a few spinlocks (10 should be
* plenty) plus one for each LWLock.
* For now, though, we just need a few spinlocks (10 should be plenty)
* plus one for each LWLock.
*/
return NumLWLocks() + 10;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.49 2002/09/02 02:47:04 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.50 2002/09/04 20:31:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -117,7 +117,7 @@ PageAddItem(Page page,
else
{
if (offsetNumber < limit)
needshuffle = true; /* need to move existing linp's */
needshuffle = true; /* need to move existing linp's */
}
}
else
@@ -378,8 +378,8 @@ PageGetFreeSpace(Page page)
int space;
/*
* Use signed arithmetic here so that we behave sensibly if
* pd_lower > pd_upper.
* Use signed arithmetic here so that we behave sensibly if pd_lower >
* pd_upper.
*/
space = (int) ((PageHeader) page)->pd_upper -
(int) ((PageHeader) page)->pd_lower;
@@ -440,9 +440,9 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
/*
* First, we want to get rid of the pd_linp entry for the index tuple.
* We copy all subsequent linp's back one slot in the array.
* We don't use PageGetItemId, because we are manipulating the _array_,
* not individual linp's.
* We copy all subsequent linp's back one slot in the array. We don't
* use PageGetItemId, because we are manipulating the _array_, not
* individual linp's.
*/
nbytes = phdr->pd_lower -
((char *) &phdr->pd_linp[offidx + 1] - (char *) phdr);
@@ -480,7 +480,7 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
if (!PageIsEmpty(page))
{
nline--; /* there's one less than when we started */
for (i = nline; --i >= 0; )
for (i = nline; --i >= 0;)
{
if (PageGetItemId(phdr, i + 1)->lp_off <= offset)
PageGetItemId(phdr, i + 1)->lp_off += size;

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.59 2002/08/15 16:36:04 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.60 2002/09/04 20:31:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -66,7 +66,7 @@ static f_smgr smgrsw[] = {
/* main memory */
{mminit, mmshutdown, mmcreate, mmunlink, mmextend, mmopen, mmclose,
mmread, mmwrite, mmblindwrt,
mmnblocks, NULL, mmcommit, mmabort, NULL},
mmnblocks, NULL, mmcommit, mmabort, NULL},
#endif
};