summaryrefslogtreecommitdiff
path: root/src/include/storage
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/storage')
-rw-r--r--src/include/storage/buf_internals.h63
-rw-r--r--src/include/storage/bufmgr.h13
-rw-r--r--src/include/storage/ipc.h4
-rw-r--r--src/include/storage/lmgr.h64
-rw-r--r--src/include/storage/lock.h12
-rw-r--r--src/include/storage/proc.h4
-rw-r--r--src/include/storage/s_lock.h4
7 files changed, 65 insertions, 99 deletions
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h
index 61f567b6d3..383204c3f0 100644
--- a/src/include/storage/buf_internals.h
+++ b/src/include/storage/buf_internals.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: buf_internals.h,v 1.26 1998/09/01 04:38:10 momjian Exp $
+ * $Id: buf_internals.h,v 1.27 1998/12/15 12:46:55 vadim Exp $
*
* NOTE
* If BUFFERPAGE0 is defined, then 0 will be used as a
@@ -83,32 +83,6 @@ struct buftag
* Dbname, relname, dbid, and relid are enough to determine where
* to put the buffer, for all storage managers.
*/
-
-#define PADDED_SBUFDESC_SIZE 128
-
-/* DO NOT CHANGE THIS NEXT STRUCTURE:
- It is used only to get padding information for the real sbufdesc structure
- It should match the sbufdesc structure exactly except for a missing sb_pad
-*/
-struct sbufdesc_unpadded
-{
- Buffer freeNext;
- Buffer freePrev;
- SHMEM_OFFSET data;
- BufferTag tag;
- int buf_id;
- BufFlags flags;
- unsigned refcount;
-#ifdef HAS_TEST_AND_SET
- slock_t io_in_progress_lock;
-#endif /* HAS_TEST_AND_SET */
- char sb_dbname[NAMEDATALEN];
-
- /* NOTE NO PADDING OF THE MEMBER HERE */
- char sb_relname[NAMEDATALEN];
-};
-
-/* THE REAL STRUCTURE - the structure above must match it, minus sb_pad */
struct sbufdesc
{
Buffer freeNext; /* link for freelist chain */
@@ -125,32 +99,26 @@ struct sbufdesc
#ifdef HAS_TEST_AND_SET
/* can afford a dedicated lock if test-and-set locks are available */
slock_t io_in_progress_lock;
+ slock_t cntx_lock; /* to lock access to page context */
#endif /* HAS_TEST_AND_SET */
+ unsigned r_locks; /* # of shared locks */
+ bool ri_lock; /* read-intent lock */
+ bool w_lock; /* context exclusively locked */
char sb_dbname[NAMEDATALEN]; /* name of db in which buf belongs */
-
- /*
- * I padded this structure to a power of 2 (PADDED_SBUFDESC_SIZE)
- * because BufferDescriptorGetBuffer is called a billion times and it
- * does an C pointer subtraction (i.e., "x - y" -> array index of x
- * relative to y, which is calculated using division by struct size).
- * Integer ".div" hits you for 35 cycles, as opposed to a 1-cycle
- * "sra" ... this hack cut 10% off of the time to create the Wisconsin
- * database! It eats up more shared memory, of course, but we're
- * (allegedly) going to make some of these types bigger soon anyway...
- * -pma 1/2/93
- */
-
- /*
- * please, don't take the sizeof() this member and use it for
- * something important
- */
-
- char sb_relname[NAMEDATALEN + /* name of reln */
- PADDED_SBUFDESC_SIZE - sizeof(struct sbufdesc_unpadded)];
+ char sb_relname[NAMEDATALEN];/* name of reln */
};
/*
+ * Buffer lock infos in BufferLocks below.
+ * We have to free these locks in elog(ERROR)...
+ */
+#define BL_IO_IN_PROGRESS (1 << 0) /* unimplemented */
+#define BL_R_LOCK (1 << 1)
+#define BL_RI_LOCK (1 << 2)
+#define BL_W_LOCK (1 << 3)
+
+/*
* mao tracing buffer allocation
*/
@@ -201,6 +169,7 @@ extern BufferDesc *BufferDescriptors;
extern BufferBlock BufferBlocks;
extern long *PrivateRefCount;
extern long *LastRefCount;
+extern bits8 *BufferLocks;
extern long *CommitInfoNeedsSave;
extern SPINLOCK BufMgrLock;
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index 1948e813ee..22f66c2295 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: bufmgr.h,v 1.23 1998/10/08 18:30:43 momjian Exp $
+ * $Id: bufmgr.h,v 1.24 1998/12/15 12:46:56 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,6 +74,14 @@ extern int ShowPinTrace;
#define BUFFER_LATE_WRITE 1 /* delayed write: mark as DIRTY */
/*
+ * Buffer context lock modes
+ */
+#define BUFFER_LOCK_UNLOCK 0
+#define BUFFER_LOCK_SHARE 1
+#define BUFFER_LOCK_EXCLUSIVE 2
+
+
+/*
* BufferIsValid --
* True iff the refcnt of the local buffer is > 0
* Note:
@@ -155,4 +163,7 @@ extern void BufferRefCountRestore(int *refcountsave);
extern int SetBufferWriteMode(int mode);
extern void SetBufferCommitInfoNeedsSave(Buffer buffer);
+extern void UnlockBuffers(void);
+extern void LockBuffer(Buffer buffer, int mode);
+
#endif /* !defined(BufMgrIncluded) */
diff --git a/src/include/storage/ipc.h b/src/include/storage/ipc.h
index 4733b34bbc..2163aa79d5 100644
--- a/src/include/storage/ipc.h
+++ b/src/include/storage/ipc.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: ipc.h,v 1.30 1998/09/01 04:38:16 momjian Exp $
+ * $Id: ipc.h,v 1.31 1998/12/15 12:46:57 vadim Exp $
*
* NOTES
* This file is very architecture-specific. This stuff should actually
@@ -186,6 +186,8 @@ typedef enum _LockId_
((key == PrivateIPCKey) ? key : 11 + (key))
#define IPCKeyGetWaitIOSemaphoreKey(key) \
((key == PrivateIPCKey) ? key : 12 + (key))
+#define IPCKeyGetWaitCLSemaphoreKey(key) \
+ ((key == PrivateIPCKey) ? key : 13 + (key))
/* --------------------------
* NOTE: This macro must always give the highest numbered key as every backend
diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h
index 4082811bcc..a85ba1e8ff 100644
--- a/src/include/storage/lmgr.h
+++ b/src/include/storage/lmgr.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: lmgr.h,v 1.15 1998/09/01 04:38:23 momjian Exp $
+ * $Id: lmgr.h,v 1.16 1998/12/15 12:46:57 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,64 +17,48 @@
#include <utils/rel.h>
#include <catalog/catname.h>
-/*
- * This was moved from pladt.h for the new lock manager. Want to obsolete
- * all of the old code.
- */
+#define AccessShareLock 1 /* SELECT */
+#define RowShareLock 2 /* SELECT FOR UPDATE */
+#define RowExclusiveLock 3 /* INSERT, UPDATE, DELETE */
+#define ShareLock 4
+#define ShareRowExclusiveLock 5
+#define ExclusiveLock 6
+#define AccessExclusiveLock 7
+
+#define ExtendLock 8
+
+extern LOCKMETHOD LockTableId;
+
+
typedef struct LockRelId
{
Oid relId; /* a relation identifier */
Oid dbId; /* a database identifier */
} LockRelId;
-#ifdef LowLevelLocking
typedef struct LockInfoData
{
LockRelId lockRelId;
- bool lockHeld[MAX_LOCKMODES]; /* on table level */
} LockInfoData;
-#else
-typedef struct LockInfoData
-{
- LockRelId lockRelId;
-} LockInfoData;
-
-#endif
-
typedef LockInfoData *LockInfo;
#define LockInfoIsValid(lockinfo) PointerIsValid(lockinfo)
+extern LOCKMETHOD InitLockTable(void);
extern void RelationInitLockInfo(Relation relation);
-extern void RelationSetLockForDescriptorOpen(Relation relation);
-extern void RelationSetLockForRead(Relation relation);
-extern void RelationUnsetLockForRead(Relation relation);
-extern void RelationSetLockForWrite(Relation relation);
-extern void RelationUnsetLockForWrite(Relation relation);
-/* used in vaccum.c */
-extern void RelationSetLockForWritePage(Relation relation,
- ItemPointer itemPointer);
+extern void LockRelation(Relation relation, LOCKMODE lockmode);
+extern void UnlockRelation(Relation relation, LOCKMODE lockmode);
-/* used in nbtpage.c, hashpage.c */
-extern void RelationSetSingleWLockPage(Relation relation,
- ItemPointer itemPointer);
-extern void RelationUnsetSingleWLockPage(Relation relation,
- ItemPointer itemPointer);
-extern void RelationSetSingleRLockPage(Relation relation,
- ItemPointer itemPointer);
-extern void RelationUnsetSingleRLockPage(Relation relation,
- ItemPointer itemPointer);
-extern void RelationSetRIntentLock(Relation relation);
-extern void RelationUnsetRIntentLock(Relation relation);
-extern void RelationSetWIntentLock(Relation relation);
-extern void RelationUnsetWIntentLock(Relation relation);
+/* this is for indices */
+extern void LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
+extern void UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
-/* single.c */
-extern bool SingleLockReln(LockInfo lockinfo, LOCKMODE lockmode, int action);
-extern bool SingleLockPage(LockInfo lockinfo, ItemPointer tidPtr,
- LOCKMODE lockmode, int action);
+/* and this is for transactions */
+extern void XactLockTableInsert(TransactionId xid);
+extern void XactLockTableDelete(TransactionId xid);
+extern void XactLockTableWait(TransactionId xid);
/* proc.c */
extern void InitProcGlobal(IPCKey key);
diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h
index 329aa758a7..9c803ef8a1 100644
--- a/src/include/storage/lock.h
+++ b/src/include/storage/lock.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: lock.h,v 1.19 1998/10/08 18:30:45 momjian Exp $
+ * $Id: lock.h,v 1.20 1998/12/15 12:46:58 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,11 +42,7 @@ typedef int LOCKMODE;
typedef int LOCKMETHOD;
/* MAX_LOCKMODES cannot be larger than the bits in MASK */
-#ifdef LowLevelLocking
#define MAX_LOCKMODES 9
-#else
-#define MAX_LOCKMODES 6
-#endif
/*
* MAX_LOCK_METHODS corresponds to the number of spin locks allocated in
@@ -69,7 +65,11 @@ typedef struct LTAG
{
Oid relId;
Oid dbId;
- ItemPointerData tupleId;
+ union
+ {
+ BlockNumber blkno;
+ TransactionId xid;
+ } objId;
uint16 lockmethod; /* needed by user locks */
} LOCKTAG;
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 4a62fac18a..914d934524 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: proc.h,v 1.15 1998/09/01 04:38:31 momjian Exp $
+ * $Id: proc.h,v 1.16 1998/12/15 12:46:59 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -44,11 +44,9 @@ typedef struct proc
TransactionId xid; /* transaction currently being executed by
* this proc */
-#ifdef LowLevelLocking
TransactionId xmin; /* minimal running XID as it was when we
* were starting our xact: vacuum must not
* remove tuples deleted by xid >= xmin ! */
-#endif
LOCK *waitLock; /* Lock we're sleeping on */
int token; /* info for proc wakeup routines */
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index d47f5ab53b..aa20a328bd 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.56 1998/10/31 02:06:08 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.57 1998/12/15 12:46:59 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -68,6 +68,8 @@
#include "storage/ipc.h"
+extern void s_lock_sleep(unsigned spin);
+
#if defined(HAS_TEST_AND_SET)