7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.30 1998/06/27 15:47:46 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.31 1998/06/28 21:17:34 momjian Exp $
11
11
*
12
12
* NOTES
13
13
* Outside modules can create a lock table and acquire/release
52
52
53
53
static int
54
54
WaitOnLock (LOCKTAB * ltable , LockTableId tableId , LOCK * lock ,
55
- LOCKT lockt );
55
+ LOCKTYPE locktype );
56
56
57
57
/*#define LOCK_MGR_DEBUG*/
58
58
@@ -437,15 +437,15 @@ LockTableRename(LockTableId tableId)
437
437
* xid.xid current xid 0
438
438
* persistence transaction user or backend
439
439
*
440
- * The lockt parameter can have the same values for normal locks
440
+ * The locktype parameter can have the same values for normal locks
441
441
* although probably only WRITE_LOCK can have some practical use.
442
442
*
443
443
* DZ - 4 Oct 1996
444
444
#endif
445
445
*/
446
446
447
447
bool
448
- LockAcquire (LockTableId tableId , LOCKTAG * lockName , LOCKT lockt )
448
+ LockAcquire (LockTableId tableId , LOCKTAG * lockName , LOCKTYPE locktype )
449
449
{
450
450
XIDLookupEnt * result ,
451
451
item ;
@@ -469,7 +469,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
469
469
lockName -> tupleId .ip_posid ,
470
470
((lockName -> tupleId .ip_blkid .bi_hi << 16 ) +
471
471
lockName -> tupleId .ip_blkid .bi_lo ),
472
- lockt );
472
+ locktype );
473
473
#endif
474
474
}
475
475
#endif
@@ -485,7 +485,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
485
485
if (LockingIsDisabled )
486
486
return (TRUE);
487
487
488
- LOCK_PRINT ("Acquire" , lockName , lockt );
488
+ LOCK_PRINT ("Acquire" , lockName , locktype );
489
489
masterLock = ltable -> ctl -> masterLock ;
490
490
491
491
SpinAcquire (masterLock );
@@ -571,7 +571,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
571
571
* ----------------
572
572
*/
573
573
lock -> nHolding ++ ;
574
- lock -> holders [lockt ]++ ;
574
+ lock -> holders [locktype ]++ ;
575
575
576
576
/* --------------------
577
577
* If I'm the only one holding a lock, then there
@@ -582,19 +582,19 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
582
582
*/
583
583
if (result -> nHolding == lock -> nActive )
584
584
{
585
- result -> holders [lockt ]++ ;
585
+ result -> holders [locktype ]++ ;
586
586
result -> nHolding ++ ;
587
- GrantLock (lock , lockt );
587
+ GrantLock (lock , locktype );
588
588
SpinRelease (masterLock );
589
589
return (TRUE);
590
590
}
591
591
592
592
Assert (result -> nHolding <= lock -> nActive );
593
593
594
- status = LockResolveConflicts (ltable , lock , lockt , myXid );
594
+ status = LockResolveConflicts (ltable , lock , locktype , myXid );
595
595
596
596
if (status == STATUS_OK )
597
- GrantLock (lock , lockt );
597
+ GrantLock (lock , locktype );
598
598
else if (status == STATUS_FOUND )
599
599
{
600
600
#ifdef USER_LOCKS
@@ -611,15 +611,15 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
611
611
hash_search (xidTable , (Pointer ) & item , HASH_REMOVE , & found );
612
612
}
613
613
lock -> nHolding -- ;
614
- lock -> holders [lockt ]-- ;
614
+ lock -> holders [locktype ]-- ;
615
615
SpinRelease (masterLock );
616
616
#ifdef USER_LOCKS_DEBUG
617
617
elog (NOTICE , "LockAcquire: user lock failed" );
618
618
#endif
619
619
return (FALSE);
620
620
}
621
621
#endif
622
- status = WaitOnLock (ltable , tableId , lock , lockt );
622
+ status = WaitOnLock (ltable , tableId , lock , locktype );
623
623
XID_PRINT ("Someone granted me the lock" , result );
624
624
}
625
625
@@ -647,7 +647,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
647
647
int
648
648
LockResolveConflicts (LOCKTAB * ltable ,
649
649
LOCK * lock ,
650
- LOCKT lockt ,
650
+ LOCKTYPE locktype ,
651
651
TransactionId xid )
652
652
{
653
653
XIDLookupEnt * result ,
@@ -703,7 +703,7 @@ LockResolveConflicts(LOCKTAB *ltable,
703
703
* do not continue and share the lock, even if we can. bjm
704
704
* ------------------------
705
705
*/
706
- int myprio = ltable -> ctl -> prio [lockt ];
706
+ int myprio = ltable -> ctl -> prio [locktype ];
707
707
PROC_QUEUE * waitQueue = & (lock -> waitProcs );
708
708
PROC * topproc = (PROC * ) MAKE_PTR (waitQueue -> links .prev );
709
709
@@ -716,15 +716,15 @@ LockResolveConflicts(LOCKTAB *ltable,
716
716
* with mine, then I get the lock.
717
717
*
718
718
* Checking for conflict: lock->mask represents the types of
719
- * currently held locks. conflictTable[lockt ] has a bit
719
+ * currently held locks. conflictTable[locktype ] has a bit
720
720
* set for each type of lock that conflicts with mine. Bitwise
721
721
* compare tells if there is a conflict.
722
722
* ----------------------------
723
723
*/
724
- if (!(ltable -> ctl -> conflictTab [lockt ] & lock -> mask ))
724
+ if (!(ltable -> ctl -> conflictTab [locktype ] & lock -> mask ))
725
725
{
726
726
727
- result -> holders [lockt ]++ ;
727
+ result -> holders [locktype ]++ ;
728
728
result -> nHolding ++ ;
729
729
730
730
XID_PRINT ("Conflict Resolved: updated xid entry stats" , result );
@@ -753,12 +753,12 @@ LockResolveConflicts(LOCKTAB *ltable,
753
753
* conflict and I have to sleep.
754
754
* ------------------------
755
755
*/
756
- if (!(ltable -> ctl -> conflictTab [lockt ] & bitmask ))
756
+ if (!(ltable -> ctl -> conflictTab [locktype ] & bitmask ))
757
757
{
758
758
759
759
/* no conflict. Get the lock and go on */
760
760
761
- result -> holders [lockt ]++ ;
761
+ result -> holders [locktype ]++ ;
762
762
result -> nHolding ++ ;
763
763
764
764
XID_PRINT ("Conflict Resolved: updated xid entry stats" , result );
@@ -771,11 +771,11 @@ LockResolveConflicts(LOCKTAB *ltable,
771
771
}
772
772
773
773
static int
774
- WaitOnLock (LOCKTAB * ltable , LockTableId tableId , LOCK * lock , LOCKT lockt )
774
+ WaitOnLock (LOCKTAB * ltable , LockTableId tableId , LOCK * lock , LOCKTYPE locktype )
775
775
{
776
776
PROC_QUEUE * waitQueue = & (lock -> waitProcs );
777
777
778
- int prio = ltable -> ctl -> prio [lockt ];
778
+ int prio = ltable -> ctl -> prio [locktype ];
779
779
780
780
/*
781
781
* 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
785
* synchronization for this queue. That will not be true if/when
786
786
* people can be deleted from the queue by a SIGINT or something.
787
787
*/
788
- LOCK_DUMP_AUX ("WaitOnLock: sleeping on lock" , lock , lockt );
788
+ LOCK_DUMP_AUX ("WaitOnLock: sleeping on lock" , lock , locktype );
789
789
if (ProcSleep (waitQueue ,
790
790
ltable -> ctl -> masterLock ,
791
- lockt ,
791
+ locktype ,
792
792
prio ,
793
793
lock ) != NO_ERROR )
794
794
{
@@ -799,13 +799,13 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
799
799
* -------------------
800
800
*/
801
801
lock -> nHolding -- ;
802
- lock -> holders [lockt ]-- ;
803
- LOCK_DUMP_AUX ("WaitOnLock: aborting on lock" , lock , lockt );
802
+ lock -> holders [locktype ]-- ;
803
+ LOCK_DUMP_AUX ("WaitOnLock: aborting on lock" , lock , locktype );
804
804
SpinRelease (ltable -> ctl -> masterLock );
805
805
elog (ERROR , "WaitOnLock: error on wakeup - Aborting this transaction" );
806
806
}
807
807
808
- LOCK_DUMP_AUX ("WaitOnLock: wakeup on lock" , lock , lockt );
808
+ LOCK_DUMP_AUX ("WaitOnLock: wakeup on lock" , lock , locktype );
809
809
return (STATUS_OK );
810
810
}
811
811
@@ -820,7 +820,7 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
820
820
* come along and request the lock).
821
821
*/
822
822
bool
823
- LockRelease (LockTableId tableId , LOCKTAG * lockName , LOCKT lockt )
823
+ LockRelease (LockTableId tableId , LOCKTAG * lockName , LOCKTYPE locktype )
824
824
{
825
825
LOCK * lock = NULL ;
826
826
SPINLOCK masterLock ;
@@ -843,7 +843,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
843
843
lockName -> tupleId .ip_posid ,
844
844
((lockName -> tupleId .ip_blkid .bi_hi << 16 ) +
845
845
lockName -> tupleId .ip_blkid .bi_lo ),
846
- lockt );
846
+ locktype );
847
847
#endif
848
848
}
849
849
#endif
@@ -859,7 +859,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
859
859
if (LockingIsDisabled )
860
860
return (TRUE);
861
861
862
- LOCK_PRINT ("Release" , lockName , lockt );
862
+ LOCK_PRINT ("Release" , lockName , locktype );
863
863
864
864
masterLock = ltable -> ctl -> masterLock ;
865
865
xidTable = ltable -> xidHash ;
@@ -919,9 +919,9 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
919
919
* fix the general lock stats
920
920
*/
921
921
lock -> nHolding -- ;
922
- lock -> holders [lockt ]-- ;
922
+ lock -> holders [locktype ]-- ;
923
923
lock -> nActive -- ;
924
- lock -> activeHolders [lockt ]-- ;
924
+ lock -> activeHolders [locktype ]-- ;
925
925
926
926
Assert (lock -> nActive >= 0 );
927
927
@@ -992,7 +992,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
992
992
* now check to see if I have any private locks. If I do, decrement
993
993
* the counts associated with them.
994
994
*/
995
- result -> holders [lockt ]-- ;
995
+ result -> holders [locktype ]-- ;
996
996
result -> nHolding -- ;
997
997
998
998
XID_PRINT ("LockRelease updated xid stats" , result );
@@ -1038,9 +1038,9 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
1038
1038
* fix the general lock stats
1039
1039
*/
1040
1040
lock -> nHolding -- ;
1041
- lock -> holders [lockt ]-- ;
1041
+ lock -> holders [locktype ]-- ;
1042
1042
lock -> nActive -- ;
1043
- lock -> activeHolders [lockt ]-- ;
1043
+ lock -> activeHolders [locktype ]-- ;
1044
1044
1045
1045
Assert (lock -> nActive >= 0 );
1046
1046
@@ -1069,10 +1069,10 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
1069
1069
* with the remaining locks.
1070
1070
* --------------------------
1071
1071
*/
1072
- if (!(lock -> activeHolders [lockt ]))
1072
+ if (!(lock -> activeHolders [locktype ]))
1073
1073
{
1074
1074
/* change the conflict mask. No more of this lock type. */
1075
- lock -> mask &= BITS_OFF [lockt ];
1075
+ lock -> mask &= BITS_OFF [locktype ];
1076
1076
}
1077
1077
1078
1078
if (wakeupNeeded )
@@ -1095,11 +1095,11 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
1095
1095
* the new lock holder.
1096
1096
*/
1097
1097
void
1098
- GrantLock (LOCK * lock , LOCKT lockt )
1098
+ GrantLock (LOCK * lock , LOCKTYPE locktype )
1099
1099
{
1100
1100
lock -> nActive ++ ;
1101
- lock -> activeHolders [lockt ]++ ;
1102
- lock -> mask |= BITS_ON [lockt ];
1101
+ lock -> activeHolders [locktype ]++ ;
1102
+ lock -> mask |= BITS_ON [locktype ];
1103
1103
}
1104
1104
1105
1105
#ifdef USER_LOCKS
0 commit comments