Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
f21fa6a7
Commit
f21fa6a7
authored
Jun 28, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename lockt to locktype and rename LOCKT to LOCKTYPE.
parent
cff7e204
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
94 deletions
+94
-94
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/lock.c
+40
-40
src/backend/storage/lmgr/multi.c
src/backend/storage/lmgr/multi.c
+31
-31
src/backend/storage/lmgr/single.c
src/backend/storage/lmgr/single.c
+7
-7
src/include/storage/lmgr.h
src/include/storage/lmgr.h
+3
-3
src/include/storage/lock.h
src/include/storage/lock.h
+8
-8
src/include/storage/multilev.h
src/include/storage/multilev.h
+5
-5
No files found.
src/backend/storage/lmgr/lock.c
View file @
f21fa6a7
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.3
0 1998/06/27 15:47:46
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.3
1 1998/06/28 21:17:34
momjian Exp $
*
*
* NOTES
* NOTES
* Outside modules can create a lock table and acquire/release
* Outside modules can create a lock table and acquire/release
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
static
int
static
int
WaitOnLock
(
LOCKTAB
*
ltable
,
LockTableId
tableId
,
LOCK
*
lock
,
WaitOnLock
(
LOCKTAB
*
ltable
,
LockTableId
tableId
,
LOCK
*
lock
,
LOCKT
lockt
);
LOCKT
YPE
locktype
);
/*#define LOCK_MGR_DEBUG*/
/*#define LOCK_MGR_DEBUG*/
...
@@ -437,7 +437,7 @@ LockTableRename(LockTableId tableId)
...
@@ -437,7 +437,7 @@ LockTableRename(LockTableId tableId)
* xid.xid current xid 0
* xid.xid current xid 0
* persistence transaction user or backend
* persistence transaction user or backend
*
*
* The lockt parameter can have the same values for normal locks
* The lockt
ype
parameter can have the same values for normal locks
* although probably only WRITE_LOCK can have some practical use.
* although probably only WRITE_LOCK can have some practical use.
*
*
* DZ - 4 Oct 1996
* DZ - 4 Oct 1996
...
@@ -445,7 +445,7 @@ LockTableRename(LockTableId tableId)
...
@@ -445,7 +445,7 @@ LockTableRename(LockTableId tableId)
*/
*/
bool
bool
LockAcquire
(
LockTableId
tableId
,
LOCKTAG
*
lockName
,
LOCKT
lockt
)
LockAcquire
(
LockTableId
tableId
,
LOCKTAG
*
lockName
,
LOCKT
YPE
locktype
)
{
{
XIDLookupEnt
*
result
,
XIDLookupEnt
*
result
,
item
;
item
;
...
@@ -469,7 +469,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -469,7 +469,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
lockName
->
tupleId
.
ip_posid
,
lockName
->
tupleId
.
ip_posid
,
((
lockName
->
tupleId
.
ip_blkid
.
bi_hi
<<
16
)
+
((
lockName
->
tupleId
.
ip_blkid
.
bi_hi
<<
16
)
+
lockName
->
tupleId
.
ip_blkid
.
bi_lo
),
lockName
->
tupleId
.
ip_blkid
.
bi_lo
),
lockt
);
lockt
ype
);
#endif
#endif
}
}
#endif
#endif
...
@@ -485,7 +485,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -485,7 +485,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
if
(
LockingIsDisabled
)
if
(
LockingIsDisabled
)
return
(
TRUE
);
return
(
TRUE
);
LOCK_PRINT
(
"Acquire"
,
lockName
,
lockt
);
LOCK_PRINT
(
"Acquire"
,
lockName
,
lockt
ype
);
masterLock
=
ltable
->
ctl
->
masterLock
;
masterLock
=
ltable
->
ctl
->
masterLock
;
SpinAcquire
(
masterLock
);
SpinAcquire
(
masterLock
);
...
@@ -571,7 +571,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -571,7 +571,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
* ----------------
* ----------------
*/
*/
lock
->
nHolding
++
;
lock
->
nHolding
++
;
lock
->
holders
[
lockt
]
++
;
lock
->
holders
[
lockt
ype
]
++
;
/* --------------------
/* --------------------
* If I'm the only one holding a lock, then there
* If I'm the only one holding a lock, then there
...
@@ -582,19 +582,19 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -582,19 +582,19 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
*/
*/
if
(
result
->
nHolding
==
lock
->
nActive
)
if
(
result
->
nHolding
==
lock
->
nActive
)
{
{
result
->
holders
[
lockt
]
++
;
result
->
holders
[
lockt
ype
]
++
;
result
->
nHolding
++
;
result
->
nHolding
++
;
GrantLock
(
lock
,
lockt
);
GrantLock
(
lock
,
lockt
ype
);
SpinRelease
(
masterLock
);
SpinRelease
(
masterLock
);
return
(
TRUE
);
return
(
TRUE
);
}
}
Assert
(
result
->
nHolding
<=
lock
->
nActive
);
Assert
(
result
->
nHolding
<=
lock
->
nActive
);
status
=
LockResolveConflicts
(
ltable
,
lock
,
lockt
,
myXid
);
status
=
LockResolveConflicts
(
ltable
,
lock
,
lockt
ype
,
myXid
);
if
(
status
==
STATUS_OK
)
if
(
status
==
STATUS_OK
)
GrantLock
(
lock
,
lockt
);
GrantLock
(
lock
,
lockt
ype
);
else
if
(
status
==
STATUS_FOUND
)
else
if
(
status
==
STATUS_FOUND
)
{
{
#ifdef USER_LOCKS
#ifdef USER_LOCKS
...
@@ -611,7 +611,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -611,7 +611,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
hash_search
(
xidTable
,
(
Pointer
)
&
item
,
HASH_REMOVE
,
&
found
);
hash_search
(
xidTable
,
(
Pointer
)
&
item
,
HASH_REMOVE
,
&
found
);
}
}
lock
->
nHolding
--
;
lock
->
nHolding
--
;
lock
->
holders
[
lockt
]
--
;
lock
->
holders
[
lockt
ype
]
--
;
SpinRelease
(
masterLock
);
SpinRelease
(
masterLock
);
#ifdef USER_LOCKS_DEBUG
#ifdef USER_LOCKS_DEBUG
elog
(
NOTICE
,
"LockAcquire: user lock failed"
);
elog
(
NOTICE
,
"LockAcquire: user lock failed"
);
...
@@ -619,7 +619,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -619,7 +619,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
return
(
FALSE
);
return
(
FALSE
);
}
}
#endif
#endif
status
=
WaitOnLock
(
ltable
,
tableId
,
lock
,
lockt
);
status
=
WaitOnLock
(
ltable
,
tableId
,
lock
,
lockt
ype
);
XID_PRINT
(
"Someone granted me the lock"
,
result
);
XID_PRINT
(
"Someone granted me the lock"
,
result
);
}
}
...
@@ -647,7 +647,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -647,7 +647,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
int
int
LockResolveConflicts
(
LOCKTAB
*
ltable
,
LockResolveConflicts
(
LOCKTAB
*
ltable
,
LOCK
*
lock
,
LOCK
*
lock
,
LOCKT
lockt
,
LOCKT
YPE
locktype
,
TransactionId
xid
)
TransactionId
xid
)
{
{
XIDLookupEnt
*
result
,
XIDLookupEnt
*
result
,
...
@@ -703,7 +703,7 @@ LockResolveConflicts(LOCKTAB *ltable,
...
@@ -703,7 +703,7 @@ LockResolveConflicts(LOCKTAB *ltable,
* do not continue and share the lock, even if we can. bjm
* do not continue and share the lock, even if we can. bjm
* ------------------------
* ------------------------
*/
*/
int
myprio
=
ltable
->
ctl
->
prio
[
lockt
];
int
myprio
=
ltable
->
ctl
->
prio
[
lockt
ype
];
PROC_QUEUE
*
waitQueue
=
&
(
lock
->
waitProcs
);
PROC_QUEUE
*
waitQueue
=
&
(
lock
->
waitProcs
);
PROC
*
topproc
=
(
PROC
*
)
MAKE_PTR
(
waitQueue
->
links
.
prev
);
PROC
*
topproc
=
(
PROC
*
)
MAKE_PTR
(
waitQueue
->
links
.
prev
);
...
@@ -716,15 +716,15 @@ LockResolveConflicts(LOCKTAB *ltable,
...
@@ -716,15 +716,15 @@ LockResolveConflicts(LOCKTAB *ltable,
* with mine, then I get the lock.
* with mine, then I get the lock.
*
*
* Checking for conflict: lock->mask represents the types of
* Checking for conflict: lock->mask represents the types of
* currently held locks. conflictTable[lockt] has a bit
* currently held locks. conflictTable[lockt
ype
] has a bit
* set for each type of lock that conflicts with mine. Bitwise
* set for each type of lock that conflicts with mine. Bitwise
* compare tells if there is a conflict.
* compare tells if there is a conflict.
* ----------------------------
* ----------------------------
*/
*/
if
(
!
(
ltable
->
ctl
->
conflictTab
[
lockt
]
&
lock
->
mask
))
if
(
!
(
ltable
->
ctl
->
conflictTab
[
lockt
ype
]
&
lock
->
mask
))
{
{
result
->
holders
[
lockt
]
++
;
result
->
holders
[
lockt
ype
]
++
;
result
->
nHolding
++
;
result
->
nHolding
++
;
XID_PRINT
(
"Conflict Resolved: updated xid entry stats"
,
result
);
XID_PRINT
(
"Conflict Resolved: updated xid entry stats"
,
result
);
...
@@ -753,12 +753,12 @@ LockResolveConflicts(LOCKTAB *ltable,
...
@@ -753,12 +753,12 @@ LockResolveConflicts(LOCKTAB *ltable,
* conflict and I have to sleep.
* conflict and I have to sleep.
* ------------------------
* ------------------------
*/
*/
if
(
!
(
ltable
->
ctl
->
conflictTab
[
lockt
]
&
bitmask
))
if
(
!
(
ltable
->
ctl
->
conflictTab
[
lockt
ype
]
&
bitmask
))
{
{
/* no conflict. Get the lock and go on */
/* no conflict. Get the lock and go on */
result
->
holders
[
lockt
]
++
;
result
->
holders
[
lockt
ype
]
++
;
result
->
nHolding
++
;
result
->
nHolding
++
;
XID_PRINT
(
"Conflict Resolved: updated xid entry stats"
,
result
);
XID_PRINT
(
"Conflict Resolved: updated xid entry stats"
,
result
);
...
@@ -771,11 +771,11 @@ LockResolveConflicts(LOCKTAB *ltable,
...
@@ -771,11 +771,11 @@ LockResolveConflicts(LOCKTAB *ltable,
}
}
static
int
static
int
WaitOnLock
(
LOCKTAB
*
ltable
,
LockTableId
tableId
,
LOCK
*
lock
,
LOCKT
lockt
)
WaitOnLock
(
LOCKTAB
*
ltable
,
LockTableId
tableId
,
LOCK
*
lock
,
LOCKT
YPE
locktype
)
{
{
PROC_QUEUE
*
waitQueue
=
&
(
lock
->
waitProcs
);
PROC_QUEUE
*
waitQueue
=
&
(
lock
->
waitProcs
);
int
prio
=
ltable
->
ctl
->
prio
[
lockt
];
int
prio
=
ltable
->
ctl
->
prio
[
lockt
ype
];
/*
/*
* the waitqueue is ordered by priority. I insert myself according to
* the waitqueue is ordered by priority. I insert myself according to
...
@@ -785,10 +785,10 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
...
@@ -785,10 +785,10 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
* synchronization for this queue. That will not be true if/when
* synchronization for this queue. That will not be true if/when
* people can be deleted from the queue by a SIGINT or something.
* people can be deleted from the queue by a SIGINT or something.
*/
*/
LOCK_DUMP_AUX
(
"WaitOnLock: sleeping on lock"
,
lock
,
lockt
);
LOCK_DUMP_AUX
(
"WaitOnLock: sleeping on lock"
,
lock
,
lockt
ype
);
if
(
ProcSleep
(
waitQueue
,
if
(
ProcSleep
(
waitQueue
,
ltable
->
ctl
->
masterLock
,
ltable
->
ctl
->
masterLock
,
lockt
,
lockt
ype
,
prio
,
prio
,
lock
)
!=
NO_ERROR
)
lock
)
!=
NO_ERROR
)
{
{
...
@@ -799,13 +799,13 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
...
@@ -799,13 +799,13 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
* -------------------
* -------------------
*/
*/
lock
->
nHolding
--
;
lock
->
nHolding
--
;
lock
->
holders
[
lockt
]
--
;
lock
->
holders
[
lockt
ype
]
--
;
LOCK_DUMP_AUX
(
"WaitOnLock: aborting on lock"
,
lock
,
lockt
);
LOCK_DUMP_AUX
(
"WaitOnLock: aborting on lock"
,
lock
,
lockt
ype
);
SpinRelease
(
ltable
->
ctl
->
masterLock
);
SpinRelease
(
ltable
->
ctl
->
masterLock
);
elog
(
ERROR
,
"WaitOnLock: error on wakeup - Aborting this transaction"
);
elog
(
ERROR
,
"WaitOnLock: error on wakeup - Aborting this transaction"
);
}
}
LOCK_DUMP_AUX
(
"WaitOnLock: wakeup on lock"
,
lock
,
lockt
);
LOCK_DUMP_AUX
(
"WaitOnLock: wakeup on lock"
,
lock
,
lockt
ype
);
return
(
STATUS_OK
);
return
(
STATUS_OK
);
}
}
...
@@ -820,7 +820,7 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
...
@@ -820,7 +820,7 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
* come along and request the lock).
* come along and request the lock).
*/
*/
bool
bool
LockRelease
(
LockTableId
tableId
,
LOCKTAG
*
lockName
,
LOCKT
lockt
)
LockRelease
(
LockTableId
tableId
,
LOCKTAG
*
lockName
,
LOCKT
YPE
locktype
)
{
{
LOCK
*
lock
=
NULL
;
LOCK
*
lock
=
NULL
;
SPINLOCK
masterLock
;
SPINLOCK
masterLock
;
...
@@ -843,7 +843,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -843,7 +843,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
lockName
->
tupleId
.
ip_posid
,
lockName
->
tupleId
.
ip_posid
,
((
lockName
->
tupleId
.
ip_blkid
.
bi_hi
<<
16
)
+
((
lockName
->
tupleId
.
ip_blkid
.
bi_hi
<<
16
)
+
lockName
->
tupleId
.
ip_blkid
.
bi_lo
),
lockName
->
tupleId
.
ip_blkid
.
bi_lo
),
lockt
);
lockt
ype
);
#endif
#endif
}
}
#endif
#endif
...
@@ -859,7 +859,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -859,7 +859,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
if
(
LockingIsDisabled
)
if
(
LockingIsDisabled
)
return
(
TRUE
);
return
(
TRUE
);
LOCK_PRINT
(
"Release"
,
lockName
,
lockt
);
LOCK_PRINT
(
"Release"
,
lockName
,
lockt
ype
);
masterLock
=
ltable
->
ctl
->
masterLock
;
masterLock
=
ltable
->
ctl
->
masterLock
;
xidTable
=
ltable
->
xidHash
;
xidTable
=
ltable
->
xidHash
;
...
@@ -919,9 +919,9 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -919,9 +919,9 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
* fix the general lock stats
* fix the general lock stats
*/
*/
lock
->
nHolding
--
;
lock
->
nHolding
--
;
lock
->
holders
[
lockt
]
--
;
lock
->
holders
[
lockt
ype
]
--
;
lock
->
nActive
--
;
lock
->
nActive
--
;
lock
->
activeHolders
[
lockt
]
--
;
lock
->
activeHolders
[
lockt
ype
]
--
;
Assert
(
lock
->
nActive
>=
0
);
Assert
(
lock
->
nActive
>=
0
);
...
@@ -992,7 +992,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -992,7 +992,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
* now check to see if I have any private locks. If I do, decrement
* now check to see if I have any private locks. If I do, decrement
* the counts associated with them.
* the counts associated with them.
*/
*/
result
->
holders
[
lockt
]
--
;
result
->
holders
[
lockt
ype
]
--
;
result
->
nHolding
--
;
result
->
nHolding
--
;
XID_PRINT
(
"LockRelease updated xid stats"
,
result
);
XID_PRINT
(
"LockRelease updated xid stats"
,
result
);
...
@@ -1038,9 +1038,9 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -1038,9 +1038,9 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
* fix the general lock stats
* fix the general lock stats
*/
*/
lock
->
nHolding
--
;
lock
->
nHolding
--
;
lock
->
holders
[
lockt
]
--
;
lock
->
holders
[
lockt
ype
]
--
;
lock
->
nActive
--
;
lock
->
nActive
--
;
lock
->
activeHolders
[
lockt
]
--
;
lock
->
activeHolders
[
lockt
ype
]
--
;
Assert
(
lock
->
nActive
>=
0
);
Assert
(
lock
->
nActive
>=
0
);
...
@@ -1069,10 +1069,10 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -1069,10 +1069,10 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
* with the remaining locks.
* with the remaining locks.
* --------------------------
* --------------------------
*/
*/
if
(
!
(
lock
->
activeHolders
[
lockt
]))
if
(
!
(
lock
->
activeHolders
[
lockt
ype
]))
{
{
/* change the conflict mask. No more of this lock type. */
/* change the conflict mask. No more of this lock type. */
lock
->
mask
&=
BITS_OFF
[
lockt
];
lock
->
mask
&=
BITS_OFF
[
lockt
ype
];
}
}
if
(
wakeupNeeded
)
if
(
wakeupNeeded
)
...
@@ -1095,11 +1095,11 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
...
@@ -1095,11 +1095,11 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
* the new lock holder.
* the new lock holder.
*/
*/
void
void
GrantLock
(
LOCK
*
lock
,
LOCKT
lockt
)
GrantLock
(
LOCK
*
lock
,
LOCKT
YPE
locktype
)
{
{
lock
->
nActive
++
;
lock
->
nActive
++
;
lock
->
activeHolders
[
lockt
]
++
;
lock
->
activeHolders
[
lockt
ype
]
++
;
lock
->
mask
|=
BITS_ON
[
lockt
];
lock
->
mask
|=
BITS_ON
[
lockt
ype
];
}
}
#ifdef USER_LOCKS
#ifdef USER_LOCKS
...
...
src/backend/storage/lmgr/multi.c
View file @
f21fa6a7
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.1
7 1998/06/27 04:53:38
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.1
8 1998/06/28 21:17:35
momjian Exp $
*
*
* NOTES:
* NOTES:
* (1) The lock.c module assumes that the caller here is doing
* (1) The lock.c module assumes that the caller here is doing
...
@@ -30,10 +30,10 @@
...
@@ -30,10 +30,10 @@
#include "miscadmin.h"
/* MyDatabaseId */
#include "miscadmin.h"
/* MyDatabaseId */
static
bool
static
bool
MultiAcquire
(
LockTableId
tableId
,
LOCKTAG
*
tag
,
LOCKT
lockt
,
MultiAcquire
(
LockTableId
tableId
,
LOCKTAG
*
tag
,
LOCKT
YPE
locktype
,
PG_LOCK_LEVEL
level
);
PG_LOCK_LEVEL
level
);
static
bool
static
bool
MultiRelease
(
LockTableId
tableId
,
LOCKTAG
*
tag
,
LOCKT
lockt
,
MultiRelease
(
LockTableId
tableId
,
LOCKTAG
*
tag
,
LOCKT
YPE
locktype
,
PG_LOCK_LEVEL
level
);
PG_LOCK_LEVEL
level
);
/*
/*
...
@@ -111,7 +111,7 @@ InitMultiLevelLocks()
...
@@ -111,7 +111,7 @@ InitMultiLevelLocks()
* Returns: TRUE if the lock can be set, FALSE otherwise.
* Returns: TRUE if the lock can be set, FALSE otherwise.
*/
*/
bool
bool
MultiLockReln
(
LockInfo
linfo
,
LOCKT
lockt
)
MultiLockReln
(
LockInfo
linfo
,
LOCKT
YPE
locktype
)
{
{
LOCKTAG
tag
;
LOCKTAG
tag
;
...
@@ -122,7 +122,7 @@ MultiLockReln(LockInfo linfo, LOCKT lockt)
...
@@ -122,7 +122,7 @@ MultiLockReln(LockInfo linfo, LOCKT lockt)
MemSet
(
&
tag
,
0
,
sizeof
(
tag
));
MemSet
(
&
tag
,
0
,
sizeof
(
tag
));
tag
.
relId
=
linfo
->
lRelId
.
relId
;
tag
.
relId
=
linfo
->
lRelId
.
relId
;
tag
.
dbId
=
linfo
->
lRelId
.
dbId
;
tag
.
dbId
=
linfo
->
lRelId
.
dbId
;
return
(
MultiAcquire
(
MultiTableId
,
&
tag
,
lockt
,
RELN_LEVEL
));
return
(
MultiAcquire
(
MultiTableId
,
&
tag
,
lockt
ype
,
RELN_LEVEL
));
}
}
/*
/*
...
@@ -134,7 +134,7 @@ MultiLockReln(LockInfo linfo, LOCKT lockt)
...
@@ -134,7 +134,7 @@ MultiLockReln(LockInfo linfo, LOCKT lockt)
* at the page and relation level.
* at the page and relation level.
*/
*/
bool
bool
MultiLockTuple
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
lockt
)
MultiLockTuple
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
YPE
locktype
)
{
{
LOCKTAG
tag
;
LOCKTAG
tag
;
...
@@ -149,14 +149,14 @@ MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
...
@@ -149,14 +149,14 @@ MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
/* not locking any valid Tuple, just the page */
/* not locking any valid Tuple, just the page */
tag
.
tupleId
=
*
tidPtr
;
tag
.
tupleId
=
*
tidPtr
;
return
(
MultiAcquire
(
MultiTableId
,
&
tag
,
lockt
,
TUPLE_LEVEL
));
return
(
MultiAcquire
(
MultiTableId
,
&
tag
,
lockt
ype
,
TUPLE_LEVEL
));
}
}
/*
/*
* same as above at page level
* same as above at page level
*/
*/
bool
bool
MultiLockPage
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
lockt
)
MultiLockPage
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
YPE
locktype
)
{
{
LOCKTAG
tag
;
LOCKTAG
tag
;
...
@@ -179,7 +179,7 @@ MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
...
@@ -179,7 +179,7 @@ MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
tag
.
relId
=
linfo
->
lRelId
.
relId
;
tag
.
relId
=
linfo
->
lRelId
.
relId
;
tag
.
dbId
=
linfo
->
lRelId
.
dbId
;
tag
.
dbId
=
linfo
->
lRelId
.
dbId
;
BlockIdCopy
(
&
(
tag
.
tupleId
.
ip_blkid
),
&
(
tidPtr
->
ip_blkid
));
BlockIdCopy
(
&
(
tag
.
tupleId
.
ip_blkid
),
&
(
tidPtr
->
ip_blkid
));
return
(
MultiAcquire
(
MultiTableId
,
&
tag
,
lockt
,
PAGE_LEVEL
));
return
(
MultiAcquire
(
MultiTableId
,
&
tag
,
lockt
ype
,
PAGE_LEVEL
));
}
}
/*
/*
...
@@ -191,10 +191,10 @@ MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
...
@@ -191,10 +191,10 @@ MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
static
bool
static
bool
MultiAcquire
(
LockTableId
tableId
,
MultiAcquire
(
LockTableId
tableId
,
LOCKTAG
*
tag
,
LOCKTAG
*
tag
,
LOCKT
lockt
,
LOCKT
YPE
locktype
,
PG_LOCK_LEVEL
level
)
PG_LOCK_LEVEL
level
)
{
{
LOCKT
locks
[
N_LEVELS
];
LOCKT
YPE
locks
[
N_LEVELS
];
int
i
,
int
i
,
status
;
status
;
LOCKTAG
xxTag
,
LOCKTAG
xxTag
,
...
@@ -213,19 +213,19 @@ MultiAcquire(LockTableId tableId,
...
@@ -213,19 +213,19 @@ MultiAcquire(LockTableId tableId,
switch
(
level
)
switch
(
level
)
{
{
case
RELN_LEVEL
:
case
RELN_LEVEL
:
locks
[
0
]
=
lockt
;
locks
[
0
]
=
lockt
ype
;
locks
[
1
]
=
NO_LOCK
;
locks
[
1
]
=
NO_LOCK
;
locks
[
2
]
=
NO_LOCK
;
locks
[
2
]
=
NO_LOCK
;
break
;
break
;
case
PAGE_LEVEL
:
case
PAGE_LEVEL
:
locks
[
0
]
=
lockt
+
INTENT
;
locks
[
0
]
=
lockt
ype
+
INTENT
;
locks
[
1
]
=
lockt
;
locks
[
1
]
=
lockt
ype
;
locks
[
2
]
=
NO_LOCK
;
locks
[
2
]
=
NO_LOCK
;
break
;
break
;
case
TUPLE_LEVEL
:
case
TUPLE_LEVEL
:
locks
[
0
]
=
lockt
+
INTENT
;
locks
[
0
]
=
lockt
ype
+
INTENT
;
locks
[
1
]
=
lockt
+
INTENT
;
locks
[
1
]
=
lockt
ype
+
INTENT
;
locks
[
2
]
=
lockt
;
locks
[
2
]
=
lockt
ype
;
break
;
break
;
default:
default:
elog
(
ERROR
,
"MultiAcquire: bad lock level"
);
elog
(
ERROR
,
"MultiAcquire: bad lock level"
);
...
@@ -285,7 +285,7 @@ MultiAcquire(LockTableId tableId,
...
@@ -285,7 +285,7 @@ MultiAcquire(LockTableId tableId,
* the last level lock we successfully acquired
* the last level lock we successfully acquired
*/
*/
retStatus
=
FALSE
;
retStatus
=
FALSE
;
MultiRelease
(
tableId
,
tag
,
lockt
,
i
);
MultiRelease
(
tableId
,
tag
,
lockt
ype
,
i
);
/* now leave the loop. Don't try for any more locks */
/* now leave the loop. Don't try for any more locks */
break
;
break
;
}
}
...
@@ -300,7 +300,7 @@ MultiAcquire(LockTableId tableId,
...
@@ -300,7 +300,7 @@ MultiAcquire(LockTableId tableId,
*/
*/
#ifdef NOT_USED
#ifdef NOT_USED
bool
bool
MultiReleasePage
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
lockt
)
MultiReleasePage
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
YPE
locktype
)
{
{
LOCKTAG
tag
;
LOCKTAG
tag
;
...
@@ -316,7 +316,7 @@ MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
...
@@ -316,7 +316,7 @@ MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
tag
.
dbId
=
linfo
->
lRelId
.
dbId
;
tag
.
dbId
=
linfo
->
lRelId
.
dbId
;
BlockIdCopy
(
&
(
tag
.
tupleId
.
ip_blkid
),
&
(
tidPtr
->
ip_blkid
));
BlockIdCopy
(
&
(
tag
.
tupleId
.
ip_blkid
),
&
(
tidPtr
->
ip_blkid
));
return
(
MultiRelease
(
MultiTableId
,
&
tag
,
lockt
,
PAGE_LEVEL
));
return
(
MultiRelease
(
MultiTableId
,
&
tag
,
lockt
ype
,
PAGE_LEVEL
));
}
}
#endif
#endif
...
@@ -326,7 +326,7 @@ MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
...
@@ -326,7 +326,7 @@ MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
* ------------------
* ------------------
*/
*/
bool
bool
MultiReleaseReln
(
LockInfo
linfo
,
LOCKT
lockt
)
MultiReleaseReln
(
LockInfo
linfo
,
LOCKT
YPE
locktype
)
{
{
LOCKTAG
tag
;
LOCKTAG
tag
;
...
@@ -340,7 +340,7 @@ MultiReleaseReln(LockInfo linfo, LOCKT lockt)
...
@@ -340,7 +340,7 @@ MultiReleaseReln(LockInfo linfo, LOCKT lockt)
tag
.
relId
=
linfo
->
lRelId
.
relId
;
tag
.
relId
=
linfo
->
lRelId
.
relId
;
tag
.
dbId
=
linfo
->
lRelId
.
dbId
;
tag
.
dbId
=
linfo
->
lRelId
.
dbId
;
return
(
MultiRelease
(
MultiTableId
,
&
tag
,
lockt
,
RELN_LEVEL
));
return
(
MultiRelease
(
MultiTableId
,
&
tag
,
lockt
ype
,
RELN_LEVEL
));
}
}
/*
/*
...
@@ -351,10 +351,10 @@ MultiReleaseReln(LockInfo linfo, LOCKT lockt)
...
@@ -351,10 +351,10 @@ MultiReleaseReln(LockInfo linfo, LOCKT lockt)
static
bool
static
bool
MultiRelease
(
LockTableId
tableId
,
MultiRelease
(
LockTableId
tableId
,
LOCKTAG
*
tag
,
LOCKTAG
*
tag
,
LOCKT
lockt
,
LOCKT
YPE
locktype
,
PG_LOCK_LEVEL
level
)
PG_LOCK_LEVEL
level
)
{
{
LOCKT
locks
[
N_LEVELS
];
LOCKT
YPE
locks
[
N_LEVELS
];
int
i
,
int
i
,
status
;
status
;
LOCKTAG
xxTag
,
LOCKTAG
xxTag
,
...
@@ -366,22 +366,22 @@ MultiRelease(LockTableId tableId,
...
@@ -366,22 +366,22 @@ MultiRelease(LockTableId tableId,
switch
(
level
)
switch
(
level
)
{
{
case
RELN_LEVEL
:
case
RELN_LEVEL
:
locks
[
0
]
=
lockt
;
locks
[
0
]
=
lockt
ype
;
locks
[
1
]
=
NO_LOCK
;
locks
[
1
]
=
NO_LOCK
;
locks
[
2
]
=
NO_LOCK
;
locks
[
2
]
=
NO_LOCK
;
break
;
break
;
case
PAGE_LEVEL
:
case
PAGE_LEVEL
:
locks
[
0
]
=
lockt
+
INTENT
;
locks
[
0
]
=
lockt
ype
+
INTENT
;
locks
[
1
]
=
lockt
;
locks
[
1
]
=
lockt
ype
;
locks
[
2
]
=
NO_LOCK
;
locks
[
2
]
=
NO_LOCK
;
break
;
break
;
case
TUPLE_LEVEL
:
case
TUPLE_LEVEL
:
locks
[
0
]
=
lockt
+
INTENT
;
locks
[
0
]
=
lockt
ype
+
INTENT
;
locks
[
1
]
=
lockt
+
INTENT
;
locks
[
1
]
=
lockt
ype
+
INTENT
;
locks
[
2
]
=
lockt
;
locks
[
2
]
=
lockt
ype
;
break
;
break
;
default:
default:
elog
(
ERROR
,
"MultiRelease: bad lockt"
);
elog
(
ERROR
,
"MultiRelease: bad lockt
ype
"
);
}
}
/*
/*
...
...
src/backend/storage/lmgr/single.c
View file @
f21fa6a7
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/single.c,v 1.
5 1997/09/18 20:21:40
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/single.c,v 1.
6 1998/06/28 21:17:35
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
* Returns: TRUE if the lock can be set, FALSE otherwise.
* Returns: TRUE if the lock can be set, FALSE otherwise.
*/
*/
bool
bool
SingleLockReln
(
LockInfo
linfo
,
LOCKT
lockt
,
int
action
)
SingleLockReln
(
LockInfo
linfo
,
LOCKT
YPE
locktype
,
int
action
)
{
{
LOCKTAG
tag
;
LOCKTAG
tag
;
...
@@ -47,9 +47,9 @@ SingleLockReln(LockInfo linfo, LOCKT lockt, int action)
...
@@ -47,9 +47,9 @@ SingleLockReln(LockInfo linfo, LOCKT lockt, int action)
tag
.
tupleId
.
ip_posid
=
InvalidOffsetNumber
;
tag
.
tupleId
.
ip_posid
=
InvalidOffsetNumber
;
if
(
action
==
UNLOCK
)
if
(
action
==
UNLOCK
)
return
(
LockRelease
(
MultiTableId
,
&
tag
,
lockt
));
return
(
LockRelease
(
MultiTableId
,
&
tag
,
lockt
ype
));
else
else
return
(
LockAcquire
(
MultiTableId
,
&
tag
,
lockt
));
return
(
LockAcquire
(
MultiTableId
,
&
tag
,
lockt
ype
));
}
}
/*
/*
...
@@ -63,7 +63,7 @@ SingleLockReln(LockInfo linfo, LOCKT lockt, int action)
...
@@ -63,7 +63,7 @@ SingleLockReln(LockInfo linfo, LOCKT lockt, int action)
bool
bool
SingleLockPage
(
LockInfo
linfo
,
SingleLockPage
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
ItemPointer
tidPtr
,
LOCKT
lockt
,
LOCKT
YPE
locktype
,
int
action
)
int
action
)
{
{
LOCKTAG
tag
;
LOCKTAG
tag
;
...
@@ -80,7 +80,7 @@ SingleLockPage(LockInfo linfo,
...
@@ -80,7 +80,7 @@ SingleLockPage(LockInfo linfo,
if
(
action
==
UNLOCK
)
if
(
action
==
UNLOCK
)
return
(
LockRelease
(
MultiTableId
,
&
tag
,
lockt
));
return
(
LockRelease
(
MultiTableId
,
&
tag
,
lockt
ype
));
else
else
return
(
LockAcquire
(
MultiTableId
,
&
tag
,
lockt
));
return
(
LockAcquire
(
MultiTableId
,
&
tag
,
lockt
ype
));
}
}
src/include/storage/lmgr.h
View file @
f21fa6a7
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: lmgr.h,v 1.1
0 1998/02/26 04:43:27
momjian Exp $
* $Id: lmgr.h,v 1.1
1 1998/06/28 21:17:35
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -72,10 +72,10 @@ extern void RelationSetWIntentLock(Relation relation);
...
@@ -72,10 +72,10 @@ extern void RelationSetWIntentLock(Relation relation);
extern
void
RelationUnsetWIntentLock
(
Relation
relation
);
extern
void
RelationUnsetWIntentLock
(
Relation
relation
);
/* single.c */
/* single.c */
extern
bool
SingleLockReln
(
LockInfo
linfo
,
LOCKT
lockt
,
int
action
);
extern
bool
SingleLockReln
(
LockInfo
linfo
,
LOCKT
YPE
locktype
,
int
action
);
extern
bool
extern
bool
SingleLockPage
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
SingleLockPage
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
lockt
,
int
action
);
LOCKT
YPE
locktype
,
int
action
);
/* proc.c */
/* proc.c */
extern
void
InitProcGlobal
(
IPCKey
key
);
extern
void
InitProcGlobal
(
IPCKey
key
);
...
...
src/include/storage/lock.h
View file @
f21fa6a7
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: lock.h,v 1.1
3 1998/06/26 01:58:46
momjian Exp $
* $Id: lock.h,v 1.1
4 1998/06/28 21:17:35
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -37,7 +37,7 @@ typedef int MASK;
...
@@ -37,7 +37,7 @@ typedef int MASK;
#define NLOCKENTS NLOCKS_PER_XACT*NBACKENDS
#define NLOCKENTS NLOCKS_PER_XACT*NBACKENDS
typedef
int
LOCK_TYPE
;
typedef
int
LOCK_TYPE
;
typedef
int
LOCKT
;
typedef
int
LOCKT
YPE
;
typedef
int
LockTableId
;
typedef
int
LockTableId
;
/* MAX_LOCKTYPES cannot be larger than the bits in MASK */
/* MAX_LOCKTYPES cannot be larger than the bits in MASK */
...
@@ -190,10 +190,10 @@ typedef struct Lock
...
@@ -190,10 +190,10 @@ typedef struct Lock
#define LockGetLock_nHolders(l) l->nHolders
#define LockGetLock_nHolders(l) l->nHolders
#define LockDecrWaitHolders(lock, lockt) \
#define LockDecrWaitHolders(lock, lockt
ype
) \
( \
( \
lock->nHolding--, \
lock->nHolding--, \
lock->holders[lockt]-- \
lock->holders[lockt
ype
]-- \
)
)
#define LockLockTable() SpinAcquire(LockMgrLock);
#define LockLockTable() SpinAcquire(LockMgrLock);
...
@@ -209,12 +209,12 @@ extern void LockDisable(int status);
...
@@ -209,12 +209,12 @@ extern void LockDisable(int status);
extern
LockTableId
extern
LockTableId
LockTableInit
(
char
*
tabName
,
MASK
*
conflictsP
,
int
*
prioP
,
LockTableInit
(
char
*
tabName
,
MASK
*
conflictsP
,
int
*
prioP
,
int
ntypes
);
int
ntypes
);
extern
bool
LockAcquire
(
LockTableId
tableId
,
LOCKTAG
*
lockName
,
LOCKT
lockt
);
extern
bool
LockAcquire
(
LockTableId
tableId
,
LOCKTAG
*
lockName
,
LOCKT
YPE
locktype
);
extern
int
extern
int
LockResolveConflicts
(
LOCKTAB
*
ltable
,
LOCK
*
lock
,
LOCKT
lockt
,
LockResolveConflicts
(
LOCKTAB
*
ltable
,
LOCK
*
lock
,
LOCKT
YPE
locktype
,
TransactionId
xid
);
TransactionId
xid
);
extern
bool
LockRelease
(
LockTableId
tableId
,
LOCKTAG
*
lockName
,
LOCKT
lockt
);
extern
bool
LockRelease
(
LockTableId
tableId
,
LOCKTAG
*
lockName
,
LOCKT
YPE
locktype
);
extern
void
GrantLock
(
LOCK
*
lock
,
LOCKT
lockt
);
extern
void
GrantLock
(
LOCK
*
lock
,
LOCKT
YPE
locktype
);
extern
bool
LockReleaseAll
(
LockTableId
tableId
,
SHM_QUEUE
*
lockQueue
);
extern
bool
LockReleaseAll
(
LockTableId
tableId
,
SHM_QUEUE
*
lockQueue
);
extern
int
LockShmemSize
(
void
);
extern
int
LockShmemSize
(
void
);
extern
bool
LockingDisabled
(
void
);
extern
bool
LockingDisabled
(
void
);
...
...
src/include/storage/multilev.h
View file @
f21fa6a7
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: multilev.h,v 1.
8 1998/06/26 19:57:50
momjian Exp $
* $Id: multilev.h,v 1.
9 1998/06/28 21:17:36
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -50,9 +50,9 @@ extern LockTableId ShortTermTableId;
...
@@ -50,9 +50,9 @@ extern LockTableId ShortTermTableId;
* function prototypes
* function prototypes
*/
*/
extern
LockTableId
InitMultiLevelLocks
(
void
);
extern
LockTableId
InitMultiLevelLocks
(
void
);
extern
bool
MultiLockReln
(
LockInfo
linfo
,
LOCKT
lockt
);
extern
bool
MultiLockReln
(
LockInfo
linfo
,
LOCKT
YPE
locktype
);
extern
bool
MultiLockTuple
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
lockt
);
extern
bool
MultiLockTuple
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
YPE
locktype
);
extern
bool
MultiLockPage
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
lockt
);
extern
bool
MultiLockPage
(
LockInfo
linfo
,
ItemPointer
tidPtr
,
LOCKT
YPE
locktype
);
extern
bool
MultiReleaseReln
(
LockInfo
linfo
,
LOCKT
lockt
);
extern
bool
MultiReleaseReln
(
LockInfo
linfo
,
LOCKT
YPE
locktype
);
#endif
/* MULTILEV_H */
#endif
/* MULTILEV_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment