Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc096a80

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 parent38fc056 commitc096a80

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
ResourceOwnerowner;
747747
uint32hashcode;
748748
LWLock*partitionLock;
749-
intstatus;
749+
boolfound_conflict;
750750
boollog_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-
* ReturnsSTATUS_FOUND if conflict,STATUS_OK if no conflict.
1331+
* Returnstrue 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(LockMethodlockMethodTable,
13451343
LOCKMODElockmode,
13461344
LOCK*lock,
@@ -1367,7 +1365,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
13671365
if (!(conflictMask&lock->grantMask))
13681366
{
13691367
PROCLOCK_PRINT("LockCheckConflicts: no conflict",proclock);
1370-
returnSTATUS_OK;
1368+
returnfalse;
13711369
}
13721370

13731371
/*
@@ -1393,7 +1391,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
13931391
if (totalConflictsRemaining==0)
13941392
{
13951393
PROCLOCK_PRINT("LockCheckConflicts: resolved (simple)",proclock);
1396-
returnSTATUS_OK;
1394+
returnfalse;
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-
returnSTATUS_FOUND;
1403+
returntrue;
14061404
}
14071405

14081406
/*
@@ -1439,7 +1437,7 @@ LockCheckConflicts(LockMethod lockMethodTable,
14391437
{
14401438
PROCLOCK_PRINT("LockCheckConflicts: resolved (group)",
14411439
proclock);
1442-
returnSTATUS_OK;
1440+
returnfalse;
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-
returnSTATUS_FOUND;
1450+
returntrue;
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
#defineSTATUS_OK(0)
11211121
#defineSTATUS_ERROR(-1)
11221122
#defineSTATUS_EOF(-2)
1123-
#defineSTATUS_FOUND(1)
11241123
#defineSTATUS_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
LOCKMODElockmode,int*countp);
551551
externvoidAtPrepare_Locks(void);
552552
externvoidPostPrepare_Locks(TransactionIdxid);
553-
externintLockCheckConflicts(LockMethodlockMethodTable,
553+
externboolLockCheckConflicts(LockMethodlockMethodTable,
554554
LOCKMODElockmode,
555555
LOCK*lock,PROCLOCK*proclock);
556556
externvoidGrantLock(LOCK*lock,PROCLOCK*proclock,LOCKMODElockmode);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp