7
7
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.79 2004/07/17 03:31:26 tgl Exp $
10
+ * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.80 2004/08/26 17:22:28 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -26,10 +26,10 @@ typedef struct PROC_QUEUE
26
26
int size ; /* number of entries in list */
27
27
} PROC_QUEUE ;
28
28
29
- /* struct PGPROC is declared in storage/ proc.h, but must forward-reference it */
29
+ /* struct PGPROC is declared in proc.h, but must forward-reference it */
30
30
typedef struct PGPROC PGPROC ;
31
31
32
-
32
+ /* GUC variables */
33
33
extern int max_locks_per_xact ;
34
34
35
35
#ifdef LOCK_DEBUG
@@ -41,6 +41,11 @@ extern bool Debug_deadlocks;
41
41
#endif /* LOCK_DEBUG */
42
42
43
43
44
+ /*
45
+ * LOCKMODE is an integer (1..N) indicating a lock type. LOCKMASK is a bit
46
+ * mask indicating a set of held or requested lock types (the bit 1<<mode
47
+ * corresponds to a particular lock mode).
48
+ */
44
49
typedef int LOCKMASK ;
45
50
typedef int LOCKMODE ;
46
51
/* MAX_LOCKMODES cannot be larger than the # of bits in LOCKMASK */
@@ -49,6 +54,11 @@ typedef int LOCKMODE;
49
54
#define LOCKBIT_ON (lockmode ) (1 << (lockmode))
50
55
#define LOCKBIT_OFF (lockmode ) (~(1 << (lockmode)))
51
56
57
+ /*
58
+ * There is normally only one lock method, the default one.
59
+ * If user locks are enabled, an additional lock method is present.
60
+ * Lock methods are identified by LOCKMETHODID.
61
+ */
52
62
typedef uint16 LOCKMETHODID ;
53
63
/* MAX_LOCK_METHODS is the number of distinct lock control tables allowed */
54
64
#define MAX_LOCK_METHODS 3
@@ -60,18 +70,13 @@ typedef uint16 LOCKMETHODID;
60
70
#define LockMethodIsValid (lockmethodid ) ((lockmethodid) != INVALID_LOCKMETHOD)
61
71
62
72
/*
63
- * There is normally only one lock method, the default one.
64
- * If user locks are enabled, an additional lock method is present.
65
- *
66
- * This is the control structure for a lock table. It
67
- * lives in shared memory. This information is the same
68
- * for all backends.
73
+ * This is the control structure for a lock table. It lives in shared
74
+ * memory. Currently, none of these fields change after startup. In addition
75
+ * to the LockMethodData, a lock table has a "lockHash" table holding
76
+ * per-locked-object lock information, and a "proclockHash" table holding
77
+ * per-lock-holder/waiter lock information.
69
78
*
70
- * lockHash -- hash table holding per-locked-object lock information
71
- *
72
- * proclockHash -- hash table holding per-lock-waiter/holder lock information
73
- *
74
- * lockmethod -- the handle used by the lock table's clients to
79
+ * lockmethodid -- the handle used by the lock table's clients to
75
80
* refer to the type of lock table being used.
76
81
*
77
82
* numLockModes -- number of lock types (READ,WRITE,etc) that
@@ -81,8 +86,7 @@ typedef uint16 LOCKMETHODID;
81
86
* type conflicts. conflictTab[i] is a mask with the j-th bit
82
87
* turned on if lock types i and j conflict.
83
88
*
84
- * masterLock -- synchronizes access to the table
85
- *
89
+ * masterLock -- LWLock used to synchronize access to the table
86
90
*/
87
91
typedef struct LockMethodData
88
92
{
@@ -156,12 +160,13 @@ typedef struct LOCK
156
160
157
161
/*
158
162
* We may have several different transactions holding or awaiting locks
159
- * on the same lockable object. We need to store some per-waiter/holder
160
- * information for each such holder (or would-be holder).
163
+ * on the same lockable object. We need to store some per-holder/waiter
164
+ * information for each such holder (or would-be holder). This is kept in
165
+ * a PROCLOCK struct.
161
166
*
162
167
* PROCLOCKTAG is the key information needed to look up a PROCLOCK item in the
163
- * proclock hashtable. A PROCLOCKTAG value uniquely identifies a lock
164
- * holder/waiter.
168
+ * proclock hashtable. A PROCLOCKTAG value uniquely identifies the combination
169
+ * of a lockable object and a holder/waiter for that object .
165
170
*
166
171
* There are two possible kinds of proclock tags: a transaction (identified
167
172
* both by the PGPROC of the backend running it, and the xact's own ID) and
0 commit comments