Commit c096a804 authored by Peter Eisentraut's avatar Peter Eisentraut

Remove STATUS_FOUND

Replace the solitary use with a bool.
Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/a6f91ead-0ce4-2a34-062b-7ab9813ea308%402ndquadrant.com
parent 38fc0560
...@@ -746,7 +746,7 @@ LockAcquireExtended(const LOCKTAG *locktag, ...@@ -746,7 +746,7 @@ LockAcquireExtended(const LOCKTAG *locktag,
ResourceOwner owner; ResourceOwner owner;
uint32 hashcode; uint32 hashcode;
LWLock *partitionLock; LWLock *partitionLock;
int status; bool found_conflict;
bool log_lock = false; bool log_lock = false;
if (lockmethodid <= 0 || lockmethodid >= lengthof(LockMethods)) if (lockmethodid <= 0 || lockmethodid >= lengthof(LockMethods))
...@@ -979,12 +979,12 @@ LockAcquireExtended(const LOCKTAG *locktag, ...@@ -979,12 +979,12 @@ LockAcquireExtended(const LOCKTAG *locktag,
* (That's last because most complex check.) * (That's last because most complex check.)
*/ */
if (lockMethodTable->conflictTab[lockmode] & lock->waitMask) if (lockMethodTable->conflictTab[lockmode] & lock->waitMask)
status = STATUS_FOUND; found_conflict = true;
else else
status = LockCheckConflicts(lockMethodTable, lockmode, found_conflict = LockCheckConflicts(lockMethodTable, lockmode,
lock, proclock); lock, proclock);
if (status == STATUS_OK) if (!found_conflict)
{ {
/* No conflict with held or previously requested locks */ /* No conflict with held or previously requested locks */
GrantLock(lock, proclock, lockmode); GrantLock(lock, proclock, lockmode);
...@@ -992,8 +992,6 @@ LockAcquireExtended(const LOCKTAG *locktag, ...@@ -992,8 +992,6 @@ LockAcquireExtended(const LOCKTAG *locktag,
} }
else else
{ {
Assert(status == STATUS_FOUND);
/* /*
* We can't acquire the lock immediately. If caller specified no * We can't acquire the lock immediately. If caller specified no
* blocking, remove useless table entries and return * blocking, remove useless table entries and return
...@@ -1330,7 +1328,7 @@ RemoveLocalLock(LOCALLOCK *locallock) ...@@ -1330,7 +1328,7 @@ RemoveLocalLock(LOCALLOCK *locallock)
* LockCheckConflicts -- test whether requested lock conflicts * LockCheckConflicts -- test whether requested lock conflicts
* with those already granted * with those already granted
* *
* Returns STATUS_FOUND if conflict, STATUS_OK if no conflict. * Returns true if conflict, false if no conflict.
* *
* NOTES: * NOTES:
* Here's what makes this complicated: one process's locks don't * Here's what makes this complicated: one process's locks don't
...@@ -1340,7 +1338,7 @@ RemoveLocalLock(LOCALLOCK *locallock) ...@@ -1340,7 +1338,7 @@ RemoveLocalLock(LOCALLOCK *locallock)
* the same group. So, we must subtract off these locks when determining * the same group. So, we must subtract off these locks when determining
* whether the requested new lock conflicts with those already held. * whether the requested new lock conflicts with those already held.
*/ */
int bool
LockCheckConflicts(LockMethod lockMethodTable, LockCheckConflicts(LockMethod lockMethodTable,
LOCKMODE lockmode, LOCKMODE lockmode,
LOCK *lock, LOCK *lock,
...@@ -1367,7 +1365,7 @@ LockCheckConflicts(LockMethod lockMethodTable, ...@@ -1367,7 +1365,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
if (!(conflictMask & lock->grantMask)) if (!(conflictMask & lock->grantMask))
{ {
PROCLOCK_PRINT("LockCheckConflicts: no conflict", proclock); PROCLOCK_PRINT("LockCheckConflicts: no conflict", proclock);
return STATUS_OK; return false;
} }
/* /*
...@@ -1393,7 +1391,7 @@ LockCheckConflicts(LockMethod lockMethodTable, ...@@ -1393,7 +1391,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
if (totalConflictsRemaining == 0) if (totalConflictsRemaining == 0)
{ {
PROCLOCK_PRINT("LockCheckConflicts: resolved (simple)", proclock); PROCLOCK_PRINT("LockCheckConflicts: resolved (simple)", proclock);
return STATUS_OK; return false;
} }
/* If no group locking, it's definitely a conflict. */ /* If no group locking, it's definitely a conflict. */
...@@ -1402,7 +1400,7 @@ LockCheckConflicts(LockMethod lockMethodTable, ...@@ -1402,7 +1400,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
Assert(proclock->tag.myProc == MyProc); Assert(proclock->tag.myProc == MyProc);
PROCLOCK_PRINT("LockCheckConflicts: conflicting (simple)", PROCLOCK_PRINT("LockCheckConflicts: conflicting (simple)",
proclock); proclock);
return STATUS_FOUND; return true;
} }
/* /*
...@@ -1439,7 +1437,7 @@ LockCheckConflicts(LockMethod lockMethodTable, ...@@ -1439,7 +1437,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
{ {
PROCLOCK_PRINT("LockCheckConflicts: resolved (group)", PROCLOCK_PRINT("LockCheckConflicts: resolved (group)",
proclock); proclock);
return STATUS_OK; return false;
} }
} }
otherproclock = (PROCLOCK *) otherproclock = (PROCLOCK *)
...@@ -1449,7 +1447,7 @@ LockCheckConflicts(LockMethod lockMethodTable, ...@@ -1449,7 +1447,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
/* Nope, it's a real conflict. */ /* Nope, it's a real conflict. */
PROCLOCK_PRINT("LockCheckConflicts: conflicting (group)", proclock); PROCLOCK_PRINT("LockCheckConflicts: conflicting (group)", proclock);
return STATUS_FOUND; return true;
} }
/* /*
......
...@@ -1149,10 +1149,8 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable) ...@@ -1149,10 +1149,8 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
} }
/* I must go before this waiter. Check special case. */ /* I must go before this waiter. Check special case. */
if ((lockMethodTable->conflictTab[lockmode] & aheadRequests) == 0 && if ((lockMethodTable->conflictTab[lockmode] & aheadRequests) == 0 &&
LockCheckConflicts(lockMethodTable, !LockCheckConflicts(lockMethodTable, lockmode, lock,
lockmode, proclock))
lock,
proclock) == STATUS_OK)
{ {
/* Skip the wait and just grant myself the lock. */ /* Skip the wait and just grant myself the lock. */
GrantLock(lock, proclock, lockmode); GrantLock(lock, proclock, lockmode);
...@@ -1648,10 +1646,8 @@ ProcLockWakeup(LockMethod lockMethodTable, LOCK *lock) ...@@ -1648,10 +1646,8 @@ ProcLockWakeup(LockMethod lockMethodTable, LOCK *lock)
* (b) doesn't conflict with already-held locks. * (b) doesn't conflict with already-held locks.
*/ */
if ((lockMethodTable->conflictTab[lockmode] & aheadRequests) == 0 && if ((lockMethodTable->conflictTab[lockmode] & aheadRequests) == 0 &&
LockCheckConflicts(lockMethodTable, !LockCheckConflicts(lockMethodTable, lockmode, lock,
lockmode, proc->waitProcLock))
lock,
proc->waitProcLock) == STATUS_OK)
{ {
/* OK to waken */ /* OK to waken */
GrantLock(lock, proc->waitProcLock, lockmode); GrantLock(lock, proc->waitProcLock, lockmode);
......
...@@ -1120,7 +1120,6 @@ typedef union PGAlignedXLogBlock ...@@ -1120,7 +1120,6 @@ typedef union PGAlignedXLogBlock
#define STATUS_OK (0) #define STATUS_OK (0)
#define STATUS_ERROR (-1) #define STATUS_ERROR (-1)
#define STATUS_EOF (-2) #define STATUS_EOF (-2)
#define STATUS_FOUND (1)
#define STATUS_WAITING (2) #define STATUS_WAITING (2)
/* /*
......
...@@ -550,7 +550,7 @@ extern VirtualTransactionId *GetLockConflicts(const LOCKTAG *locktag, ...@@ -550,7 +550,7 @@ extern VirtualTransactionId *GetLockConflicts(const LOCKTAG *locktag,
LOCKMODE lockmode, int *countp); LOCKMODE lockmode, int *countp);
extern void AtPrepare_Locks(void); extern void AtPrepare_Locks(void);
extern void PostPrepare_Locks(TransactionId xid); extern void PostPrepare_Locks(TransactionId xid);
extern int LockCheckConflicts(LockMethod lockMethodTable, extern bool LockCheckConflicts(LockMethod lockMethodTable,
LOCKMODE lockmode, LOCKMODE lockmode,
LOCK *lock, PROCLOCK *proclock); LOCK *lock, PROCLOCK *proclock);
extern void GrantLock(LOCK *lock, PROCLOCK *proclock, LOCKMODE lockmode); extern void GrantLock(LOCK *lock, PROCLOCK *proclock, LOCKMODE lockmode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment