summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/heapam.h9
-rw-r--r--src/include/storage/buf_internals.h6
-rw-r--r--src/include/storage/lmgr.h22
-rw-r--r--src/include/utils/rel.h56
4 files changed, 48 insertions, 45 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index 8c1461122f..b6dccc33fa 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: heapam.h,v 1.45 1999/07/16 17:07:26 momjian Exp $
+ * $Id: heapam.h,v 1.46 1999/09/18 19:08:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,6 +18,7 @@
#include "access/relscan.h"
#include "access/tupmacs.h"
#include "storage/block.h"
+#include "storage/lmgr.h"
#include "utils/rel.h"
#include "utils/tqual.h"
@@ -246,9 +247,9 @@ extern HeapAccessStatistics heap_access_stats; /* in stats.c */
/* heapam.c */
-extern Relation heap_open(Oid relationId);
-extern Relation heap_openr(char *relationName);
-extern void heap_close(Relation relation);
+extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
+extern Relation heap_openr(char *relationName, LOCKMODE lockmode);
+extern void heap_close(Relation relation, LOCKMODE lockmode);
extern HeapScanDesc heap_beginscan(Relation relation, int atend,
Snapshot snapshot, unsigned nkeys, ScanKey key);
extern void heap_rescan(HeapScanDesc scan, bool scanFromEnd, ScanKey key);
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h
index 98d8be3369..b98f0fb820 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.31 1999/07/16 17:07:37 momjian Exp $
+ * $Id: buf_internals.h,v 1.32 1999/09/18 19:08:18 tgl Exp $
*
* NOTE
* If BUFFERPAGE0 is defined, then 0 will be used as a
@@ -64,8 +64,8 @@ struct buftag
#define INIT_BUFFERTAG(a,xx_reln,xx_blockNum) \
( \
- (a)->blockNum = xx_blockNum, \
- (a)->relId = ((LockInfo)(xx_reln->lockInfo))->lockRelId \
+ (a)->blockNum = (xx_blockNum), \
+ (a)->relId = (xx_reln)->rd_lockInfo.lockRelId \
)
#define BAD_BUFFER_ID(bid) ((bid<1) || (bid>(NBuffers)))
diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h
index 8903af8ec6..302bedb677 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.22 1999/07/15 23:04:11 momjian Exp $
+ * $Id: lmgr.h,v 1.23 1999/09/18 19:08:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,6 +16,11 @@
#include "storage/lock.h"
#include "utils/rel.h"
+/* These are the valid values of type LOCKMODE: */
+
+/* NoLock is not a lock mode, but a flag value meaning "don't get a lock" */
+#define NoLock 0
+
#define AccessShareLock 1 /* SELECT */
#define RowShareLock 2 /* SELECT FOR UPDATE */
#define RowExclusiveLock 3 /* INSERT, UPDATE, DELETE */
@@ -27,21 +32,6 @@
extern LOCKMETHOD LockTableId;
-typedef struct LockRelId
-{
- Oid relId; /* a relation identifier */
- Oid dbId; /* a database identifier */
-} LockRelId;
-
-typedef struct LockInfoData
-{
- LockRelId lockRelId;
-} LockInfoData;
-
-typedef LockInfoData *LockInfo;
-
-#define LockInfoIsValid(lockinfo) PointerIsValid(lockinfo)
-
extern LOCKMETHOD InitLockTable(void);
extern void RelationInitLockInfo(Relation relation);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index c95f51e89d..f2789b39e0 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: rel.h,v 1.25 1999/07/16 17:07:40 momjian Exp $
+ * $Id: rel.h,v 1.26 1999/09/18 19:08:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,6 +20,26 @@
#include "rewrite/prs2lock.h"
#include "storage/fd.h"
+
+/*
+ * LockRelId and LockInfo really belong to lmgr.h, but it's more convenient
+ * to declare them here so we can have a LockInfoData field in a Relation.
+ */
+
+typedef struct LockRelId
+{
+ Oid relId; /* a relation identifier */
+ Oid dbId; /* a database identifier */
+} LockRelId;
+
+typedef struct LockInfoData
+{
+ LockRelId lockRelId;
+} LockInfoData;
+
+typedef LockInfoData *LockInfo;
+
+
typedef struct Trigger
{
char *tgname;
@@ -44,20 +64,21 @@ typedef struct TriggerDesc
Trigger *triggers;
} TriggerDesc;
+
typedef struct RelationData
{
File rd_fd; /* open file descriptor */
int rd_nblocks; /* number of blocks in rel */
uint16 rd_refcnt; /* reference count */
- bool rd_myxactonly; /* uses the local buffer mgr */
+ bool rd_myxactonly; /* rel uses the local buffer mgr */
bool rd_isnailed; /* rel is nailed in cache */
bool rd_isnoname; /* rel has no name */
bool rd_nonameunlinked; /* noname rel already unlinked */
Form_pg_am rd_am; /* AM tuple */
Form_pg_class rd_rel; /* RELATION tuple */
- Oid rd_id; /* relations's object id */
- Pointer lockInfo; /* ptr. to misc. info. */
- TupleDesc rd_att; /* tuple desciptor */
+ Oid rd_id; /* relation's object id */
+ LockInfoData rd_lockInfo; /* lock manager's info for locking relation */
+ TupleDesc rd_att; /* tuple descriptor */
RuleLock *rd_rules; /* rewrite rules */
IndexStrategy rd_istrat;
RegProcedure *rd_support;
@@ -66,6 +87,7 @@ typedef struct RelationData
typedef RelationData *Relation;
+
/* ----------------
* RelationPtr is used in the executor to support index scans
* where we have to keep track of several index relations in an
@@ -74,7 +96,6 @@ typedef RelationData *Relation;
*/
typedef Relation *RelationPtr;
-#define InvalidRelation ((Relation)NULL)
/*
* RelationIsValid
@@ -82,6 +103,8 @@ typedef Relation *RelationPtr;
*/
#define RelationIsValid(relation) PointerIsValid(relation)
+#define InvalidRelation ((Relation) NULL)
+
/*
* RelationGetSystemPort
* Returns system port of a relation.
@@ -92,13 +115,6 @@ typedef Relation *RelationPtr;
#define RelationGetSystemPort(relation) ((relation)->rd_fd)
/*
- * RelationGetLockInfo
- * Returns the lock information structure in the reldesc
- *
- */
-#define RelationGetLockInfo(relation) ((relation)->lockInfo)
-
-/*
* RelationHasReferenceCountZero
* True iff relation reference count is zero.
*
@@ -112,13 +128,13 @@ typedef Relation *RelationPtr;
* RelationSetReferenceCount
* Sets relation reference count.
*/
-#define RelationSetReferenceCount(relation,count) ((relation)->rd_refcnt = count)
+#define RelationSetReferenceCount(relation,count) ((relation)->rd_refcnt = (count))
/*
* RelationIncrementReferenceCount
* Increments relation reference count.
*/
-#define RelationIncrementReferenceCount(relation) ((relation)->rd_refcnt += 1);
+#define RelationIncrementReferenceCount(relation) ((relation)->rd_refcnt += 1)
/*
* RelationDecrementReferenceCount
@@ -135,7 +151,6 @@ typedef Relation *RelationPtr;
*/
#define RelationGetForm(relation) ((relation)->rd_rel)
-
/*
* RelationGetRelid
*
@@ -151,7 +166,6 @@ typedef Relation *RelationPtr;
*/
#define RelationGetFile(relation) ((relation)->rd_fd)
-
/*
* RelationGetRelationName
*
@@ -160,21 +174,19 @@ typedef Relation *RelationPtr;
#define RelationGetRelationName(relation) (&(relation)->rd_rel->relname)
/*
- * RelationGetRelationName
+ * RelationGetNumberOfAttributes
*
- * Returns a the number of attributes.
+ * Returns the number of attributes.
*/
#define RelationGetNumberOfAttributes(relation) ((relation)->rd_rel->relnatts)
/*
* RelationGetDescr
* Returns tuple descriptor for a relation.
- *
- * Note:
- * Assumes relation descriptor is valid.
*/
#define RelationGetDescr(relation) ((relation)->rd_att)
+
extern IndexStrategy RelationGetIndexStrategy(Relation relation);
extern void RelationSetIndexSupport(Relation relation, IndexStrategy strategy,