mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Rename lockt to locktype and rename LOCKT to LOCKTYPE.
This commit is contained in:
parent
cff7e20467
commit
f21fa6a773
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.30 1998/06/27 15:47:46 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.31 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 @@
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock,
|
WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock,
|
||||||
LOCKT lockt);
|
LOCKTYPE locktype);
|
||||||
|
|
||||||
/*#define LOCK_MGR_DEBUG*/
|
/*#define LOCK_MGR_DEBUG*/
|
||||||
|
|
||||||
@ -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 locktype 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)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
|
LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKTYPE locktype)
|
||||||
{
|
{
|
||||||
XIDLookupEnt *result,
|
XIDLookupEnt *result,
|
||||||
item;
|
item;
|
||||||
@ -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);
|
locktype);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -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, locktype);
|
||||||
masterLock = ltable->ctl->masterLock;
|
masterLock = ltable->ctl->masterLock;
|
||||||
|
|
||||||
SpinAcquire(masterLock);
|
SpinAcquire(masterLock);
|
||||||
@ -571,7 +571,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
lock->nHolding++;
|
lock->nHolding++;
|
||||||
lock->holders[lockt]++;
|
lock->holders[locktype]++;
|
||||||
|
|
||||||
/* --------------------
|
/* --------------------
|
||||||
* 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)
|
|||||||
*/
|
*/
|
||||||
if (result->nHolding == lock->nActive)
|
if (result->nHolding == lock->nActive)
|
||||||
{
|
{
|
||||||
result->holders[lockt]++;
|
result->holders[locktype]++;
|
||||||
result->nHolding++;
|
result->nHolding++;
|
||||||
GrantLock(lock, lockt);
|
GrantLock(lock, locktype);
|
||||||
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, locktype, myXid);
|
||||||
|
|
||||||
if (status == STATUS_OK)
|
if (status == STATUS_OK)
|
||||||
GrantLock(lock, lockt);
|
GrantLock(lock, locktype);
|
||||||
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)
|
|||||||
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[locktype]--;
|
||||||
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)
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
status = WaitOnLock(ltable, tableId, lock, lockt);
|
status = WaitOnLock(ltable, tableId, lock, locktype);
|
||||||
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)
|
|||||||
int
|
int
|
||||||
LockResolveConflicts(LOCKTAB *ltable,
|
LockResolveConflicts(LOCKTAB *ltable,
|
||||||
LOCK *lock,
|
LOCK *lock,
|
||||||
LOCKT lockt,
|
LOCKTYPE locktype,
|
||||||
TransactionId xid)
|
TransactionId xid)
|
||||||
{
|
{
|
||||||
XIDLookupEnt *result,
|
XIDLookupEnt *result,
|
||||||
@ -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[locktype];
|
||||||
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,
|
|||||||
* 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[locktype] 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[locktype] & lock->mask))
|
||||||
{
|
{
|
||||||
|
|
||||||
result->holders[lockt]++;
|
result->holders[locktype]++;
|
||||||
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,
|
|||||||
* conflict and I have to sleep.
|
* conflict and I have to sleep.
|
||||||
* ------------------------
|
* ------------------------
|
||||||
*/
|
*/
|
||||||
if (!(ltable->ctl->conflictTab[lockt] & bitmask))
|
if (!(ltable->ctl->conflictTab[locktype] & bitmask))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* no conflict. Get the lock and go on */
|
/* no conflict. Get the lock and go on */
|
||||||
|
|
||||||
result->holders[lockt]++;
|
result->holders[locktype]++;
|
||||||
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,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
|
WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKTYPE locktype)
|
||||||
{
|
{
|
||||||
PROC_QUEUE *waitQueue = &(lock->waitProcs);
|
PROC_QUEUE *waitQueue = &(lock->waitProcs);
|
||||||
|
|
||||||
int prio = ltable->ctl->prio[lockt];
|
int prio = ltable->ctl->prio[locktype];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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)
|
|||||||
* 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, locktype);
|
||||||
if (ProcSleep(waitQueue,
|
if (ProcSleep(waitQueue,
|
||||||
ltable->ctl->masterLock,
|
ltable->ctl->masterLock,
|
||||||
lockt,
|
locktype,
|
||||||
prio,
|
prio,
|
||||||
lock) != NO_ERROR)
|
lock) != NO_ERROR)
|
||||||
{
|
{
|
||||||
@ -799,13 +799,13 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
|
|||||||
* -------------------
|
* -------------------
|
||||||
*/
|
*/
|
||||||
lock->nHolding--;
|
lock->nHolding--;
|
||||||
lock->holders[lockt]--;
|
lock->holders[locktype]--;
|
||||||
LOCK_DUMP_AUX("WaitOnLock: aborting on lock", lock, lockt);
|
LOCK_DUMP_AUX("WaitOnLock: aborting on lock", lock, locktype);
|
||||||
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, locktype);
|
||||||
return (STATUS_OK);
|
return (STATUS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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, LOCKTYPE locktype)
|
||||||
{
|
{
|
||||||
LOCK *lock = NULL;
|
LOCK *lock = NULL;
|
||||||
SPINLOCK masterLock;
|
SPINLOCK masterLock;
|
||||||
@ -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);
|
locktype);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -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, locktype);
|
||||||
|
|
||||||
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)
|
|||||||
* fix the general lock stats
|
* fix the general lock stats
|
||||||
*/
|
*/
|
||||||
lock->nHolding--;
|
lock->nHolding--;
|
||||||
lock->holders[lockt]--;
|
lock->holders[locktype]--;
|
||||||
lock->nActive--;
|
lock->nActive--;
|
||||||
lock->activeHolders[lockt]--;
|
lock->activeHolders[locktype]--;
|
||||||
|
|
||||||
Assert(lock->nActive >= 0);
|
Assert(lock->nActive >= 0);
|
||||||
|
|
||||||
@ -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[locktype]--;
|
||||||
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)
|
|||||||
* fix the general lock stats
|
* fix the general lock stats
|
||||||
*/
|
*/
|
||||||
lock->nHolding--;
|
lock->nHolding--;
|
||||||
lock->holders[lockt]--;
|
lock->holders[locktype]--;
|
||||||
lock->nActive--;
|
lock->nActive--;
|
||||||
lock->activeHolders[lockt]--;
|
lock->activeHolders[locktype]--;
|
||||||
|
|
||||||
Assert(lock->nActive >= 0);
|
Assert(lock->nActive >= 0);
|
||||||
|
|
||||||
@ -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[locktype]))
|
||||||
{
|
{
|
||||||
/* 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[locktype];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wakeupNeeded)
|
if (wakeupNeeded)
|
||||||
@ -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, LOCKTYPE locktype)
|
||||||
{
|
{
|
||||||
lock->nActive++;
|
lock->nActive++;
|
||||||
lock->activeHolders[lockt]++;
|
lock->activeHolders[locktype]++;
|
||||||
lock->mask |= BITS_ON[lockt];
|
lock->mask |= BITS_ON[locktype];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USER_LOCKS
|
#ifdef USER_LOCKS
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.17 1998/06/27 04:53:38 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.18 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 @@
|
|||||||
#include "miscadmin.h" /* MyDatabaseId */
|
#include "miscadmin.h" /* MyDatabaseId */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
MultiAcquire(LockTableId tableId, LOCKTAG *tag, LOCKT lockt,
|
MultiAcquire(LockTableId tableId, LOCKTAG *tag, LOCKTYPE 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, LOCKTYPE locktype,
|
||||||
PG_LOCK_LEVEL level);
|
PG_LOCK_LEVEL level);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -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, LOCKTYPE locktype)
|
||||||
{
|
{
|
||||||
LOCKTAG tag;
|
LOCKTAG tag;
|
||||||
|
|
||||||
@ -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, locktype, RELN_LEVEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -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, LOCKTYPE locktype)
|
||||||
{
|
{
|
||||||
LOCKTAG tag;
|
LOCKTAG tag;
|
||||||
|
|
||||||
@ -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, locktype, 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, LOCKTYPE locktype)
|
||||||
{
|
{
|
||||||
LOCKTAG tag;
|
LOCKTAG tag;
|
||||||
|
|
||||||
@ -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, locktype, PAGE_LEVEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -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,
|
LOCKTYPE locktype,
|
||||||
PG_LOCK_LEVEL level)
|
PG_LOCK_LEVEL level)
|
||||||
{
|
{
|
||||||
LOCKT locks[N_LEVELS];
|
LOCKTYPE locks[N_LEVELS];
|
||||||
int i,
|
int i,
|
||||||
status;
|
status;
|
||||||
LOCKTAG xxTag,
|
LOCKTAG xxTag,
|
||||||
@ -213,19 +213,19 @@ MultiAcquire(LockTableId tableId,
|
|||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
case RELN_LEVEL:
|
case RELN_LEVEL:
|
||||||
locks[0] = lockt;
|
locks[0] = locktype;
|
||||||
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] = locktype + INTENT;
|
||||||
locks[1] = lockt;
|
locks[1] = locktype;
|
||||||
locks[2] = NO_LOCK;
|
locks[2] = NO_LOCK;
|
||||||
break;
|
break;
|
||||||
case TUPLE_LEVEL:
|
case TUPLE_LEVEL:
|
||||||
locks[0] = lockt + INTENT;
|
locks[0] = locktype + INTENT;
|
||||||
locks[1] = lockt + INTENT;
|
locks[1] = locktype + INTENT;
|
||||||
locks[2] = lockt;
|
locks[2] = locktype;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(ERROR, "MultiAcquire: bad lock level");
|
elog(ERROR, "MultiAcquire: bad lock level");
|
||||||
@ -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, locktype, 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,
|
|||||||
*/
|
*/
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
bool
|
bool
|
||||||
MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
|
MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKTYPE locktype)
|
||||||
{
|
{
|
||||||
LOCKTAG tag;
|
LOCKTAG tag;
|
||||||
|
|
||||||
@ -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, locktype, PAGE_LEVEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -326,7 +326,7 @@ MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt)
|
|||||||
* ------------------
|
* ------------------
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
MultiReleaseReln(LockInfo linfo, LOCKT lockt)
|
MultiReleaseReln(LockInfo linfo, LOCKTYPE locktype)
|
||||||
{
|
{
|
||||||
LOCKTAG tag;
|
LOCKTAG tag;
|
||||||
|
|
||||||
@ -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, locktype, RELN_LEVEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -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,
|
LOCKTYPE locktype,
|
||||||
PG_LOCK_LEVEL level)
|
PG_LOCK_LEVEL level)
|
||||||
{
|
{
|
||||||
LOCKT locks[N_LEVELS];
|
LOCKTYPE locks[N_LEVELS];
|
||||||
int i,
|
int i,
|
||||||
status;
|
status;
|
||||||
LOCKTAG xxTag,
|
LOCKTAG xxTag,
|
||||||
@ -366,22 +366,22 @@ MultiRelease(LockTableId tableId,
|
|||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
case RELN_LEVEL:
|
case RELN_LEVEL:
|
||||||
locks[0] = lockt;
|
locks[0] = locktype;
|
||||||
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] = locktype + INTENT;
|
||||||
locks[1] = lockt;
|
locks[1] = locktype;
|
||||||
locks[2] = NO_LOCK;
|
locks[2] = NO_LOCK;
|
||||||
break;
|
break;
|
||||||
case TUPLE_LEVEL:
|
case TUPLE_LEVEL:
|
||||||
locks[0] = lockt + INTENT;
|
locks[0] = locktype + INTENT;
|
||||||
locks[1] = lockt + INTENT;
|
locks[1] = locktype + INTENT;
|
||||||
locks[2] = lockt;
|
locks[2] = locktype;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(ERROR, "MultiRelease: bad lockt");
|
elog(ERROR, "MultiRelease: bad locktype");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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 @@
|
|||||||
* 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, LOCKTYPE locktype, int action)
|
||||||
{
|
{
|
||||||
LOCKTAG tag;
|
LOCKTAG tag;
|
||||||
|
|
||||||
@ -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, locktype));
|
||||||
else
|
else
|
||||||
return (LockAcquire(MultiTableId, &tag, lockt));
|
return (LockAcquire(MultiTableId, &tag, locktype));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -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,
|
LOCKTYPE locktype,
|
||||||
int action)
|
int action)
|
||||||
{
|
{
|
||||||
LOCKTAG tag;
|
LOCKTAG tag;
|
||||||
@ -80,7 +80,7 @@ SingleLockPage(LockInfo linfo,
|
|||||||
|
|
||||||
|
|
||||||
if (action == UNLOCK)
|
if (action == UNLOCK)
|
||||||
return (LockRelease(MultiTableId, &tag, lockt));
|
return (LockRelease(MultiTableId, &tag, locktype));
|
||||||
else
|
else
|
||||||
return (LockAcquire(MultiTableId, &tag, lockt));
|
return (LockAcquire(MultiTableId, &tag, locktype));
|
||||||
}
|
}
|
||||||
|
@ -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.10 1998/02/26 04:43:27 momjian Exp $
|
* $Id: lmgr.h,v 1.11 1998/06/28 21:17:35 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -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, LOCKTYPE locktype, int action);
|
||||||
extern bool
|
extern bool
|
||||||
SingleLockPage(LockInfo linfo, ItemPointer tidPtr,
|
SingleLockPage(LockInfo linfo, ItemPointer tidPtr,
|
||||||
LOCKT lockt, int action);
|
LOCKTYPE locktype, int action);
|
||||||
|
|
||||||
/* proc.c */
|
/* proc.c */
|
||||||
extern void InitProcGlobal(IPCKey key);
|
extern void InitProcGlobal(IPCKey key);
|
||||||
|
@ -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.13 1998/06/26 01:58:46 momjian Exp $
|
* $Id: lock.h,v 1.14 1998/06/28 21:17:35 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -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 LOCKTYPE;
|
||||||
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
|
|||||||
|
|
||||||
#define LockGetLock_nHolders(l) l->nHolders
|
#define LockGetLock_nHolders(l) l->nHolders
|
||||||
|
|
||||||
#define LockDecrWaitHolders(lock, lockt) \
|
#define LockDecrWaitHolders(lock, locktype) \
|
||||||
( \
|
( \
|
||||||
lock->nHolding--, \
|
lock->nHolding--, \
|
||||||
lock->holders[lockt]-- \
|
lock->holders[locktype]-- \
|
||||||
)
|
)
|
||||||
|
|
||||||
#define LockLockTable() SpinAcquire(LockMgrLock);
|
#define LockLockTable() SpinAcquire(LockMgrLock);
|
||||||
@ -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, LOCKTYPE locktype);
|
||||||
extern int
|
extern int
|
||||||
LockResolveConflicts(LOCKTAB *ltable, LOCK *lock, LOCKT lockt,
|
LockResolveConflicts(LOCKTAB *ltable, LOCK *lock, LOCKTYPE locktype,
|
||||||
TransactionId xid);
|
TransactionId xid);
|
||||||
extern bool LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt);
|
extern bool LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKTYPE locktype);
|
||||||
extern void GrantLock(LOCK *lock, LOCKT lockt);
|
extern void GrantLock(LOCK *lock, LOCKTYPE 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);
|
||||||
|
@ -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;
|
|||||||
* function prototypes
|
* function prototypes
|
||||||
*/
|
*/
|
||||||
extern LockTableId InitMultiLevelLocks(void);
|
extern LockTableId InitMultiLevelLocks(void);
|
||||||
extern bool MultiLockReln(LockInfo linfo, LOCKT lockt);
|
extern bool MultiLockReln(LockInfo linfo, LOCKTYPE locktype);
|
||||||
extern bool MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt);
|
extern bool MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKTYPE locktype);
|
||||||
extern bool MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt);
|
extern bool MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKTYPE locktype);
|
||||||
extern bool MultiReleaseReln(LockInfo linfo, LOCKT lockt);
|
extern bool MultiReleaseReln(LockInfo linfo, LOCKTYPE locktype);
|
||||||
|
|
||||||
#endif /* MULTILEV_H */
|
#endif /* MULTILEV_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user