Skip to content

Commit c096a80

Browse files
committed
Remove STATUS_FOUND
Replace the solitary use with a bool. Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/flat/a6f91ead-0ce4-2a34-062b-7ab9813ea308%402ndquadrant.com
1 parent 38fc056 commit c096a80

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

src/backend/storage/lmgr/lock.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ LockAcquireExtended(const LOCKTAG *locktag,
746746
ResourceOwner owner;
747747
uint32 hashcode;
748748
LWLock *partitionLock;
749-
int status;
749+
bool found_conflict;
750750
bool log_lock = false;
751751

752752
if (lockmethodid <= 0 || lockmethodid >= lengthof(LockMethods))
@@ -979,21 +979,19 @@ LockAcquireExtended(const LOCKTAG *locktag,
979979
* (That's last because most complex check.)
980980
*/
981981
if (lockMethodTable->conflictTab[lockmode] & lock->waitMask)
982-
status = STATUS_FOUND;
982+
found_conflict = true;
983983
else
984-
status = LockCheckConflicts(lockMethodTable, lockmode,
984+
found_conflict = LockCheckConflicts(lockMethodTable, lockmode,
985985
lock, proclock);
986986

987-
if (status == STATUS_OK)
987+
if (!found_conflict)
988988
{
989989
/* No conflict with held or previously requested locks */
990990
GrantLock(lock, proclock, lockmode);
991991
GrantLockLocal(locallock, owner);
992992
}
993993
else
994994
{
995-
Assert(status == STATUS_FOUND);
996-
997995
/*
998996
* We can't acquire the lock immediately. If caller specified no
999997
* blocking, remove useless table entries and return
@@ -1330,7 +1328,7 @@ RemoveLocalLock(LOCALLOCK *locallock)
13301328
* LockCheckConflicts -- test whether requested lock conflicts
13311329
* with those already granted
13321330
*
1333-
* Returns STATUS_FOUND if conflict, STATUS_OK if no conflict.
1331+
* Returns true if conflict, false if no conflict.
13341332
*
13351333
* NOTES:
13361334
* Here's what makes this complicated: one process's locks don't
@@ -1340,7 +1338,7 @@ RemoveLocalLock(LOCALLOCK *locallock)
13401338
* the same group. So, we must subtract off these locks when determining
13411339
* whether the requested new lock conflicts with those already held.
13421340
*/
1343-
int
1341+
bool
13441342
LockCheckConflicts(LockMethod lockMethodTable,
13451343
LOCKMODE lockmode,
13461344
LOCK *lock,
@@ -1367,7 +1365,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
13671365
if (!(conflictMask & lock->grantMask))
13681366
{
13691367
PROCLOCK_PRINT("LockCheckConflicts: no conflict", proclock);
1370-
return STATUS_OK;
1368+
return false;
13711369
}
13721370

13731371
/*
@@ -1393,7 +1391,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
13931391
if (totalConflictsRemaining == 0)
13941392
{
13951393
PROCLOCK_PRINT("LockCheckConflicts: resolved (simple)", proclock);
1396-
return STATUS_OK;
1394+
return false;
13971395
}
13981396

13991397
/* If no group locking, it's definitely a conflict. */
@@ -1402,7 +1400,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
14021400
Assert(proclock->tag.myProc == MyProc);
14031401
PROCLOCK_PRINT("LockCheckConflicts: conflicting (simple)",
14041402
proclock);
1405-
return STATUS_FOUND;
1403+
return true;
14061404
}
14071405

14081406
/*
@@ -1439,7 +1437,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
14391437
{
14401438
PROCLOCK_PRINT("LockCheckConflicts: resolved (group)",
14411439
proclock);
1442-
return STATUS_OK;
1440+
return false;
14431441
}
14441442
}
14451443
otherproclock = (PROCLOCK *)
@@ -1449,7 +1447,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
14491447

14501448
/* Nope, it's a real conflict. */
14511449
PROCLOCK_PRINT("LockCheckConflicts: conflicting (group)", proclock);
1452-
return STATUS_FOUND;
1450+
return true;
14531451
}
14541452

14551453
/*

src/backend/storage/lmgr/proc.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,10 +1149,8 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
11491149
}
11501150
/* I must go before this waiter. Check special case. */
11511151
if ((lockMethodTable->conflictTab[lockmode] & aheadRequests) == 0 &&
1152-
LockCheckConflicts(lockMethodTable,
1153-
lockmode,
1154-
lock,
1155-
proclock) == STATUS_OK)
1152+
!LockCheckConflicts(lockMethodTable, lockmode, lock,
1153+
proclock))
11561154
{
11571155
/* Skip the wait and just grant myself the lock. */
11581156
GrantLock(lock, proclock, lockmode);
@@ -1648,10 +1646,8 @@ ProcLockWakeup(LockMethod lockMethodTable, LOCK *lock)
16481646
* (b) doesn't conflict with already-held locks.
16491647
*/
16501648
if ((lockMethodTable->conflictTab[lockmode] & aheadRequests) == 0 &&
1651-
LockCheckConflicts(lockMethodTable,
1652-
lockmode,
1653-
lock,
1654-
proc->waitProcLock) == STATUS_OK)
1649+
!LockCheckConflicts(lockMethodTable, lockmode, lock,
1650+
proc->waitProcLock))
16551651
{
16561652
/* OK to waken */
16571653
GrantLock(lock, proc->waitProcLock, lockmode);

src/include/c.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,6 @@ typedef union PGAlignedXLogBlock
11201120
#define STATUS_OK (0)
11211121
#define STATUS_ERROR (-1)
11221122
#define STATUS_EOF (-2)
1123-
#define STATUS_FOUND (1)
11241123
#define STATUS_WAITING (2)
11251124

11261125
/*

src/include/storage/lock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ extern VirtualTransactionId *GetLockConflicts(const LOCKTAG *locktag,
550550
LOCKMODE lockmode, int *countp);
551551
extern void AtPrepare_Locks(void);
552552
extern void PostPrepare_Locks(TransactionId xid);
553-
extern int LockCheckConflicts(LockMethod lockMethodTable,
553+
extern bool LockCheckConflicts(LockMethod lockMethodTable,
554554
LOCKMODE lockmode,
555555
LOCK *lock, PROCLOCK *proclock);
556556
extern void GrantLock(LOCK *lock, PROCLOCK *proclock, LOCKMODE lockmode);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy