Skip to content

Commit 223be21

Browse files
committed
Undo overly enthusiastic de-const-ification.
s/const//g wasn't exactly what I was suggesting here ... parameter declarations of the form "const structtype *param" are good and useful, so put those occurrences back. Likewise, avoid casting away the const in a "const void *" parameter.
1 parent 0b44818 commit 223be21

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

src/backend/storage/lmgr/predicate.c

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static void ReleasePredXact(SERIALIZABLEXACT *sxact);
388388
static SERIALIZABLEXACT *FirstPredXact(void);
389389
static SERIALIZABLEXACT *NextPredXact(SERIALIZABLEXACT *sxact);
390390

391-
static bool RWConflictExists(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer);
391+
static bool RWConflictExists(const SERIALIZABLEXACT *reader, const SERIALIZABLEXACT *writer);
392392
static void SetRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer);
393393
static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT *activeXact);
394394
static void ReleaseRWConflict(RWConflict conflict);
@@ -404,26 +404,26 @@ static uint32 predicatelock_hash(const void *key, Size keysize);
404404
static void SummarizeOldestCommittedSxact(void);
405405
static Snapshot GetSafeSnapshot(Snapshot snapshot);
406406
static Snapshot RegisterSerializableTransactionInt(Snapshot snapshot);
407-
static bool PredicateLockExists(PREDICATELOCKTARGETTAG *targettag);
408-
static bool GetParentPredicateLockTag(PREDICATELOCKTARGETTAG *tag,
407+
static bool PredicateLockExists(const PREDICATELOCKTARGETTAG *targettag);
408+
static bool GetParentPredicateLockTag(const PREDICATELOCKTARGETTAG *tag,
409409
PREDICATELOCKTARGETTAG *parent);
410-
static bool CoarserLockCovers(PREDICATELOCKTARGETTAG *newtargettag);
410+
static bool CoarserLockCovers(const PREDICATELOCKTARGETTAG *newtargettag);
411411
static void RemoveScratchTarget(bool lockheld);
412412
static void RestoreScratchTarget(bool lockheld);
413413
static void RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target,
414414
uint32 targettaghash);
415-
static void DeleteChildTargetLocks(PREDICATELOCKTARGETTAG *newtargettag);
416-
static int PredicateLockPromotionThreshold(PREDICATELOCKTARGETTAG *tag);
417-
static bool CheckAndPromotePredicateLockRequest(PREDICATELOCKTARGETTAG *reqtag);
418-
static void DecrementParentLocks(PREDICATELOCKTARGETTAG *targettag);
419-
static void CreatePredicateLock(PREDICATELOCKTARGETTAG *targettag,
415+
static void DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag);
416+
static int PredicateLockPromotionThreshold(const PREDICATELOCKTARGETTAG *tag);
417+
static bool CheckAndPromotePredicateLockRequest(const PREDICATELOCKTARGETTAG *reqtag);
418+
static void DecrementParentLocks(const PREDICATELOCKTARGETTAG *targettag);
419+
static void CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag,
420420
uint32 targettaghash,
421421
SERIALIZABLEXACT *sxact);
422422
static void DeleteLockTarget(PREDICATELOCKTARGET *target, uint32 targettaghash);
423423
static bool TransferPredicateLocksToNewTarget(PREDICATELOCKTARGETTAG oldtargettag,
424424
PREDICATELOCKTARGETTAG newtargettag,
425425
bool removeOld);
426-
static void PredicateLockAcquire(PREDICATELOCKTARGETTAG *targettag);
426+
static void PredicateLockAcquire(const PREDICATELOCKTARGETTAG *targettag);
427427
static void DropAllPredicateLocksFromTable(Relation relation,
428428
bool transfer);
429429
static void SetNewSxactGlobalXmin(void);
@@ -433,7 +433,7 @@ static void ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial,
433433
static bool XidIsConcurrent(TransactionId xid);
434434
static void CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag);
435435
static void FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer);
436-
static void OnConflict_CheckForSerializationFailure(SERIALIZABLEXACT *reader,
436+
static void OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
437437
SERIALIZABLEXACT *writer);
438438

439439

@@ -601,7 +601,7 @@ NextPredXact(SERIALIZABLEXACT *sxact)
601601
* These functions manage primitive access to the RWConflict pool and lists.
602602
*/
603603
static bool
604-
RWConflictExists(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
604+
RWConflictExists(const SERIALIZABLEXACT *reader, const SERIALIZABLEXACT *writer)
605605
{
606606
RWConflict conflict;
607607

@@ -1337,7 +1337,7 @@ PredicateLockShmemSize(void)
13371337
static uint32
13381338
predicatelock_hash(const void *key, Size keysize)
13391339
{
1340-
PREDICATELOCKTAG *predicatelocktag = (PREDICATELOCKTAG *) key;
1340+
const PREDICATELOCKTAG *predicatelocktag = (const PREDICATELOCKTAG *) key;
13411341
uint32 targethash;
13421342

13431343
Assert(keysize == sizeof(PREDICATELOCKTAG));
@@ -1785,7 +1785,7 @@ PageIsPredicateLocked(Relation relation, BlockNumber blkno)
17851785
* acceptable!
17861786
*/
17871787
static bool
1788-
PredicateLockExists(PREDICATELOCKTARGETTAG *targettag)
1788+
PredicateLockExists(const PREDICATELOCKTARGETTAG *targettag)
17891789
{
17901790
LOCALPREDICATELOCK *lock;
17911791

@@ -1812,7 +1812,7 @@ PredicateLockExists(PREDICATELOCKTARGETTAG *targettag)
18121812
* returns false if none exists.
18131813
*/
18141814
static bool
1815-
GetParentPredicateLockTag(PREDICATELOCKTARGETTAG *tag,
1815+
GetParentPredicateLockTag(const PREDICATELOCKTARGETTAG *tag,
18161816
PREDICATELOCKTARGETTAG *parent)
18171817
{
18181818
switch (GET_PREDICATELOCKTARGETTAG_TYPE(*tag))
@@ -1851,7 +1851,7 @@ GetParentPredicateLockTag(PREDICATELOCKTARGETTAG *tag,
18511851
* negative, but it will never return a false positive.
18521852
*/
18531853
static bool
1854-
CoarserLockCovers(PREDICATELOCKTARGETTAG *newtargettag)
1854+
CoarserLockCovers(const PREDICATELOCKTARGETTAG *newtargettag)
18551855
{
18561856
PREDICATELOCKTARGETTAG targettag,
18571857
parenttag;
@@ -1952,7 +1952,7 @@ RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target, uint32 targettaghash)
19521952
* locks.
19531953
*/
19541954
static void
1955-
DeleteChildTargetLocks(PREDICATELOCKTARGETTAG *newtargettag)
1955+
DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag)
19561956
{
19571957
SERIALIZABLEXACT *sxact;
19581958
PREDICATELOCK *predlock;
@@ -2029,7 +2029,7 @@ DeleteChildTargetLocks(PREDICATELOCKTARGETTAG *newtargettag)
20292029
* entirely arbitrarily (and without benchmarking).
20302030
*/
20312031
static int
2032-
PredicateLockPromotionThreshold(PREDICATELOCKTARGETTAG *tag)
2032+
PredicateLockPromotionThreshold(const PREDICATELOCKTARGETTAG *tag)
20332033
{
20342034
switch (GET_PREDICATELOCKTARGETTAG_TYPE(*tag))
20352035
{
@@ -2063,7 +2063,7 @@ PredicateLockPromotionThreshold(PREDICATELOCKTARGETTAG *tag)
20632063
* Returns true if a parent lock was acquired and false otherwise.
20642064
*/
20652065
static bool
2066-
CheckAndPromotePredicateLockRequest(PREDICATELOCKTARGETTAG *reqtag)
2066+
CheckAndPromotePredicateLockRequest(const PREDICATELOCKTARGETTAG *reqtag)
20672067
{
20682068
PREDICATELOCKTARGETTAG targettag,
20692069
nexttag,
@@ -2128,7 +2128,7 @@ CheckAndPromotePredicateLockRequest(PREDICATELOCKTARGETTAG *reqtag)
21282128
* this information is no longer needed.
21292129
*/
21302130
static void
2131-
DecrementParentLocks(PREDICATELOCKTARGETTAG *targettag)
2131+
DecrementParentLocks(const PREDICATELOCKTARGETTAG *targettag)
21322132
{
21332133
PREDICATELOCKTARGETTAG parenttag,
21342134
nexttag;
@@ -2190,7 +2190,7 @@ DecrementParentLocks(PREDICATELOCKTARGETTAG *targettag)
21902190
* PredicateLockAcquire for that.
21912191
*/
21922192
static void
2193-
CreatePredicateLock(PREDICATELOCKTARGETTAG *targettag,
2193+
CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag,
21942194
uint32 targettaghash,
21952195
SERIALIZABLEXACT *sxact)
21962196
{
@@ -2251,7 +2251,7 @@ CreatePredicateLock(PREDICATELOCKTARGETTAG *targettag,
22512251
* any finer-grained locks covered by the new one.
22522252
*/
22532253
static void
2254-
PredicateLockAcquire(PREDICATELOCKTARGETTAG *targettag)
2254+
PredicateLockAcquire(const PREDICATELOCKTARGETTAG *targettag)
22552255
{
22562256
uint32 targettaghash;
22572257
bool found;
@@ -2613,14 +2613,13 @@ TransferPredicateLocksToNewTarget(PREDICATELOCKTARGETTAG oldtargettag,
26132613
Assert(found);
26142614
}
26152615

2616-
26172616
newpredlock = (PREDICATELOCK *)
2618-
hash_search_with_hash_value
2619-
(PredicateLockHash,
2620-
&newpredlocktag,
2621-
PredicateLockHashCodeFromTargetHashCode(&newpredlocktag,
2622-
newtargettaghash),
2623-
HASH_ENTER_NULL, &found);
2617+
hash_search_with_hash_value(PredicateLockHash,
2618+
&newpredlocktag,
2619+
PredicateLockHashCodeFromTargetHashCode(&newpredlocktag,
2620+
newtargettaghash),
2621+
HASH_ENTER_NULL,
2622+
&found);
26242623
if (!newpredlock)
26252624
{
26262625
/* Out of shared memory. Undo what we've done so far. */
@@ -2856,12 +2855,12 @@ DropAllPredicateLocksFromTable(Relation relation, bool transfer)
28562855
newpredlocktag.myTarget = heaptarget;
28572856
newpredlocktag.myXact = oldXact;
28582857
newpredlock = (PREDICATELOCK *)
2859-
hash_search_with_hash_value
2860-
(PredicateLockHash,
2861-
&newpredlocktag,
2862-
PredicateLockHashCodeFromTargetHashCode(&newpredlocktag,
2863-
heaptargettaghash),
2864-
HASH_ENTER, &found);
2858+
hash_search_with_hash_value(PredicateLockHash,
2859+
&newpredlocktag,
2860+
PredicateLockHashCodeFromTargetHashCode(&newpredlocktag,
2861+
heaptargettaghash),
2862+
HASH_ENTER,
2863+
&found);
28652864
if (!found)
28662865
{
28672866
SHMQueueInsertBefore(&(heaptarget->predicateLocks),
@@ -4327,7 +4326,7 @@ FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
43274326
*----------------------------------------------------------------------------
43284327
*/
43294328
static void
4330-
OnConflict_CheckForSerializationFailure(SERIALIZABLEXACT *reader,
4329+
OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
43314330
SERIALIZABLEXACT *writer)
43324331
{
43334332
bool failure;

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