summaryrefslogtreecommitdiff
path: root/src/backend/storage
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage')
-rw-r--r--src/backend/storage/buffer/buf_init.c6
-rw-r--r--src/backend/storage/buffer/bufmgr.c40
-rw-r--r--src/backend/storage/buffer/freelist.c4
-rw-r--r--src/backend/storage/buffer/s_lock.c38
-rw-r--r--src/backend/storage/file/fd.c4
-rw-r--r--src/backend/storage/ipc/ipc.c35
-rw-r--r--src/backend/storage/ipc/shmem.c53
-rw-r--r--src/backend/storage/ipc/shmqueue.c18
-rw-r--r--src/backend/storage/ipc/sinval.c5
-rw-r--r--src/backend/storage/ipc/sinvaladt.c22
-rw-r--r--src/backend/storage/ipc/spin.c12
-rw-r--r--src/backend/storage/large_object/inv_api.c82
-rw-r--r--src/backend/storage/lmgr/lmgr.c37
-rw-r--r--src/backend/storage/lmgr/lock.c318
-rw-r--r--src/backend/storage/lmgr/multi.c45
-rw-r--r--src/backend/storage/lmgr/proc.c30
-rw-r--r--src/backend/storage/page/bufpage.c7
-rw-r--r--src/backend/storage/smgr/md.c6
-rw-r--r--src/backend/storage/smgr/mm.c6
-rw-r--r--src/backend/storage/smgr/smgr.c8
20 files changed, 415 insertions, 361 deletions
diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c
index 64eb13688f8..975e999ec2b 100644
--- a/src/backend/storage/buffer/buf_init.c
+++ b/src/backend/storage/buffer/buf_init.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.18 1998/06/27 15:47:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.19 1998/09/01 04:31:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -48,7 +48,7 @@ bmtrace *TraceBuf;
long *CurTraceBuf;
#define BMT_LIMIT 200
-#endif /* BMTRACE */
+#endif /* BMTRACE */
int ShowPinTrace = 0;
int NBuffers = NDBUFS; /* NDBUFS defined in miscadmin.h */
@@ -278,7 +278,7 @@ BufferShmemSize()
nsegs = 1 << (int) my_log2((nbuckets - 1) / DEF_SEGSIZE + 1);
/* size of shmem index table */
- size += MAXALIGN(my_log2(SHMEM_INDEX_SIZE) * sizeof(void *)); /* HTAB->dir */
+ size += MAXALIGN(my_log2(SHMEM_INDEX_SIZE) * sizeof(void *)); /* HTAB->dir */
size += MAXALIGN(sizeof(HHDR)); /* HTAB->hctl */
size += MAXALIGN(DEF_SEGSIZE * sizeof(SEGMENT));
size += BUCKET_ALLOC_INCR *
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 837b02dbf12..f283887eb01 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.42 1998/09/01 03:25:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.43 1998/09/01 04:31:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -87,13 +87,11 @@ static void WaitIO(BufferDesc *buf, SPINLOCK spinlock);
static void SignalIO(BufferDesc *buf);
extern long *NWaitIOBackendP; /* defined in buf_init.c */
-#endif /* HAS_TEST_AND_SET */
+#endif /* HAS_TEST_AND_SET */
-static Buffer
-ReadBufferWithBufferLock(Relation relation, BlockNumber blockNum,
+static Buffer ReadBufferWithBufferLock(Relation relation, BlockNumber blockNum,
bool bufferLockHeld);
-static BufferDesc *
-BufferAlloc(Relation reln, BlockNumber blockNum,
+static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum,
bool *foundPtr, bool bufferLockHeld);
static int FlushBuffer(Buffer buffer, bool release);
static void BufferSync(void);
@@ -119,8 +117,8 @@ RelationGetBufferWithBuffer(Relation relation,
{
if (!BufferIsLocal(buffer))
{
- LockRelId *lrelId = &(((LockInfo)(relation->lockInfo))->lockRelId);
-
+ LockRelId *lrelId = &(((LockInfo) (relation->lockInfo))->lockRelId);
+
bufHdr = &BufferDescriptors[buffer - 1];
SpinAcquire(BufMgrLock);
if (bufHdr->tag.blockNum == blockNumber &&
@@ -417,7 +415,7 @@ BufferAlloc(Relation reln,
}
#ifdef BMTRACE
_bm_trace((reln->rd_rel->relisshared ? 0 : MyDatabaseId), RelationGetRelid(reln), blockNum, BufferDescriptorGetBuffer(buf), BMT_ALLOCFND);
-#endif /* BMTRACE */
+#endif /* BMTRACE */
SpinRelease(BufMgrLock);
@@ -480,7 +478,7 @@ BufferAlloc(Relation reln,
*/
Assert(S_LOCK_FREE(&(buf->io_in_progress_lock)));
S_LOCK(&(buf->io_in_progress_lock));
-#endif /* HAS_TEST_AND_SET */
+#endif /* HAS_TEST_AND_SET */
/*
* Write the buffer out, being careful to release BufMgrLock
@@ -493,7 +491,7 @@ BufferAlloc(Relation reln,
smok = BufferReplace(buf, true);
#ifndef OPTIMIZE_SINGLE
SpinAcquire(BufMgrLock);
-#endif /* OPTIMIZE_SINGLE */
+#endif /* OPTIMIZE_SINGLE */
if (smok == FALSE)
{
@@ -507,7 +505,7 @@ BufferAlloc(Relation reln,
#else /* !HAS_TEST_AND_SET */
if (buf->refcount > 1)
SignalIO(buf);
-#endif /* !HAS_TEST_AND_SET */
+#endif /* !HAS_TEST_AND_SET */
PrivateRefCount[BufferDescriptorGetBuffer(buf) - 1] = 0;
buf->refcount--;
if (buf->refcount == 0)
@@ -553,7 +551,7 @@ BufferAlloc(Relation reln,
#else /* !HAS_TEST_AND_SET */
if (buf->refcount > 1)
SignalIO(buf);
-#endif /* !HAS_TEST_AND_SET */
+#endif /* !HAS_TEST_AND_SET */
PrivateRefCount[BufferDescriptorGetBuffer(buf) - 1] = 0;
buf->refcount--;
buf = (BufferDesc *) NULL;
@@ -583,7 +581,7 @@ BufferAlloc(Relation reln,
#else /* !HAS_TEST_AND_SET */
if (buf->refcount > 1)
SignalIO(buf);
-#endif /* !HAS_TEST_AND_SET */
+#endif /* !HAS_TEST_AND_SET */
/* give up the buffer since we don't need it any more */
buf->refcount--;
@@ -656,12 +654,12 @@ BufferAlloc(Relation reln,
#ifdef HAS_TEST_AND_SET
Assert(S_LOCK_FREE(&(buf->io_in_progress_lock)));
S_LOCK(&(buf->io_in_progress_lock));
-#endif /* HAS_TEST_AND_SET */
+#endif /* HAS_TEST_AND_SET */
}
#ifdef BMTRACE
_bm_trace((reln->rd_rel->relisshared ? 0 : MyDatabaseId), RelationGetRelid(reln), blockNum, BufferDescriptorGetBuffer(buf), BMT_ALLOCNOTFND);
-#endif /* BMTRACE */
+#endif /* BMTRACE */
SpinRelease(BufMgrLock);
@@ -1018,7 +1016,7 @@ BufferSync()
#ifndef OPTIMIZE_SINGLE
SpinRelease(BufMgrLock);
-#endif /* OPTIMIZE_SINGLE */
+#endif /* OPTIMIZE_SINGLE */
if (reln == (Relation) NULL)
{
status = smgrblindwrt(DEFAULT_SMGR, bufHdr->sb_dbname,
@@ -1034,7 +1032,7 @@ BufferSync()
}
#ifndef OPTIMIZE_SINGLE
SpinAcquire(BufMgrLock);
-#endif /* OPTIMIZE_SINGLE */
+#endif /* OPTIMIZE_SINGLE */
UnpinBuffer(bufHdr);
if (status == SM_FAIL)
@@ -1129,7 +1127,7 @@ SignalIO(BufferDesc *buf)
*NWaitIOBackendP = 0;
}
-#endif /* HAS_TEST_AND_SET */
+#endif /* HAS_TEST_AND_SET */
long NDirectFileRead; /* some I/O's are direct file access.
* bypass bufmgr */
@@ -1575,7 +1573,7 @@ BlowawayRelationBuffers(Relation rel, BlockNumber block)
if (buf->flags & BM_DIRTY)
{
elog(NOTICE, "BlowawayRelationBuffers(%s (local), %u): block %u is dirty",
- rel->rd_rel->relname.data, block, buf->tag.blockNum);
+ rel->rd_rel->relname.data, block, buf->tag.blockNum);
return -1;
}
if (LocalRefCount[i] > 0)
@@ -1888,7 +1886,7 @@ _bm_die(Oid dbId, Oid relId, int blkNo, int bufNo,
kill(getpid(), SIGILL);
}
-#endif /* BMTRACE */
+#endif /* BMTRACE */
void
BufferRefCountReset(int *refcountsave)
diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c
index 421bce86e24..8b853ec7c6d 100644
--- a/src/backend/storage/buffer/freelist.c
+++ b/src/backend/storage/buffer/freelist.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.12 1998/09/01 03:25:03 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.13 1998/09/01 04:31:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -68,7 +68,7 @@ AddBufferToFreelist(BufferDesc *bf)
#ifdef BMTRACE
_bm_trace(bf->tag.relId.dbId, bf->tag.relId.relId, bf->tag.blockNum,
BufferDescriptorGetBuffer(bf), BMT_DEALLOC);
-#endif /* BMTRACE */
+#endif /* BMTRACE */
NotInQueue(bf);
/* change bf so it points to inFrontOfNew and its successor */
diff --git a/src/backend/storage/buffer/s_lock.c b/src/backend/storage/buffer/s_lock.c
index 23bc0ec2c4a..84b9868bc0f 100644
--- a/src/backend/storage/buffer/s_lock.c
+++ b/src/backend/storage/buffer/s_lock.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/s_lock.c,v 1.8 1998/06/16 07:18:15 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/s_lock.c,v 1.9 1998/09/01 04:31:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,12 +27,12 @@
* granularity.
* note: total time to cycle through all 16 entries might be about .07 sec.
*/
-#define S_NSPINCYCLE 20
-#define S_MAX_BUSY 500 * S_NSPINCYCLE
+#define S_NSPINCYCLE 20
+#define S_MAX_BUSY 500 * S_NSPINCYCLE
-int s_spincycle[S_NSPINCYCLE] =
-{ 0, 0, 0, 0, 10000, 0, 0, 0, 10000, 0,
- 0, 10000, 0, 0, 10000, 0, 10000, 0, 10000, 10000
+int s_spincycle[S_NSPINCYCLE] =
+{0, 0, 0, 0, 10000, 0, 0, 0, 10000, 0,
+ 0, 10000, 0, 0, 10000, 0, 10000, 0, 10000, 10000
};
@@ -111,11 +111,12 @@ success: \n\
blr \n\
");
}
-#endif /* PPC */
+#endif /* PPC */
-#else /* defined(__GNUC__) */
+
+#else /* defined(__GNUC__) */
/***************************************************************************
* All non gcc
*/
@@ -124,7 +125,8 @@ success: \n\
#if defined(sun3)
static void
-tas_dummy() /* really means: extern int tas(slock_t *lock); */
+tas_dummy() /* really means: extern int tas(slock_t
+ * *lock); */
{
asm("LLA0:");
asm(" .data");
@@ -143,7 +145,8 @@ tas_dummy() /* really means: extern int tas(slock_t *lock); */
asm(" rts");
asm(" .data");
}
-#endif /* sun3 */
+
+#endif /* sun3 */
@@ -152,11 +155,13 @@ tas_dummy() /* really means: extern int tas(slock_t *lock); */
* sparc machines not using gcc
*/
static void
-tas_dummy() /* really means: extern int tas(slock_t *lock); */
+tas_dummy() /* really means: extern int tas(slock_t
+ * *lock); */
{
asm(".seg \"data\"");
asm(".seg \"text\"");
asm("_tas:");
+
/*
* Sparc atomic test and set (sparc calls it "atomic load-store")
*/
@@ -165,18 +170,18 @@ tas_dummy() /* really means: extern int tas(slock_t *lock); */
asm("nop");
}
-#endif /* NEED_SPARC_TAS_ASM */
+#endif /* NEED_SPARC_TAS_ASM */
#if defined(NEED_I386_TAS_ASM)
/* non gcc i386 based things */
-#endif /* NEED_I386_TAS_ASM */
+#endif /* NEED_I386_TAS_ASM */
-#endif /* not __GNUC__ */
+#endif /* not __GNUC__ */
@@ -188,7 +193,7 @@ tas_dummy() /* really means: extern int tas(slock_t *lock); */
* test program for verifying a port.
*/
-volatile slock_t test_lock;
+volatile slock_t test_lock;
void
main()
@@ -219,5 +224,4 @@ main()
}
-#endif /* S_LOCK_TEST */
-
+#endif /* S_LOCK_TEST */
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 88288c9a5ef..3b0824dad43 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Id: fd.c,v 1.33 1998/09/01 03:25:06 momjian Exp $
+ * $Id: fd.c,v 1.34 1998/09/01 04:31:45 momjian Exp $
*
* NOTES:
*
@@ -220,7 +220,7 @@ _dump_lru()
elog(DEBUG, buf);
}
-#endif /* FDDEBUG */
+#endif /* FDDEBUG */
static void
Delete(File file)
diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c
index 48ccd13fba9..f266789c88f 100644
--- a/src/backend/storage/ipc/ipc.c
+++ b/src/backend/storage/ipc/ipc.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.32 1998/09/01 03:25:08 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.33 1998/09/01 04:31:47 momjian Exp $
*
* NOTES
*
@@ -46,7 +46,7 @@
#include <sys/ipc.h>
#endif
-static int UsePrivateMemory = 0;
+static int UsePrivateMemory = 0;
static void IpcMemoryDetach(int status, char *shmaddr);
@@ -61,9 +61,10 @@ static struct ONEXIT
{
void (*function) ();
caddr_t arg;
-} on_proc_exit_list[MAX_ON_EXITS], on_shmem_exit_list[MAX_ON_EXITS];
+} on_proc_exit_list[MAX_ON_EXITS], on_shmem_exit_list[MAX_ON_EXITS];
-static int on_proc_exit_index, on_shmem_exit_index;
+static int on_proc_exit_index,
+ on_shmem_exit_index;
static void IpcConfigTip(void);
typedef struct _PrivateMemStruct
@@ -116,11 +117,12 @@ proc_exit(int code)
TPRINTF(TRACE_VERBOSE, "proc_exit(%d) [#%d]", code, proc_exit_inprogress);
- /*
- * If proc_exit is called too many times something bad is
- * happenig, so exit immediately.
+ /*
+ * If proc_exit is called too many times something bad is happenig, so
+ * exit immediately.
*/
- if (proc_exit_inprogress > 9) {
+ if (proc_exit_inprogress > 9)
+ {
elog(ERROR, "infinite recursion in proc_exit");
goto exit;
}
@@ -136,7 +138,7 @@ proc_exit(int code)
/* do our shared memory exits first */
shmem_exit(code);
-
+
/* ----------------
* call all the callbacks registered before calling exit().
* ----------------
@@ -166,10 +168,11 @@ shmem_exit(int code)
code, shmem_exit_inprogress);
/*
- * If shmem_exit is called too many times something bad is
- * happenig, so exit immediately.
+ * If shmem_exit is called too many times something bad is happenig,
+ * so exit immediately.
*/
- if (shmem_exit_inprogress > 9) {
+ if (shmem_exit_inprogress > 9)
+ {
elog(ERROR, "infinite recursion in shmem_exit");
exit(-1);
}
@@ -202,7 +205,7 @@ shmem_exit(int code)
* ----------------------------------------------------------------
*/
int
-on_proc_exit(void (*function) (), caddr_t arg)
+ on_proc_exit(void (*function) (), caddr_t arg)
{
if (on_proc_exit_index >= MAX_ON_EXITS)
return -1;
@@ -223,7 +226,7 @@ on_proc_exit(void (*function) (), caddr_t arg)
* ----------------------------------------------------------------
*/
int
-on_shmem_exit(void (*function) (), caddr_t arg)
+ on_shmem_exit(void (*function) (), caddr_t arg)
{
if (on_shmem_exit_index >= MAX_ON_EXITS)
return -1;
@@ -402,7 +405,7 @@ IpcSemaphoreSet(int semId, int semno, int value)
if (errStatus == -1)
{
- EPRINTF("IpcSemaphoreSet: semctl failed (%s) id=%d",
+ EPRINTF("IpcSemaphoreSet: semctl failed (%s) id=%d",
strerror(errno), semId);
}
}
@@ -734,7 +737,7 @@ LockIsFree(int lockid)
#endif
-#endif /* HAS_TEST_AND_SET */
+#endif /* HAS_TEST_AND_SET */
static void
IpcConfigTip(void)
diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
index f8f45aa4364..18b8d718d67 100644
--- a/src/backend/storage/ipc/shmem.c
+++ b/src/backend/storage/ipc/shmem.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.30 1998/09/01 03:25:11 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.31 1998/09/01 04:31:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -76,7 +76,7 @@ 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) */
-extern VariableCache ShmemVariableCache; /* varsup.c */
+extern VariableCache ShmemVariableCache; /* varsup.c */
SPINLOCK ShmemLock; /* lock for shared memory allocation */
@@ -85,8 +85,9 @@ SPINLOCK ShmemIndexLock; /* lock for shmem index access */
static unsigned long *ShmemFreeStart = NULL; /* pointer to the OFFSET
* of first free shared
* memory */
-static unsigned long *ShmemIndexOffset = NULL; /* start of the shmem index
- * table (for bootstrap) */
+static unsigned long *ShmemIndexOffset = NULL; /* start of the shmem
+ * index table (for
+ * bootstrap) */
static int ShmemBootstrap = FALSE; /* flag becomes true when shared
* mem is created by POSTMASTER */
@@ -155,6 +156,7 @@ InitShmem(unsigned int key, unsigned int size)
item;
bool found;
IpcMemoryId shmid;
+
/* if zero key, use default memory size */
if (size)
ShmemSize = size;
@@ -204,7 +206,7 @@ InitShmem(unsigned int key, unsigned int size)
if (ShmemBootstrap)
{
*ShmemFreeStart = currFreeSpace;
- memset (ShmemVariableCache, 0, sizeof(*ShmemVariableCache));
+ memset(ShmemVariableCache, 0, sizeof(*ShmemVariableCache));
}
/* if ShmemFreeStart is NULL, then the allocator won't work */
@@ -217,8 +219,8 @@ InitShmem(unsigned int key, unsigned int size)
/* This will acquire the shmem index lock, but not release it. */
ShmemIndex = ShmemInitHash("ShmemIndex",
- SHMEM_INDEX_SIZE, SHMEM_INDEX_SIZE,
- &info, hash_flags);
+ SHMEM_INDEX_SIZE, SHMEM_INDEX_SIZE,
+ &info, hash_flags);
if (!ShmemIndex)
{
@@ -248,8 +250,7 @@ InitShmem(unsigned int key, unsigned int size)
{
/*
- * bootstrapping shmem: we have to initialize the shmem index
- * now.
+ * bootstrapping shmem: we have to initialize the shmem index now.
*/
Assert(ShmemBootstrap);
@@ -501,14 +502,16 @@ ShmemInitStruct(char *name, unsigned long size, bool *foundPtr)
{
#ifdef USE_ASSERT_CHECKING
char *strname = "ShmemIndex";
+
#endif
+
/*
* If the shmem index doesnt exist, we fake it.
*
* If we are creating the first shmem index, then let shmemalloc()
* allocate the space for a new HTAB. Otherwise, find the old one
- * and return that. Notice that the ShmemIndexLock is held until the
- * shmem index has been completely initialized.
+ * and return that. Notice that the ShmemIndexLock is held until
+ * the shmem index has been completely initialized.
*/
Assert(!strcmp(name, strname));
if (ShmemBootstrap)
@@ -545,6 +548,7 @@ ShmemInitStruct(char *name, unsigned long size, bool *foundPtr)
}
else if (*foundPtr)
{
+
/*
* Structure is in the shmem index so someone else has allocated
* it already. The size better be the same as the size we are
@@ -634,23 +638,23 @@ TransactionIdIsInProgress(TransactionId xid)
* placed in array. Current xact ID are never placed there (just
* to reduce its length, xmin/xmax may be equal to cid).
* MyProc->xmin will be setted if equal to InvalidTransactionId.
- *
+ *
* Yet another strange func for this place... - vadim 07/21/98
*/
Snapshot
GetSnapshotData(bool serialized)
{
- Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData));
- TransactionId snapshot->xip = (TransactionId*)
- malloc(32 * sizeof(TransactionId));
- ShmemIndexEnt *result;
- PROC *proc;
- TransactionId cid = GetCurrentTransactionId();
- uint count = 0;
- unit free = 31;
+ Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData));
+ TransactionId snapshot->xip = (TransactionId *)
+ malloc(32 * sizeof(TransactionId));
+ ShmemIndexEnt *result;
+ PROC *proc;
+ TransactionId cid = GetCurrentTransactionId();
+ uint count = 0;
+ unit free = 31;
Assert(ShmemIndex);
-
+
snapshot->xmax = cid;
snapshot->xmin = cid;
@@ -672,7 +676,7 @@ GetSnapshotData(bool serialized)
continue;
proc = (PROC *) MAKE_PTR(result->location);
if (proc == MyProc || proc->xid < FirstTransactionId ||
- serialized && proc->xid >= cid)
+ serialized && proc->xid >= cid)
continue;
if (proc->xid < snapshot->xmin)
snapshot->xmin = proc->xid;
@@ -680,8 +684,8 @@ GetSnapshotData(bool serialized)
snapshot->xmax = proc->xid;
if (free == 0)
{
- snapshot->xip = (TransactionId*) realloc(snapshot->xip,
- (count + 33) * sizeof(TransactionId));
+ snapshot->xip = (TransactionId *) realloc(snapshot->xip,
+ (count + 33) * sizeof(TransactionId));
free = 32;
}
snapshot->xip[count] = proc->xid;
@@ -695,4 +699,5 @@ GetSnapshotData(bool serialized)
elog(ERROR, "GetSnapshotData: ShmemIndex corrupted");
return NULL;
}
+
#endif
diff --git a/src/backend/storage/ipc/shmqueue.c b/src/backend/storage/ipc/shmqueue.c
index 95ebfd01360..c460beaf900 100644
--- a/src/backend/storage/ipc/shmqueue.c
+++ b/src/backend/storage/ipc/shmqueue.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.8 1998/09/01 03:25:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.9 1998/09/01 04:31:50 momjian Exp $
*
* NOTES
*
@@ -32,7 +32,7 @@
#define SHMQUEUE_DEBUG_HD /* head inserts */
#define SHMQUEUE_DEBUG_TL /* tail inserts */
#define SHMQUEUE_DEBUG_ELOG NOTICE
-#endif /* SHMQUEUE_DEBUG */
+#endif /* SHMQUEUE_DEBUG */
/*
* ShmemQueueInit -- make the head of a new queue point
@@ -85,14 +85,14 @@ SHMQueueDelete(SHM_QUEUE *queue)
#ifdef SHMQUEUE_DEBUG_DEL
dumpQ(queue, "in SHMQueueDelete: begin");
-#endif /* SHMQUEUE_DEBUG_DEL */
+#endif /* SHMQUEUE_DEBUG_DEL */
prevElem->next = (queue)->next;
nextElem->prev = (queue)->prev;
#ifdef SHMQUEUE_DEBUG_DEL
dumpQ((SHM_QUEUE *) MAKE_PTR(queue->prev), "in SHMQueueDelete: end");
-#endif /* SHMQUEUE_DEBUG_DEL */
+#endif /* SHMQUEUE_DEBUG_DEL */
}
#ifdef SHMQUEUE_DEBUG
@@ -144,7 +144,7 @@ dumpQ(SHM_QUEUE *q, char *s)
elog(SHMQUEUE_DEBUG_ELOG, "%s: %s", s, buf);
}
-#endif /* SHMQUEUE_DEBUG */
+#endif /* SHMQUEUE_DEBUG */
/*
* SHMQueueInsertHD -- put elem in queue between the queue head
@@ -162,7 +162,7 @@ SHMQueueInsertHD(SHM_QUEUE *queue, SHM_QUEUE *elem)
#ifdef SHMQUEUE_DEBUG_HD
dumpQ(queue, "in SHMQueueInsertHD: begin");
-#endif /* SHMQUEUE_DEBUG_HD */
+#endif /* SHMQUEUE_DEBUG_HD */
(elem)->next = prevPtr->next;
(elem)->prev = queue->prev;
@@ -171,7 +171,7 @@ SHMQueueInsertHD(SHM_QUEUE *queue, SHM_QUEUE *elem)
#ifdef SHMQUEUE_DEBUG_HD
dumpQ(queue, "in SHMQueueInsertHD: end");
-#endif /* SHMQUEUE_DEBUG_HD */
+#endif /* SHMQUEUE_DEBUG_HD */
}
#endif
@@ -187,7 +187,7 @@ SHMQueueInsertTL(SHM_QUEUE *queue, SHM_QUEUE *elem)
#ifdef SHMQUEUE_DEBUG_TL
dumpQ(queue, "in SHMQueueInsertTL: begin");
-#endif /* SHMQUEUE_DEBUG_TL */
+#endif /* SHMQUEUE_DEBUG_TL */
(elem)->prev = nextPtr->prev;
(elem)->next = queue->next;
@@ -196,7 +196,7 @@ SHMQueueInsertTL(SHM_QUEUE *queue, SHM_QUEUE *elem)
#ifdef SHMQUEUE_DEBUG_TL
dumpQ(queue, "in SHMQueueInsertTL: end");
-#endif /* SHMQUEUE_DEBUG_TL */
+#endif /* SHMQUEUE_DEBUG_TL */
}
/*
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c
index c5c011b5d42..7c4ceaca43b 100644
--- a/src/backend/storage/ipc/sinval.c
+++ b/src/backend/storage/ipc/sinval.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.11 1998/08/25 21:31:17 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.12 1998/09/01 04:31:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -157,7 +157,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,
diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c
index adfa1757d9b..806b7806646 100644
--- a/src/backend/storage/ipc/sinvaladt.c
+++ b/src/backend/storage/ipc/sinvaladt.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.14 1998/09/01 03:25:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.15 1998/09/01 04:31:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -88,7 +88,7 @@ SISetActiveProcess(SISeg *segInOutP, BackendId backendId)
int
SIBackendInit(SISeg *segInOutP)
{
- LockRelId LtCreateRelId();
+ LockRelId LtCreateRelId();
TransactionId LMITransactionIdCopy();
Assert(MyBackendTag > 0);
@@ -100,7 +100,7 @@ SIBackendInit(SISeg *segInOutP)
#ifdef INVALIDDEBUG
elog(DEBUG, "SIBackendInit: backend tag %d; backend id %d.",
MyBackendTag, MyBackendId);
-#endif /* INVALIDDEBUG */
+#endif /* INVALIDDEBUG */
SISetActiveProcess(segInOutP, MyBackendId);
on_shmem_exit(CleanupInvalidationState, (caddr_t) segInOutP);
@@ -151,7 +151,7 @@ SIAssignBackendId(SISeg *segInOutP, BackendTag backendTag)
}
Assert(stateP);
-
+
if (stateP->tag != InvalidBackendTag)
{
if (stateP->tag == backendTag)
@@ -360,16 +360,18 @@ SIGetProcStateLimit(SISeg *segP, int i)
static bool
SIIncNumEntries(SISeg *segP, int num)
{
+
/*
- * Try to prevent table overflow. When the table is 70% full send
- * a SIGUSR2 to the postmaster which will send it back to all the
+ * Try to prevent table overflow. When the table is 70% full send a
+ * SIGUSR2 to the postmaster which will send it back to all the
* backends. This will be handled by Async_NotifyHandler() with a
* StartTransactionCommand() which will flush unread SI entries for
* each backend. dz - 27 Jan 1998
*/
- if (segP->numEntries == (MAXNUMMESSAGES * 70 / 100)) {
+ if (segP->numEntries == (MAXNUMMESSAGES * 70 / 100))
+ {
TPRINTF(TRACE_VERBOSE,
- "SIIncNumEntries: table is 70%% full, signaling postmaster");
+ "SIIncNumEntries: table is 70%% full, signaling postmaster");
kill(getppid(), SIGUSR2);
}
@@ -844,7 +846,7 @@ SISegmentInit(bool killExistingSegment, IPCKey key)
if (shmId < 0)
{
perror("SISegmentGet: failed");
- return -1; /* an error */
+ return -1; /* an error */
}
/* Attach the shared cache invalidation segment */
@@ -862,7 +864,7 @@ SISegmentInit(bool killExistingSegment, IPCKey key)
if (shmId < 0)
{
perror("SISegmentGet: getting an existent segment failed");
- return -1; /* an error */
+ return -1; /* an error */
}
/* Attach the shared cache invalidation segment */
SISegmentAttach(shmId);
diff --git a/src/backend/storage/ipc/spin.c b/src/backend/storage/ipc/spin.c
index 398815fe188..2bd88356fe7 100644
--- a/src/backend/storage/ipc/spin.c
+++ b/src/backend/storage/ipc/spin.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.16 1998/09/01 03:25:15 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.17 1998/09/01 04:31:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -63,6 +63,7 @@ InitSpinLocks(int init, IPCKey key)
#ifdef STABLE_MEMORY_STORAGE
extern SPINLOCK MMCacheLock;
+
#endif
/* These six spinlocks have fixed location is shmem */
@@ -83,7 +84,7 @@ InitSpinLocks(int init, IPCKey key)
#ifdef LOCKDEBUG
#define PRINT_LOCK(LOCK) \
- TPRINTF(TRACE_SPINLOCKS, \
+ TPRINTF(TRACE_SPINLOCKS, \
"(locklock = %d, flag = %d, nshlocks = %d, shlock = %d, " \
"exlock =%d)\n", LOCK->locklock, \
LOCK->flag, LOCK->nshlocks, LOCK->shlock, \
@@ -140,9 +141,10 @@ SpinRelease(SPINLOCK lockid)
slckP = &(SLockArray[lockid]);
#ifdef USE_ASSERT_CHECKING
+
/*
- * Check that we are actually holding the lock we are releasing.
- * This can be done only after MyProc has been initialized.
+ * Check that we are actually holding the lock we are releasing. This
+ * can be done only after MyProc has been initialized.
*/
if (MyProc)
Assert(MyProc->sLocks[lockid] > 0);
@@ -334,4 +336,4 @@ InitSpinLocks(int init, IPCKey key)
return TRUE;
}
-#endif /* HAS_TEST_AND_SET */
+#endif /* HAS_TEST_AND_SET */
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index 91f3f9e21f8..fde126fb84a 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.37 1998/09/01 03:25:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.38 1998/09/01 04:31:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,16 +61,16 @@
*/
/*
- * In order to prevent buffer leak on transaction commit, large object
- * scan index handling has been modified. Indexes are persistant inside
- * a transaction but may be closed between two calls to this API (when
- * transaction is committed while object is opened, or when no
- * transaction is active). Scan indexes are thus now reinitialized using
- * the object current offset. [PA]
+ * In order to prevent buffer leak on transaction commit, large object
+ * scan index handling has been modified. Indexes are persistant inside
+ * a transaction but may be closed between two calls to this API (when
+ * transaction is committed while object is opened, or when no
+ * transaction is active). Scan indexes are thus now reinitialized using
+ * the object current offset. [PA]
*
- * Some cleanup has been also done for non freed memory.
+ * Some cleanup has been also done for non freed memory.
*
- * For subsequent notes, [PA] is Pascal Andr� <[email protected]>
+ * For subsequent notes, [PA] is Pascal Andr� <[email protected]>
*/
#define IFREESPC(p) (PageGetFreeSpace(p) - sizeof(HeapTupleData) - sizeof(struct varlena) - sizeof(int32))
@@ -78,13 +78,11 @@
#define IMINBLK 512
/* non-export function prototypes */
-static HeapTuple
-inv_newtuple(LargeObjectDesc *obj_desc, Buffer buffer,
+static HeapTuple inv_newtuple(LargeObjectDesc *obj_desc, Buffer buffer,
Page page, char *dbuf, int nwrite);
static HeapTuple inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer);
static int inv_wrnew(LargeObjectDesc *obj_desc, char *buf, int nbytes);
-static int
-inv_wrold(LargeObjectDesc *obj_desc, char *dbuf, int nbytes,
+static int inv_wrold(LargeObjectDesc *obj_desc, char *dbuf, int nbytes,
HeapTuple tuple, Buffer buffer);
static void inv_indextup(LargeObjectDesc *obj_desc, HeapTuple tuple);
static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln);
@@ -276,7 +274,8 @@ inv_close(LargeObjectDesc *obj_desc)
{
Assert(PointerIsValid(obj_desc));
- if (obj_desc->iscan != (IndexScanDesc) NULL) {
+ if (obj_desc->iscan != (IndexScanDesc) NULL)
+ {
index_endscan(obj_desc->iscan);
pfree(obj_desc->iscan);
obj_desc->iscan = NULL;
@@ -468,8 +467,8 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
/* fetch a block at a time */
while (nread < nbytes)
{
- Buffer buffer;
-
+ Buffer buffer;
+
/* fetch an inversion file system block */
tuple = inv_fetchtup(obj_desc, &buffer);
@@ -482,7 +481,7 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
/* copy the data from this block into the buffer */
d = heap_getattr(tuple, 2, obj_desc->hdesc, &isNull);
ReleaseBuffer(buffer);
-
+
fsblock = (struct varlena *) DatumGetPointer(d);
off = obj_desc->offset - obj_desc->lowbyte;
@@ -526,8 +525,8 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
/* write a block at a time */
while (nwritten < nbytes)
{
- Buffer buffer;
-
+ Buffer buffer;
+
/*
* Fetch the current inversion file system block. If the class
* storing the inversion file is empty, we don't want to do an
@@ -552,7 +551,7 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
tuplen = inv_wrold(obj_desc, buf, nbytes - nwritten, tuple, buffer);
}
ReleaseBuffer(buffer);
-
+
/* move pointers past the amount we just wrote */
buf += tuplen;
nwritten += tuplen;
@@ -565,23 +564,24 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
/*
* inv_cleanindex --
- * Clean opened indexes for large objects, and clears current result.
- * This is necessary on transaction commit in order to prevent buffer
- * leak.
- * This function must be called for each opened large object.
- * [ PA, 7/17/98 ]
+ * Clean opened indexes for large objects, and clears current result.
+ * This is necessary on transaction commit in order to prevent buffer
+ * leak.
+ * This function must be called for each opened large object.
+ * [ PA, 7/17/98 ]
*/
-void
+void
inv_cleanindex(LargeObjectDesc *obj_desc)
{
- Assert(PointerIsValid(obj_desc));
+ Assert(PointerIsValid(obj_desc));
- if (obj_desc->iscan == (IndexScanDesc) NULL) return;
+ if (obj_desc->iscan == (IndexScanDesc) NULL)
+ return;
index_endscan(obj_desc->iscan);
pfree(obj_desc->iscan);
obj_desc->iscan = (IndexScanDesc) NULL;
-
+
ItemPointerSetInvalid(&(obj_desc->htid));
}
@@ -630,13 +630,13 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer)
{
ScanKeyData skey;
- /*
- * As scan index may be prematurely closed (on commit),
- * we must use object current offset (was 0) to
- * reinitialize the entry [ PA ].
+ /*
+ * As scan index may be prematurely closed (on commit), we
+ * must use object current offset (was 0) to reinitialize the
+ * entry [ PA ].
*/
ScanKeyEntryInitialize(&skey, 0x0, 1, F_INT4GE,
- Int32GetDatum(obj_desc->offset));
+ Int32GetDatum(obj_desc->offset));
obj_desc->iscan =
index_beginscan(obj_desc->index_r,
(bool) 0, (uint16) 1,
@@ -658,13 +658,13 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer)
* rather that NowTimeQual. We currently have no way to pass
* a time qual in.
*
- * This is now valid for snapshot !!!
- * And should be fixed in some way... - vadim 07/28/98
- *
+ * This is now valid for snapshot !!! And should be fixed in some
+ * way... - vadim 07/28/98
+ *
*/
tuple = heap_fetch(obj_desc->heap_r, SnapshotNow,
- &res->heap_iptr, buffer);
+ &res->heap_iptr, buffer);
pfree(res);
} while (tuple == (HeapTuple) NULL);
@@ -675,7 +675,7 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer)
else
{
tuple = heap_fetch(obj_desc->heap_r, SnapshotNow,
- &(obj_desc->htid), buffer);
+ &(obj_desc->htid), buffer);
}
/*
@@ -1213,7 +1213,7 @@ _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln)
long size;
bool isNull;
Buffer buffer;
-
+
/* scan backwards from end */
iscan = index_beginscan(ireln, (bool) 1, 0, (ScanKey) NULL);
@@ -1250,6 +1250,6 @@ _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln)
d = heap_getattr(tuple, 1, hdesc, &isNull);
size = DatumGetInt32(d) + 1;
ReleaseBuffer(buffer);
-
+
return size;
}
diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c
index a24d7298087..13adb8c48f8 100644
--- a/src/backend/storage/lmgr/lmgr.c
+++ b/src/backend/storage/lmgr/lmgr.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.18 1998/08/24 01:13:46 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.19 1998/09/01 04:31:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,7 +16,7 @@
#ifdef LOCKDEBUGALL
#define LOCKDEBUG 1
-#endif /* LOCKDEBUGALL */
+#endif /* LOCKDEBUGALL */
#include <string.h>
@@ -56,20 +56,20 @@ extern Oid MyDatabaseId;
void
RelationInitLockInfo(Relation relation)
{
- LockInfo info;
- char *relname;
- MemoryContext oldcxt;
- extern Oid MyDatabaseId; /* XXX use include */
- extern GlobalMemory CacheCxt;
+ LockInfo info;
+ char *relname;
+ MemoryContext oldcxt;
+ extern Oid MyDatabaseId; /* XXX use include */
+ extern GlobalMemory CacheCxt;
Assert(RelationIsValid(relation));
Assert(OidIsValid(RelationGetRelid(relation)));
info = (LockInfo) relation->lockInfo;
-
+
if (LockInfoIsValid(info))
return;
-
+
relname = (char *) RelationGetRelationName(relation);
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
@@ -99,7 +99,7 @@ elog(DEBUG, "RelationSetLockForDescriptorOpen(%s[%d,%d]) called", \
RelationGetRelationName(relation), lockRelId.dbId, lockRelId.relId)
#else
#define LOCKDEBUGALL_30
-#endif /* LOCKDEBUGALL */
+#endif /* LOCKDEBUGALL */
void
RelationSetLockForDescriptorOpen(Relation relation)
@@ -131,7 +131,7 @@ elog(DEBUG, "RelationSetLockForRead(%s[%d,%d]) called", \
RelationGetRelationName(relation), lockRelId.dbId, lockRelId.relId)
#else
#define LOCKDEBUG_40
-#endif /* LOCKDEBUG */
+#endif /* LOCKDEBUG */
/*
* RelationSetLockForRead --
@@ -180,7 +180,7 @@ elog(DEBUG, "RelationUnsetLockForRead(%s[%d,%d]) called", \
RelationGetRelationName(relation), lockRelId.dbId, lockRelId.relId)
#else
#define LOCKDEBUG_50
-#endif /* LOCKDEBUG */
+#endif /* LOCKDEBUG */
/*
* RelationUnsetLockForRead --
@@ -226,7 +226,7 @@ elog(DEBUG, "RelationSetLockForWrite(%s[%d,%d]) called", \
RelationGetRelationName(relation), lockRelId.dbId, lockRelId.relId)
#else
#define LOCKDEBUG_60
-#endif /* LOCKDEBUG */
+#endif /* LOCKDEBUG */
/*
* RelationSetLockForWrite --
@@ -275,7 +275,7 @@ elog(DEBUG, "RelationUnsetLockForWrite(%s[%d,%d]) called", \
RelationGetRelationName(relation), lockRelId.dbId, lockRelId.relId)
#else
#define LOCKDEBUG_70
-#endif /* LOCKDEBUG */
+#endif /* LOCKDEBUG */
/*
* RelationUnsetLockForWrite --
@@ -316,7 +316,7 @@ elog(DEBUG, "RelationSetLockForReadPage(%s[%d,%d], @%d) called", \
RelationGetRelationName(relation), lockRelId.dbId, lockRelId.relId, page)
#else
#define LOCKDEBUG_90
-#endif /* LOCKDEBUG */
+#endif /* LOCKDEBUG */
/* ----------------
* RelationSetLockForWritePage
@@ -328,7 +328,7 @@ elog(DEBUG, "RelationSetLockForWritePage(%s[%d,%d], @%d) called", \
RelationGetRelationName(relation), lockRelId.dbId, lockRelId.relId, page)
#else
#define LOCKDEBUG_100
-#endif /* LOCKDEBUG */
+#endif /* LOCKDEBUG */
/*
* RelationSetLockForWritePage --
@@ -370,7 +370,7 @@ elog(DEBUG, "RelationUnsetLockForReadPage(%s[%d,%d], @%d) called", \
RelationGetRelationName(relation), lockRelId.dbId, lockRelId.relId, page)
#else
#define LOCKDEBUG_110
-#endif /* LOCKDEBUG */
+#endif /* LOCKDEBUG */
/* ----------------
* RelationUnsetLockForWritePage
@@ -382,7 +382,7 @@ elog(DEBUG, "RelationUnsetLockForWritePage(%s[%d,%d], @%d) called", \
RelationGetRelationName(relation), lockRelId.dbId, lockRelId.relId, page)
#else
#define LOCKDEBUG_120
-#endif /* LOCKDEBUG */
+#endif /* LOCKDEBUG */
/*
* Set a single level write page lock. Assumes that you already
@@ -609,4 +609,3 @@ RelationUnsetLockForExtend(Relation relation)
}
#endif
-
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 2456b2a6683..a40034ac331 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.35 1998/09/01 03:25:19 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.36 1998/09/01 04:32:00 momjian Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
@@ -52,7 +52,7 @@
#include "utils/ps_status.h"
static int WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode,
- TransactionId xid);
+ TransactionId xid);
/*
* lockDebugRelation can be used to trace unconditionally a single relation,
@@ -64,11 +64,11 @@ static int WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode,
* If you are using tprintf you should specify a value greater than the max
* oid of system relations, which can be found with the following query:
*
- * select max(int4in(int4out(oid))) from pg_class where relname ~ '^pg_';
+ * select max(int4in(int4out(oid))) from pg_class where relname ~ '^pg_';
*
* To get a useful lock trace you can use the following pg_options:
*
- * -T "verbose,query,locks,userlocks,lock_debug_oidmin=17500"
+ * -T "verbose,query,locks,userlocks,lock_debug_oidmin=17500"
*/
#define LOCKDEBUG(lockmethod) (pg_options[TRACE_SHORTLOCKS+lockmethod])
#define lockDebugRelation (pg_options[TRACE_LOCKRELATION])
@@ -77,10 +77,10 @@ static int WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode,
#ifdef LOCK_MGR_DEBUG
#define LOCK_PRINT(where,lock,type) \
- if (((LOCKDEBUG(LOCK_LOCKMETHOD(*(lock))) >= 1) \
- && (lock->tag.relId >= lockDebugOidMin)) \
- || (lock->tag.relId == lockDebugRelation)) \
- LOCK_PRINT_AUX(where,lock,type)
+ if (((LOCKDEBUG(LOCK_LOCKMETHOD(*(lock))) >= 1) \
+ && (lock->tag.relId >= lockDebugOidMin)) \
+ || (lock->tag.relId == lockDebugRelation)) \
+ LOCK_PRINT_AUX(where,lock,type)
#define LOCK_PRINT_AUX(where,lock,type) \
TPRINTF(TRACE_ALL, \
@@ -113,11 +113,11 @@ static int WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode,
#define XID_PRINT(where,xidentP) \
if (((LOCKDEBUG(XIDENT_LOCKMETHOD(*(xidentP))) >= 1) \
- && (((LOCK *)MAKE_PTR(xidentP->tag.lock))->tag.relId \
+ && (((LOCK *)MAKE_PTR(xidentP->tag.lock))->tag.relId \
>= lockDebugOidMin)) \
- || (((LOCK *)MAKE_PTR(xidentP->tag.lock))->tag.relId \
+ || (((LOCK *)MAKE_PTR(xidentP->tag.lock))->tag.relId \
== lockDebugRelation)) \
- XID_PRINT_AUX(where,xidentP)
+ XID_PRINT_AUX(where,xidentP)
#define XID_PRINT_AUX(where,xidentP) \
TPRINTF(TRACE_ALL, \
@@ -137,18 +137,18 @@ static int WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode,
xidentP->nHolding)
#define LOCK_TPRINTF(lock, args...) \
- if (((LOCKDEBUG(LOCK_LOCKMETHOD(*(lock))) >= 1) \
- && (lock->tag.relId >= lockDebugOidMin)) \
- || (lock->tag.relId == lockDebugRelation)) \
- TPRINTF(TRACE_ALL, args)
+ if (((LOCKDEBUG(LOCK_LOCKMETHOD(*(lock))) >= 1) \
+ && (lock->tag.relId >= lockDebugOidMin)) \
+ || (lock->tag.relId == lockDebugRelation)) \
+ TPRINTF(TRACE_ALL, args)
-#else /* !LOCK_MGR_DEBUG */
+#else /* !LOCK_MGR_DEBUG */
#define LOCK_PRINT(where,lock,type)
#define LOCK_PRINT_AUX(where,lock,type)
#define XID_PRINT(where,xidentP)
#define XID_PRINT_AUX(where,xidentP)
#define LOCK_TPRINTF(lock, args...)
-#endif /* !LOCK_MGR_DEBUG */
+#endif /* !LOCK_MGR_DEBUG */
static char *lock_types[] = {
"",
@@ -204,13 +204,13 @@ InitLocks()
}
#ifdef LOCK_MGR_DEBUG
+
/*
- * If lockDebugOidMin value has not been specified
- * in pg_options set a default value.
+ * If lockDebugOidMin value has not been specified in pg_options set a
+ * default value.
*/
- if (!lockDebugOidMin) {
+ if (!lockDebugOidMin)
lockDebugOidMin = BootstrapObjectIdData;
- }
#endif
}
@@ -232,10 +232,10 @@ LockDisable(int status)
* Notes: just copying. Should only be called once.
*/
static void
-LockMethodInit(LOCKMETHODTABLE *lockMethodTable,
- MASK *conflictsP,
- int *prioP,
- int numModes)
+LockMethodInit(LOCKMETHODTABLE * lockMethodTable,
+ MASK *conflictsP,
+ int *prioP,
+ int numModes)
{
int i;
@@ -260,11 +260,11 @@ LockMethodInit(LOCKMETHODTABLE *lockMethodTable,
*/
LOCKMETHOD
LockMethodTableInit(char *tabName,
- MASK *conflictsP,
- int *prioP,
- int numModes)
+ MASK *conflictsP,
+ int *prioP,
+ int numModes)
{
- LOCKMETHODTABLE *lockMethodTable;
+ LOCKMETHODTABLE *lockMethodTable;
char *shmemName;
HASHCTL info;
int hash_flags;
@@ -355,7 +355,7 @@ LockMethodTableInit(char *tabName,
sprintf(shmemName, "%s (lock hash)", tabName);
lockMethodTable->lockHash = (HTAB *) ShmemInitHash(shmemName,
INIT_TABLE_SIZE, MAX_TABLE_SIZE,
- &info, hash_flags);
+ &info, hash_flags);
Assert(lockMethodTable->lockHash->hash == tag_hash);
if (!lockMethodTable->lockHash)
@@ -377,7 +377,7 @@ LockMethodTableInit(char *tabName,
sprintf(shmemName, "%s (xid hash)", tabName);
lockMethodTable->xidHash = (HTAB *) ShmemInitHash(shmemName,
INIT_TABLE_SIZE, MAX_TABLE_SIZE,
- &info, hash_flags);
+ &info, hash_flags);
if (!lockMethodTable->xidHash)
{
@@ -414,7 +414,7 @@ LockMethodTableInit(char *tabName,
LOCKMETHOD
LockMethodTableRename(LOCKMETHOD lockmethod)
{
- LOCKMETHOD newLockMethod;
+ LOCKMETHOD newLockMethod;
if (NumLockMethods >= MAX_LOCK_METHODS)
return INVALID_LOCKMETHOD;
@@ -494,7 +494,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
bool found;
LOCK *lock = NULL;
SPINLOCK masterLock;
- LOCKMETHODTABLE *lockMethodTable;
+ LOCKMETHODTABLE *lockMethodTable;
int status;
TransactionId xid;
@@ -560,7 +560,9 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
Assert(BlockIdEquals(&(lock->tag.tupleId.ip_blkid),
&(locktag->tupleId.ip_blkid)));
LOCK_PRINT("LockAcquire: new", lock, lockmode);
- } else {
+ }
+ else
+ {
LOCK_PRINT("LockAcquire: found", lock, lockmode);
Assert((lock->nHolding > 0) && (lock->holders[lockmode] >= 0));
Assert((lock->nActive > 0) && (lock->activeHolders[lockmode] >= 0));
@@ -589,7 +591,9 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
{
item.tag.pid = MyProcPid;
item.tag.xid = xid = 0;
- } else {
+ }
+ else
+ {
xid = GetCurrentTransactionId();
TransactionIdStore(xid, &item.tag.xid);
}
@@ -618,7 +622,9 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
MemSet((char *) result->holders, 0, sizeof(int) * MAX_LOCKMODES);
ProcAddLock(&result->queue);
XID_PRINT("LockAcquire: new", result);
- } else {
+ }
+ else
+ {
XID_PRINT("LockAcquire: found", result);
Assert((result->nHolding > 0) && (result->holders[lockmode] >= 0));
Assert(result->nHolding <= lock->nActive);
@@ -658,6 +664,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
else if (status == STATUS_FOUND)
{
#ifdef USER_LOCKS
+
/*
* User locks are non blocking. If we can't acquire a lock we must
* remove the xid entry and return FALSE without waiting.
@@ -669,13 +676,12 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
SHMQueueDelete(&result->queue);
result = (XIDLookupEnt *) hash_search(xidTable,
(Pointer) result,
- HASH_REMOVE, &found);
- if (!result || !found) {
+ HASH_REMOVE, &found);
+ if (!result || !found)
elog(NOTICE, "LockAcquire: remove xid, table corrupted");
- }
- } else {
- XID_PRINT_AUX("LockAcquire: NHOLDING", result);
}
+ else
+ XID_PRINT_AUX("LockAcquire: NHOLDING", result);
lock->nHolding--;
lock->holders[lockmode]--;
LOCK_PRINT("LockAcquire: user lock failed", lock, lockmode);
@@ -686,11 +692,13 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
}
#endif
status = WaitOnLock(lockmethod, lock, lockmode, xid);
+
/*
- * Check the xid entry status, in case something in the
- * ipc communication doesn't work correctly.
+ * Check the xid entry status, in case something in the ipc
+ * communication doesn't work correctly.
*/
- if (!((result->nHolding > 0) && (result->holders[lockmode] > 0))) {
+ if (!((result->nHolding > 0) && (result->holders[lockmode] > 0)))
+ {
XID_PRINT_AUX("LockAcquire: INCONSISTENT ", result);
LOCK_PRINT_AUX("LockAcquire: INCONSISTENT ", lock, lockmode);
/* Should we retry ? */
@@ -737,20 +745,26 @@ LockResolveConflicts(LOCKMETHOD lockmethod,
int bitmask;
int i,
tmpMask;
+
#ifdef USER_LOCKS
int is_user_lock;
+
#endif
numLockModes = LockMethodTable[lockmethod]->ctl->numLockModes;
xidTable = LockMethodTable[lockmethod]->xidHash;
- if (xidentP) {
+ if (xidentP)
+ {
+
/*
* A pointer to the xid entry was supplied from the caller.
* Actually only LockAcquire can do it.
*/
result = xidentP;
- } else {
+ }
+ else
+ {
/* ---------------------
* read my own statistics from the xid table. If there
* isn't an entry, then we'll just add one.
@@ -766,12 +780,13 @@ LockResolveConflicts(LOCKMETHOD lockmethod,
#endif
#ifdef USER_LOCKS
is_user_lock = (lockmethod == 2);
- if (is_user_lock) {
+ if (is_user_lock)
+ {
item.tag.pid = MyProcPid;
item.tag.xid = 0;
- } else {
- TransactionIdStore(xid, &item.tag.xid);
}
+ else
+ TransactionIdStore(xid, &item.tag.xid);
#else
TransactionIdStore(xid, &item.tag.xid);
#endif
@@ -788,9 +803,9 @@ LockResolveConflicts(LOCKMETHOD lockmethod,
}
/*
- * If not found initialize the new entry. THIS SHOULD NEVER HAPPEN,
- * if we are trying to resolve a conflict we must already have
- * allocated an xid entry for this lock. dz 21-11-1997
+ * If not found initialize the new entry. THIS SHOULD NEVER
+ * HAPPEN, if we are trying to resolve a conflict we must already
+ * have allocated an xid entry for this lock. dz 21-11-1997
*/
if (!found)
{
@@ -799,12 +814,12 @@ LockResolveConflicts(LOCKMETHOD lockmethod,
* the lock stats.
* ---------------
*/
- MemSet(result->holders,0, numLockModes * sizeof(*(lock->holders)));
+ MemSet(result->holders, 0, numLockModes * sizeof(*(lock->holders)));
result->nHolding = 0;
XID_PRINT_AUX("LockResolveConflicts: NOT FOUND", result);
- } else {
- XID_PRINT("LockResolveConflicts: found", result);
}
+ else
+ XID_PRINT("LockResolveConflicts: found", result);
}
Assert((result->nHolding >= 0) && (result->holders[lockmode] >= 0));
@@ -822,7 +837,8 @@ LockResolveConflicts(LOCKMETHOD lockmethod,
PROC_QUEUE *waitQueue = &(lock->waitProcs);
PROC *topproc = (PROC *) MAKE_PTR(waitQueue->links.prev);
- if (waitQueue->size && topproc->prio > myprio) {
+ if (waitQueue->size && topproc->prio > myprio)
+ {
XID_PRINT("LockResolveConflicts: higher priority proc waiting",
result);
return STATUS_FOUND;
@@ -904,7 +920,7 @@ WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode,
TransactionId xid)
{
PROC_QUEUE *waitQueue = &(lock->waitProcs);
- LOCKMETHODTABLE *lockMethodTable = LockMethodTable[lockmethod];
+ LOCKMETHODTABLE *lockMethodTable = LockMethodTable[lockmethod];
int prio = lockMethodTable->ctl->prio[lockmode];
char old_status[64],
new_status[64];
@@ -970,7 +986,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
LOCK *lock = NULL;
SPINLOCK masterLock;
bool found;
- LOCKMETHODTABLE *lockMethodTable;
+ LOCKMETHODTABLE *lockMethodTable;
XIDLookupEnt *result,
item;
HTAB *xidTable;
@@ -1024,7 +1040,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
HASH_FIND, &found);
/*
- * let the caller print its own error message, too. Do not elog(ERROR).
+ * let the caller print its own error message, too. Do not
+ * elog(ERROR).
*/
if (!lock)
{
@@ -1037,7 +1054,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
{
SpinRelease(masterLock);
#ifdef USER_LOCKS
- if (is_user_lock) {
+ if (is_user_lock)
+ {
TPRINTF(TRACE_USERLOCKS, "LockRelease: no lock with this tag");
return FALSE;
}
@@ -1062,10 +1080,13 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
item.tag.lockmethod = lockmethod;
#endif
#ifdef USER_LOCKS
- if (is_user_lock) {
+ if (is_user_lock)
+ {
item.tag.pid = MyProcPid;
item.tag.xid = xid = 0;
- } else {
+ }
+ else
+ {
xid = GetCurrentTransactionId();
TransactionIdStore(xid, &item.tag.xid);
}
@@ -1084,21 +1105,22 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
{
SpinRelease(masterLock);
#ifdef USER_LOCKS
- if (!found && is_user_lock) {
+ if (!found && is_user_lock)
TPRINTF(TRACE_USERLOCKS, "LockRelease: no lock with this tag");
- } else
+ else
#endif
- elog(NOTICE, "LockReplace: xid table corrupted");
+ elog(NOTICE, "LockReplace: xid table corrupted");
return FALSE;
}
XID_PRINT("LockRelease: found", result);
Assert(result->tag.lock == MAKE_OFFSET(lock));
/*
- * Check that we are actually holding a lock of the type we want
- * to release.
+ * Check that we are actually holding a lock of the type we want to
+ * release.
*/
- if (!(result->holders[lockmode] > 0)) {
+ if (!(result->holders[lockmode] > 0))
+ {
SpinRelease(masterLock);
XID_PRINT_AUX("LockAcquire: WRONGTYPE", result);
elog(NOTICE, "LockRelease: you don't own a lock of type %s",
@@ -1114,7 +1136,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
lock->nHolding--;
lock->holders[lockmode]--;
lock->nActive--;
- lock->activeHolders[lockmode]--;
+ lock->activeHolders[lockmode]--;
/* --------------------------
* If there are still active locks of the type I just released, no one
@@ -1123,9 +1145,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
* --------------------------
*/
if (lock->activeHolders[lockmode])
- {
wakeupNeeded = false;
- }
else
{
/* change the conflict mask. No more of this lock type. */
@@ -1169,12 +1189,10 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
*/
if (!result->nHolding)
{
- if (result->queue.prev == INVALID_OFFSET) {
+ if (result->queue.prev == INVALID_OFFSET)
elog(NOTICE, "LockRelease: xid.prev == INVALID_OFFSET");
- }
- if (result->queue.next == INVALID_OFFSET) {
+ if (result->queue.next == INVALID_OFFSET)
elog(NOTICE, "LockRelease: xid.next == INVALID_OFFSET");
- }
if (result->queue.next != INVALID_OFFSET)
SHMQueueDelete(&result->queue);
XID_PRINT("LockRelease: deleting", result);
@@ -1199,9 +1217,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode)
ProcLockWakeup(&(lock->waitProcs), lockmethod, lock);
}
else
- {
LOCK_TPRINTF(lock, "LockRelease: no wakeup needed");
- }
SpinRelease(masterLock);
return TRUE;
@@ -1220,7 +1236,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
XIDLookupEnt *result;
SHMEM_OFFSET end = MAKE_OFFSET(lockQueue);
SPINLOCK masterLock;
- LOCKMETHODTABLE *lockMethodTable;
+ LOCKMETHODTABLE *lockMethodTable;
int i,
numLockModes;
LOCK *lock;
@@ -1245,7 +1261,8 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
Assert(lockmethod < NumLockMethods);
lockMethodTable = LockMethodTable[lockmethod];
- if (!lockMethodTable) {
+ if (!lockMethodTable)
+ {
elog(NOTICE, "LockAcquire: bad lockmethod %d", lockmethod);
return FALSE;
}
@@ -1261,6 +1278,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
for (;;)
{
+
/*
* Sometimes the queue appears to be messed up.
*/
@@ -1281,7 +1299,8 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
lock = (LOCK *) MAKE_PTR(xidLook->tag.lock);
xidtag_lockmethod = XIDENT_LOCKMETHOD(*xidLook);
- if ((xidtag_lockmethod == lockmethod) || (trace_flag >= 2)) {
+ if ((xidtag_lockmethod == lockmethod) || (trace_flag >= 2))
+ {
XID_PRINT("LockReleaseAll", xidLook);
LOCK_PRINT("LockReleaseAll", lock, 0);
}
@@ -1291,7 +1310,8 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
elog(NOTICE, "LockReleaseAll: xid/lock method mismatch: %d != %d",
xidtag_lockmethod, lock->tag.lockmethod);
#endif
- if ((xidtag_lockmethod != lockmethod) && (trace_flag >= 2)) {
+ if ((xidtag_lockmethod != lockmethod) && (trace_flag >= 2))
+ {
TPRINTF(trace_flag, "LockReleaseAll: skipping other table");
nleft++;
goto next_item;
@@ -1310,7 +1330,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
{
TPRINTF(TRACE_USERLOCKS,
"LockReleaseAll: skiping normal lock [%d,%d,%d]",
- xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
+ xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
nleft++;
goto next_item;
}
@@ -1322,28 +1342,32 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
lock->tag.tupleId.ip_posid,
((lock->tag.tupleId.ip_blkid.bi_hi << 16) +
lock->tag.tupleId.ip_blkid.bi_lo),
- xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
+ xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
nleft++;
goto next_item;
}
TPRINTF(TRACE_USERLOCKS,
- "LockReleaseAll: releasing user lock [%u,%u] [%d,%d,%d]",
+ "LockReleaseAll: releasing user lock [%u,%u] [%d,%d,%d]",
lock->tag.tupleId.ip_posid,
((lock->tag.tupleId.ip_blkid.bi_hi << 16) +
lock->tag.tupleId.ip_blkid.bi_lo),
- xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
+ xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
}
else
{
- /* Can't check xidLook->tag.xid, can be 0 also for normal locks */
+
+ /*
+ * Can't check xidLook->tag.xid, can be 0 also for normal
+ * locks
+ */
if (xidLook->tag.pid != 0)
{
TPRINTF(TRACE_LOCKS,
- "LockReleaseAll: skiping user lock [%u,%u] [%d,%d,%d]",
+ "LockReleaseAll: skiping user lock [%u,%u] [%d,%d,%d]",
lock->tag.tupleId.ip_posid,
((lock->tag.tupleId.ip_blkid.bi_hi << 16) +
lock->tag.tupleId.ip_blkid.bi_lo),
- xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
+ xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid);
nleft++;
goto next_item;
}
@@ -1362,7 +1386,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
lock->holders[i] -= xidLook->holders[i];
lock->activeHolders[i] -= xidLook->holders[i];
Assert((lock->holders[i] >= 0) \
- && (lock->activeHolders[i] >= 0));
+ &&(lock->activeHolders[i] >= 0));
if (!lock->activeHolders[i])
lock->mask &= BITS_OFF[i];
}
@@ -1380,7 +1404,8 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
*/
lock->nHolding = 0;
/* Fix the lock status, just for next LOCK_PRINT message. */
- for (i=1; i<=numLockModes; i++) {
+ for (i = 1; i <= numLockModes; i++)
+ {
Assert(lock->holders[i] == lock->activeHolders[i]);
lock->holders[i] = lock->activeHolders[i] = 0;
}
@@ -1399,7 +1424,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue)
XID_PRINT("LockReleaseAll: deleting", xidLook);
result = (XIDLookupEnt *) hash_search(lockMethodTable->xidHash,
- (Pointer) xidLook,
+ (Pointer) xidLook,
HASH_REMOVE,
&found);
if (!result || !found)
@@ -1452,7 +1477,8 @@ next_item:
/*
* Reinitialize the queue only if nothing has been left in.
*/
- if (nleft == 0) {
+ if (nleft == 0)
+ {
TPRINTF(trace_flag, "LockReleaseAll: reinitializing lockQueue");
SHMQueueInit(lockQueue);
}
@@ -1479,7 +1505,8 @@ LockShmemSize()
nXidSegs = 1 << (int) my_log2((nLockBuckets - 1) / DEF_SEGSIZE + 1);
size += MAXALIGN(NBACKENDS * sizeof(PROC)); /* each MyProc */
- size += MAXALIGN(NBACKENDS * sizeof(LOCKMETHODCTL)); /* each lockMethodTable->ctl */
+ size += MAXALIGN(NBACKENDS * sizeof(LOCKMETHODCTL)); /* each
+ * lockMethodTable->ctl */
size += MAXALIGN(sizeof(PROC_HDR)); /* ProcGlobal */
size += MAXALIGN(my_log2(NLOCKENTS) * sizeof(void *));
@@ -1531,7 +1558,7 @@ DeadLockCheck(SHM_QUEUE *lockQueue, LOCK *findlock, bool skip_check)
SHMEM_OFFSET end = MAKE_OFFSET(lockQueue);
LOCK *lock;
- LOCKMETHODTABLE *lockMethodTable;
+ LOCKMETHODTABLE *lockMethodTable;
XIDLookupEnt *result,
item;
HTAB *xidTable;
@@ -1692,16 +1719,16 @@ DeadLockCheck(SHM_QUEUE *lockQueue, LOCK *findlock, bool skip_check)
* This works only for user locks because normal locks have no
* pid information in the corresponding XIDLookupEnt.
*/
-ArrayType *
+ArrayType *
LockOwners(LOCKMETHOD lockmethod, LOCKTAG *locktag)
{
XIDLookupEnt *xidLook = NULL;
SPINLOCK masterLock;
- LOCK *lock;
+ LOCK *lock;
SHMEM_OFFSET lock_offset;
- int count = 0;
- LOCKMETHODTABLE *lockMethodTable;
- HTAB *xidTable;
+ int count = 0;
+ LOCKMETHODTABLE *lockMethodTable;
+ HTAB *xidTable;
bool found;
int ndims,
nitems,
@@ -1709,11 +1736,11 @@ LockOwners(LOCKMETHOD lockmethod, LOCKTAG *locktag)
size;
int lbounds[1],
hbounds[1];
- ArrayType *array;
- int *data_ptr;
+ ArrayType *array;
+ int *data_ptr;
/* Assume that no one will modify the result */
- static int empty_array[] = { 20, 1, 0, 0, 0 };
+ static int empty_array[] = {20, 1, 0, 0, 0};
#ifdef USER_LOCKS
int is_user_lock;
@@ -1740,9 +1767,7 @@ LockOwners(LOCKMETHOD lockmethod, LOCKTAG *locktag)
}
if (LockingIsDisabled)
- {
return (ArrayType *) &empty_array;
- }
masterLock = lockMethodTable->ctl->masterLock;
SpinAcquire(masterLock);
@@ -1768,7 +1793,8 @@ LockOwners(LOCKMETHOD lockmethod, LOCKTAG *locktag)
{
SpinRelease(masterLock);
#ifdef USER_LOCKS
- if (is_user_lock) {
+ if (is_user_lock)
+ {
TPRINTF(TRACE_USERLOCKS, "LockOwners: no lock with this tag");
return (ArrayType *) &empty_array;
}
@@ -1799,53 +1825,61 @@ LockOwners(LOCKMETHOD lockmethod, LOCKTAG *locktag)
xidTable = lockMethodTable->xidHash;
hash_seq(NULL);
nitems = 0;
- while ((xidLook = (XIDLookupEnt *)hash_seq(xidTable)) &&
- (xidLook != (XIDLookupEnt *)TRUE)) {
- if (count++ > 1000) {
- elog(NOTICE,"LockOwners: possible loop, giving up");
+ while ((xidLook = (XIDLookupEnt *) hash_seq(xidTable)) &&
+ (xidLook != (XIDLookupEnt *) TRUE))
+ {
+ if (count++ > 1000)
+ {
+ elog(NOTICE, "LockOwners: possible loop, giving up");
break;
}
- if (xidLook->tag.pid == 0) {
+ if (xidLook->tag.pid == 0)
+ {
XID_PRINT("LockOwners: no pid", xidLook);
continue;
}
- if (!xidLook->tag.lock) {
+ if (!xidLook->tag.lock)
+ {
XID_PRINT("LockOwners: NULL LOCK", xidLook);
continue;
}
- if (xidLook->tag.lock != lock_offset) {
+ if (xidLook->tag.lock != lock_offset)
+ {
XID_PRINT("LockOwners: different lock", xidLook);
continue;
}
- if (LOCK_LOCKMETHOD(*lock) != lockmethod) {
+ if (LOCK_LOCKMETHOD(*lock) != lockmethod)
+ {
XID_PRINT("LockOwners: other table", xidLook);
continue;
}
- if (xidLook->nHolding <= 0) {
+ if (xidLook->nHolding <= 0)
+ {
XID_PRINT("LockOwners: not holding", xidLook);
continue;
}
- if (nitems >= hbounds[0]) {
- elog(NOTICE,"LockOwners: array size exceeded");
+ if (nitems >= hbounds[0])
+ {
+ elog(NOTICE, "LockOwners: array size exceeded");
break;
}
/*
- * Check that the holding process is still alive by sending
- * him an unused (ignored) signal. If the kill fails the
- * process is not alive.
+ * Check that the holding process is still alive by sending him an
+ * unused (ignored) signal. If the kill fails the process is not
+ * alive.
*/
if ((xidLook->tag.pid != MyProcPid) \
- && (kill(xidLook->tag.pid, SIGCHLD)) != 0)
+ &&(kill(xidLook->tag.pid, SIGCHLD)) != 0)
{
/* Return a negative pid to signal that process is dead */
- data_ptr[nitems++] = - (xidLook->tag.pid);
+ data_ptr[nitems++] = -(xidLook->tag.pid);
XID_PRINT("LockOwners: not alive", xidLook);
/* XXX - TODO: remove this entry and update lock stats */
continue;
@@ -1887,7 +1921,7 @@ DumpLocks()
LOCK *lock;
int count = 0;
int lockmethod = DEFAULT_LOCKMETHOD;
- LOCKMETHODTABLE *lockMethodTable;
+ LOCKMETHODTABLE *lockMethodTable;
ShmemPIDLookup(MyProcPid, &location);
if (location == INVALID_OFFSET)
@@ -1911,9 +1945,8 @@ DumpLocks()
SHMQueueFirst(lockQueue, (Pointer *) &xidLook, &xidLook->queue);
end = MAKE_OFFSET(lockQueue);
- if (MyProc->waitLock) {
+ if (MyProc->waitLock)
LOCK_PRINT_AUX("DumpLocks: waiting on", MyProc->waitLock, 0);
- }
for (;;)
{
@@ -1950,17 +1983,17 @@ void
DumpAllLocks()
{
SHMEM_OFFSET location;
- PROC *proc;
+ PROC *proc;
XIDLookupEnt *xidLook = NULL;
- LOCK *lock;
- int pid;
- int count = 0;
+ LOCK *lock;
+ int pid;
+ int count = 0;
int lockmethod = DEFAULT_LOCKMETHOD;
- LOCKMETHODTABLE *lockMethodTable;
- HTAB *xidTable;
+ LOCKMETHODTABLE *lockMethodTable;
+ HTAB *xidTable;
pid = getpid();
- ShmemPIDLookup(pid,&location);
+ ShmemPIDLookup(pid, &location);
if (location == INVALID_OFFSET)
return;
proc = (PROC *) MAKE_PTR(location);
@@ -1974,26 +2007,29 @@ DumpAllLocks()
xidTable = lockMethodTable->xidHash;
- if (MyProc->waitLock) {
- LOCK_PRINT_AUX("DumpAllLocks: waiting on", MyProc->waitLock,0);
- }
+ if (MyProc->waitLock)
+ LOCK_PRINT_AUX("DumpAllLocks: waiting on", MyProc->waitLock, 0);
hash_seq(NULL);
- while ((xidLook = (XIDLookupEnt *)hash_seq(xidTable)) &&
- (xidLook != (XIDLookupEnt *)TRUE)) {
+ while ((xidLook = (XIDLookupEnt *) hash_seq(xidTable)) &&
+ (xidLook != (XIDLookupEnt *) TRUE))
+ {
XID_PRINT_AUX("DumpAllLocks", xidLook);
- if (xidLook->tag.lock) {
+ if (xidLook->tag.lock)
+ {
lock = (LOCK *) MAKE_PTR(xidLook->tag.lock);
LOCK_PRINT_AUX("DumpAllLocks", lock, 0);
- } else {
- elog(DEBUG, "DumpAllLocks: xidLook->tag.lock = NULL");
}
+ else
+ elog(DEBUG, "DumpAllLocks: xidLook->tag.lock = NULL");
- if (count++ > 2000) {
- elog(NOTICE,"DumpAllLocks: possible loop, giving up");
+ if (count++ > 2000)
+ {
+ elog(NOTICE, "DumpAllLocks: possible loop, giving up");
break;
}
}
}
+
#endif
diff --git a/src/backend/storage/lmgr/multi.c b/src/backend/storage/lmgr/multi.c
index 01d1a0f5fe1..9bc6a598157 100644
--- a/src/backend/storage/lmgr/multi.c
+++ b/src/backend/storage/lmgr/multi.c
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.24 1998/09/01 03:25:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.25 1998/09/01 04:32:01 momjian Exp $
*
* NOTES:
* (1) The lock.c module assumes that the caller here is doing
@@ -30,15 +30,15 @@
#include "miscadmin.h" /* MyDatabaseId */
static bool MultiAcquire(LOCKMETHOD lockmethod, LOCKTAG *tag,
- LOCKMODE lockmode, PG_LOCK_LEVEL level);
+ LOCKMODE lockmode, PG_LOCK_LEVEL level);
static bool MultiRelease(LOCKMETHOD lockmethod, LOCKTAG *tag,
- LOCKMODE lockmode, PG_LOCK_LEVEL level);
+ LOCKMODE lockmode, PG_LOCK_LEVEL level);
#ifdef LowLevelLocking
-static MASK MultiConflicts[] = {
+static MASK MultiConflicts[] = {
(int) NULL,
-
+
/* RowShareLock */
(1 << ExclusiveLock),
@@ -46,26 +46,26 @@ static MASK MultiConflicts[] = {
(1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) | (1 << ShareLock),
/* ShareLock */
- (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) |
+ (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) |
(1 << RowExclusiveLock),
/* ShareRowExclusiveLock */
- (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) |
+ (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) |
(1 << ShareLock) | (1 << RowExclusiveLock),
-
+
/* ExclusiveLock */
- (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) | (1 << ShareLock) |
+ (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) | (1 << ShareLock) |
(1 << RowExclusiveLock) | (1 << RowShareLock),
-
+
/* ObjShareLock */
(1 << ObjExclusiveLock),
-
+
/* ObjExclusiveLock */
(1 << ObjExclusiveLock) | (1 << ObjShareLock),
-
+
/* ExtendLock */
(1 << ExtendLock)
-
+
};
/*
@@ -90,7 +90,7 @@ static int MultiPrios[] = {
* WRITE conflict between the tuple's intent lock and the relation's
* write lock.
*/
-static MASK MultiConflicts[] = {
+static MASK 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),
@@ -121,16 +121,18 @@ static int MultiPrios[] = {
1
};
-#endif /* !LowLevelLocking */
+#endif /* !LowLevelLocking */
/*
* Lock table identifier for this lock table. The multi-level
* lock table is ONE lock table, not three.
*/
-LOCKMETHOD MultiTableId = (LOCKMETHOD) NULL;
-LOCKMETHOD LongTermTableId = (LOCKMETHOD) NULL;
+LOCKMETHOD MultiTableId = (LOCKMETHOD) NULL;
+LOCKMETHOD LongTermTableId = (LOCKMETHOD) NULL;
+
#ifdef NOT_USED
-LOCKMETHOD ShortTermTableId = (LOCKMETHOD) NULL;
+LOCKMETHOD ShortTermTableId = (LOCKMETHOD) NULL;
+
#endif
/*
@@ -141,8 +143,8 @@ InitMultiLevelLocks()
{
int lockmethod;
- lockmethod = LockMethodTableInit("MultiLevelLockTable",
- MultiConflicts, MultiPrios, MAX_LOCKMODES - 1);
+ lockmethod = LockMethodTableInit("MultiLevelLockTable",
+ MultiConflicts, MultiPrios, MAX_LOCKMODES - 1);
MultiTableId = lockmethod;
if (!(MultiTableId))
elog(ERROR, "InitMultiLocks: couldnt initialize lock table");
@@ -157,6 +159,7 @@ InitMultiLevelLocks()
*/
#ifdef USER_LOCKS
+
/*
* Allocate another tableId for long-term locks
*/
@@ -420,7 +423,7 @@ MultiRelease(LOCKMETHOD lockmethod,
LOCKMODE lockmode,
PG_LOCK_LEVEL level)
{
- LOCKMODE locks[N_LEVELS];
+ LOCKMODE locks[N_LEVELS];
int i,
status;
LOCKTAG xxTag,
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 3fc24260315..650500de48b 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.42 1998/09/01 03:25:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.43 1998/09/01 04:32:02 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.42 1998/09/01 03:25:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.43 1998/09/01 04:32:02 momjian Exp $
*/
#include <sys/time.h>
#include <unistd.h>
@@ -187,10 +187,10 @@ InitProcess(IPCKey key)
{
/*
- * have to allocate one. We can't use the normal shmem index table
- * mechanism because the proc structure is stored by PID instead
- * of by a global name (need to look it up by PID when we cleanup
- * dead processes).
+ * have to allocate one. We can't use the normal shmem index
+ * table mechanism because the proc structure is stored by PID
+ * instead of by a global name (need to look it up by PID when we
+ * cleanup dead processes).
*/
MyProc = (PROC *) ShmemAlloc((unsigned) sizeof(PROC));
@@ -364,6 +364,7 @@ ProcKill(int exitStatus, int pid)
LockReleaseAll(DEFAULT_LOCKMETHOD, &proc->lockQueue);
#ifdef USER_LOCKS
+
/*
* Assume we have a second lock table.
*/
@@ -440,12 +441,12 @@ ProcQueueInit(PROC_QUEUE *queue)
* NOTES: The process queue is now a priority queue for locking.
*/
int
-ProcSleep(PROC_QUEUE *waitQueue, /* lock->waitProcs */
+ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */
SPINLOCK spinlock,
- int token, /* lockmode */
+ int token, /* lockmode */
int prio,
LOCK *lock,
- TransactionId xid) /* needed by user locks, see below */
+ TransactionId xid) /* needed by user locks, see below */
{
int i;
PROC *proc;
@@ -561,7 +562,7 @@ ProcSleep(PROC_QUEUE *waitQueue, /* lock->waitProcs */
#ifdef LOCK_MGR_DEBUG
/* Just to get meaningful debug messages from DumpLocks() */
- MyProc->waitLock = (LOCK *)NULL;
+ MyProc->waitLock = (LOCK *) NULL;
#endif
return MyProc->errType;
@@ -620,13 +621,13 @@ ProcLockWakeup(PROC_QUEUE *queue, LOCKMETHOD lockmethod, LOCK *lock)
count = 0;
while ((queue_size--) && (proc))
{
+
/*
- * This proc will conflict as the previous one did, don't even try.
+ * This proc will conflict as the previous one did, don't even
+ * try.
*/
if (proc->token == last_locktype)
- {
continue;
- }
/*
* This proc conflicts with locks held by others, ignored.
@@ -663,7 +664,8 @@ ProcLockWakeup(PROC_QUEUE *queue, LOCKMETHOD lockmethod, LOCK *lock)
if (count)
return STATUS_OK;
- else {
+ else
+ {
/* Something is still blocking us. May have deadlocked. */
trace_flag = (lock->tag.lockmethod == USER_LOCKMETHOD) ? \
TRACE_USERLOCKS : TRACE_LOCKS;
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c
index bd90d7a29d8..674e5ecd996 100644
--- a/src/backend/storage/page/bufpage.c
+++ b/src/backend/storage/page/bufpage.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.19 1998/09/01 03:25:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.20 1998/09/01 04:32:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -24,8 +24,7 @@
#include "utils/memutils.h"
#include "storage/bufpage.h"
-static void
-PageIndexTupleDeleteAdjustLinePointers(PageHeader phdr,
+static void PageIndexTupleDeleteAdjustLinePointers(PageHeader phdr,
char *location, Size size);
static bool PageManagerShuffle = true; /* default is shuffle mode */
@@ -306,7 +305,7 @@ PageRepairFragmentation(Page page)
/* sort itemIdSortData array... */
qsort((char *) itemidbase, nused, sizeof(struct itemIdSortData),
- itemidcompare);
+ itemidcompare);
/* compactify page */
((PageHeader) page)->pd_upper = ((PageHeader) page)->pd_special;
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index fb421636215..1c458728837 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.38 1998/09/01 03:25:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.39 1998/09/01 04:32:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -568,7 +568,7 @@ mdblindwrt(char *dbstr,
int4 owner;
Oid id;
char *tmpPath;
- int tmpEncoding;
+ int tmpEncoding;
GetRawDatabaseInfo(dbstr, &owner, &id, dbpath, &tmpEncoding);
@@ -607,7 +607,7 @@ mdblindwrt(char *dbstr,
int4 owner;
Oid id;
char *tmpPath;
- int tmpEncoding;
+ int tmpEncoding;
GetRawDatabaseInfo(dbstr, &owner, &id, dbpath, &tmpEncoding);
diff --git a/src/backend/storage/smgr/mm.c b/src/backend/storage/smgr/mm.c
index 4b9c9e885a2..b3e72e37d68 100644
--- a/src/backend/storage/smgr/mm.c
+++ b/src/backend/storage/smgr/mm.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.11 1998/09/01 03:25:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.12 1998/09/01 04:32:07 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -138,7 +138,7 @@ mminit()
return SM_FAIL;
}
- if (IsUnderPostmaster) /* was IsPostmaster bjm */
+ if (IsUnderPostmaster) /* was IsPostmaster bjm */
{
MemSet(mmcacheblk, 0, mmsize);
SpinRelease(MMCacheLock);
@@ -608,4 +608,4 @@ MMShmemSize()
return size;
}
-#endif /* STABLE_MEMORY_STORAGE */
+#endif /* STABLE_MEMORY_STORAGE */
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c
index 75ea2297efa..f3d6cbfafc4 100644
--- a/src/backend/storage/smgr/smgr.c
+++ b/src/backend/storage/smgr/smgr.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.19 1998/09/01 03:25:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.20 1998/09/01 04:32:08 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -132,7 +132,7 @@ smgrcreate(int16 which, Relation reln)
int fd;
if ((fd = (*(smgrsw[which].smgr_create)) (reln)) < 0)
- elog(ERROR, "cannot create %s", reln->rd_rel->relname.data);
+ elog(ERROR, "cannot create %s", reln->rd_rel->relname.data);
return fd;
}
@@ -251,7 +251,7 @@ smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
if (status == SM_FAIL)
elog(ERROR, "cannot write block %d of %s",
- blocknum, reln->rd_rel->relname.data);
+ blocknum, reln->rd_rel->relname.data);
return status;
}
@@ -349,7 +349,7 @@ smgrtruncate(int16 which, Relation reln, int nblocks)
{
if ((newblks = (*(smgrsw[which].smgr_truncate)) (reln, nblocks)) < 0)
elog(ERROR, "cannot truncate %s to %d blocks",
- reln->rd_rel->relname.data, nblocks);
+ reln->rd_rel->relname.data, nblocks);
}
return newblks;