Commit 223be216 authored by Tom Lane's avatar Tom Lane

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.
parent 0b44818e
...@@ -388,7 +388,7 @@ static void ReleasePredXact(SERIALIZABLEXACT *sxact); ...@@ -388,7 +388,7 @@ static void ReleasePredXact(SERIALIZABLEXACT *sxact);
static SERIALIZABLEXACT *FirstPredXact(void); static SERIALIZABLEXACT *FirstPredXact(void);
static SERIALIZABLEXACT *NextPredXact(SERIALIZABLEXACT *sxact); static SERIALIZABLEXACT *NextPredXact(SERIALIZABLEXACT *sxact);
static bool RWConflictExists(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer); static bool RWConflictExists(const SERIALIZABLEXACT *reader, const SERIALIZABLEXACT *writer);
static void SetRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer); static void SetRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer);
static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT *activeXact); static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT *activeXact);
static void ReleaseRWConflict(RWConflict conflict); static void ReleaseRWConflict(RWConflict conflict);
...@@ -404,26 +404,26 @@ static uint32 predicatelock_hash(const void *key, Size keysize); ...@@ -404,26 +404,26 @@ static uint32 predicatelock_hash(const void *key, Size keysize);
static void SummarizeOldestCommittedSxact(void); static void SummarizeOldestCommittedSxact(void);
static Snapshot GetSafeSnapshot(Snapshot snapshot); static Snapshot GetSafeSnapshot(Snapshot snapshot);
static Snapshot RegisterSerializableTransactionInt(Snapshot snapshot); static Snapshot RegisterSerializableTransactionInt(Snapshot snapshot);
static bool PredicateLockExists(PREDICATELOCKTARGETTAG *targettag); static bool PredicateLockExists(const PREDICATELOCKTARGETTAG *targettag);
static bool GetParentPredicateLockTag(PREDICATELOCKTARGETTAG *tag, static bool GetParentPredicateLockTag(const PREDICATELOCKTARGETTAG *tag,
PREDICATELOCKTARGETTAG *parent); PREDICATELOCKTARGETTAG *parent);
static bool CoarserLockCovers(PREDICATELOCKTARGETTAG *newtargettag); static bool CoarserLockCovers(const PREDICATELOCKTARGETTAG *newtargettag);
static void RemoveScratchTarget(bool lockheld); static void RemoveScratchTarget(bool lockheld);
static void RestoreScratchTarget(bool lockheld); static void RestoreScratchTarget(bool lockheld);
static void RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target, static void RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target,
uint32 targettaghash); uint32 targettaghash);
static void DeleteChildTargetLocks(PREDICATELOCKTARGETTAG *newtargettag); static void DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag);
static int PredicateLockPromotionThreshold(PREDICATELOCKTARGETTAG *tag); static int PredicateLockPromotionThreshold(const PREDICATELOCKTARGETTAG *tag);
static bool CheckAndPromotePredicateLockRequest(PREDICATELOCKTARGETTAG *reqtag); static bool CheckAndPromotePredicateLockRequest(const PREDICATELOCKTARGETTAG *reqtag);
static void DecrementParentLocks(PREDICATELOCKTARGETTAG *targettag); static void DecrementParentLocks(const PREDICATELOCKTARGETTAG *targettag);
static void CreatePredicateLock(PREDICATELOCKTARGETTAG *targettag, static void CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag,
uint32 targettaghash, uint32 targettaghash,
SERIALIZABLEXACT *sxact); SERIALIZABLEXACT *sxact);
static void DeleteLockTarget(PREDICATELOCKTARGET *target, uint32 targettaghash); static void DeleteLockTarget(PREDICATELOCKTARGET *target, uint32 targettaghash);
static bool TransferPredicateLocksToNewTarget(PREDICATELOCKTARGETTAG oldtargettag, static bool TransferPredicateLocksToNewTarget(PREDICATELOCKTARGETTAG oldtargettag,
PREDICATELOCKTARGETTAG newtargettag, PREDICATELOCKTARGETTAG newtargettag,
bool removeOld); bool removeOld);
static void PredicateLockAcquire(PREDICATELOCKTARGETTAG *targettag); static void PredicateLockAcquire(const PREDICATELOCKTARGETTAG *targettag);
static void DropAllPredicateLocksFromTable(Relation relation, static void DropAllPredicateLocksFromTable(Relation relation,
bool transfer); bool transfer);
static void SetNewSxactGlobalXmin(void); static void SetNewSxactGlobalXmin(void);
...@@ -433,7 +433,7 @@ static void ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial, ...@@ -433,7 +433,7 @@ static void ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial,
static bool XidIsConcurrent(TransactionId xid); static bool XidIsConcurrent(TransactionId xid);
static void CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag); static void CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag);
static void FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer); static void FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer);
static void OnConflict_CheckForSerializationFailure(SERIALIZABLEXACT *reader, static void OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
SERIALIZABLEXACT *writer); SERIALIZABLEXACT *writer);
...@@ -601,7 +601,7 @@ NextPredXact(SERIALIZABLEXACT *sxact) ...@@ -601,7 +601,7 @@ NextPredXact(SERIALIZABLEXACT *sxact)
* These functions manage primitive access to the RWConflict pool and lists. * These functions manage primitive access to the RWConflict pool and lists.
*/ */
static bool static bool
RWConflictExists(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer) RWConflictExists(const SERIALIZABLEXACT *reader, const SERIALIZABLEXACT *writer)
{ {
RWConflict conflict; RWConflict conflict;
...@@ -1337,7 +1337,7 @@ PredicateLockShmemSize(void) ...@@ -1337,7 +1337,7 @@ PredicateLockShmemSize(void)
static uint32 static uint32
predicatelock_hash(const void *key, Size keysize) predicatelock_hash(const void *key, Size keysize)
{ {
PREDICATELOCKTAG *predicatelocktag = (PREDICATELOCKTAG *) key; const PREDICATELOCKTAG *predicatelocktag = (const PREDICATELOCKTAG *) key;
uint32 targethash; uint32 targethash;
Assert(keysize == sizeof(PREDICATELOCKTAG)); Assert(keysize == sizeof(PREDICATELOCKTAG));
...@@ -1785,7 +1785,7 @@ PageIsPredicateLocked(Relation relation, BlockNumber blkno) ...@@ -1785,7 +1785,7 @@ PageIsPredicateLocked(Relation relation, BlockNumber blkno)
* acceptable! * acceptable!
*/ */
static bool static bool
PredicateLockExists(PREDICATELOCKTARGETTAG *targettag) PredicateLockExists(const PREDICATELOCKTARGETTAG *targettag)
{ {
LOCALPREDICATELOCK *lock; LOCALPREDICATELOCK *lock;
...@@ -1812,7 +1812,7 @@ PredicateLockExists(PREDICATELOCKTARGETTAG *targettag) ...@@ -1812,7 +1812,7 @@ PredicateLockExists(PREDICATELOCKTARGETTAG *targettag)
* returns false if none exists. * returns false if none exists.
*/ */
static bool static bool
GetParentPredicateLockTag(PREDICATELOCKTARGETTAG *tag, GetParentPredicateLockTag(const PREDICATELOCKTARGETTAG *tag,
PREDICATELOCKTARGETTAG *parent) PREDICATELOCKTARGETTAG *parent)
{ {
switch (GET_PREDICATELOCKTARGETTAG_TYPE(*tag)) switch (GET_PREDICATELOCKTARGETTAG_TYPE(*tag))
...@@ -1851,7 +1851,7 @@ GetParentPredicateLockTag(PREDICATELOCKTARGETTAG *tag, ...@@ -1851,7 +1851,7 @@ GetParentPredicateLockTag(PREDICATELOCKTARGETTAG *tag,
* negative, but it will never return a false positive. * negative, but it will never return a false positive.
*/ */
static bool static bool
CoarserLockCovers(PREDICATELOCKTARGETTAG *newtargettag) CoarserLockCovers(const PREDICATELOCKTARGETTAG *newtargettag)
{ {
PREDICATELOCKTARGETTAG targettag, PREDICATELOCKTARGETTAG targettag,
parenttag; parenttag;
...@@ -1952,7 +1952,7 @@ RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target, uint32 targettaghash) ...@@ -1952,7 +1952,7 @@ RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target, uint32 targettaghash)
* locks. * locks.
*/ */
static void static void
DeleteChildTargetLocks(PREDICATELOCKTARGETTAG *newtargettag) DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag)
{ {
SERIALIZABLEXACT *sxact; SERIALIZABLEXACT *sxact;
PREDICATELOCK *predlock; PREDICATELOCK *predlock;
...@@ -2029,7 +2029,7 @@ DeleteChildTargetLocks(PREDICATELOCKTARGETTAG *newtargettag) ...@@ -2029,7 +2029,7 @@ DeleteChildTargetLocks(PREDICATELOCKTARGETTAG *newtargettag)
* entirely arbitrarily (and without benchmarking). * entirely arbitrarily (and without benchmarking).
*/ */
static int static int
PredicateLockPromotionThreshold(PREDICATELOCKTARGETTAG *tag) PredicateLockPromotionThreshold(const PREDICATELOCKTARGETTAG *tag)
{ {
switch (GET_PREDICATELOCKTARGETTAG_TYPE(*tag)) switch (GET_PREDICATELOCKTARGETTAG_TYPE(*tag))
{ {
...@@ -2063,7 +2063,7 @@ PredicateLockPromotionThreshold(PREDICATELOCKTARGETTAG *tag) ...@@ -2063,7 +2063,7 @@ PredicateLockPromotionThreshold(PREDICATELOCKTARGETTAG *tag)
* Returns true if a parent lock was acquired and false otherwise. * Returns true if a parent lock was acquired and false otherwise.
*/ */
static bool static bool
CheckAndPromotePredicateLockRequest(PREDICATELOCKTARGETTAG *reqtag) CheckAndPromotePredicateLockRequest(const PREDICATELOCKTARGETTAG *reqtag)
{ {
PREDICATELOCKTARGETTAG targettag, PREDICATELOCKTARGETTAG targettag,
nexttag, nexttag,
...@@ -2128,7 +2128,7 @@ CheckAndPromotePredicateLockRequest(PREDICATELOCKTARGETTAG *reqtag) ...@@ -2128,7 +2128,7 @@ CheckAndPromotePredicateLockRequest(PREDICATELOCKTARGETTAG *reqtag)
* this information is no longer needed. * this information is no longer needed.
*/ */
static void static void
DecrementParentLocks(PREDICATELOCKTARGETTAG *targettag) DecrementParentLocks(const PREDICATELOCKTARGETTAG *targettag)
{ {
PREDICATELOCKTARGETTAG parenttag, PREDICATELOCKTARGETTAG parenttag,
nexttag; nexttag;
...@@ -2190,7 +2190,7 @@ DecrementParentLocks(PREDICATELOCKTARGETTAG *targettag) ...@@ -2190,7 +2190,7 @@ DecrementParentLocks(PREDICATELOCKTARGETTAG *targettag)
* PredicateLockAcquire for that. * PredicateLockAcquire for that.
*/ */
static void static void
CreatePredicateLock(PREDICATELOCKTARGETTAG *targettag, CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag,
uint32 targettaghash, uint32 targettaghash,
SERIALIZABLEXACT *sxact) SERIALIZABLEXACT *sxact)
{ {
...@@ -2251,7 +2251,7 @@ CreatePredicateLock(PREDICATELOCKTARGETTAG *targettag, ...@@ -2251,7 +2251,7 @@ CreatePredicateLock(PREDICATELOCKTARGETTAG *targettag,
* any finer-grained locks covered by the new one. * any finer-grained locks covered by the new one.
*/ */
static void static void
PredicateLockAcquire(PREDICATELOCKTARGETTAG *targettag) PredicateLockAcquire(const PREDICATELOCKTARGETTAG *targettag)
{ {
uint32 targettaghash; uint32 targettaghash;
bool found; bool found;
...@@ -2613,14 +2613,13 @@ TransferPredicateLocksToNewTarget(PREDICATELOCKTARGETTAG oldtargettag, ...@@ -2613,14 +2613,13 @@ TransferPredicateLocksToNewTarget(PREDICATELOCKTARGETTAG oldtargettag,
Assert(found); Assert(found);
} }
newpredlock = (PREDICATELOCK *) newpredlock = (PREDICATELOCK *)
hash_search_with_hash_value hash_search_with_hash_value(PredicateLockHash,
(PredicateLockHash,
&newpredlocktag, &newpredlocktag,
PredicateLockHashCodeFromTargetHashCode(&newpredlocktag, PredicateLockHashCodeFromTargetHashCode(&newpredlocktag,
newtargettaghash), newtargettaghash),
HASH_ENTER_NULL, &found); HASH_ENTER_NULL,
&found);
if (!newpredlock) if (!newpredlock)
{ {
/* Out of shared memory. Undo what we've done so far. */ /* Out of shared memory. Undo what we've done so far. */
...@@ -2856,12 +2855,12 @@ DropAllPredicateLocksFromTable(Relation relation, bool transfer) ...@@ -2856,12 +2855,12 @@ DropAllPredicateLocksFromTable(Relation relation, bool transfer)
newpredlocktag.myTarget = heaptarget; newpredlocktag.myTarget = heaptarget;
newpredlocktag.myXact = oldXact; newpredlocktag.myXact = oldXact;
newpredlock = (PREDICATELOCK *) newpredlock = (PREDICATELOCK *)
hash_search_with_hash_value hash_search_with_hash_value(PredicateLockHash,
(PredicateLockHash,
&newpredlocktag, &newpredlocktag,
PredicateLockHashCodeFromTargetHashCode(&newpredlocktag, PredicateLockHashCodeFromTargetHashCode(&newpredlocktag,
heaptargettaghash), heaptargettaghash),
HASH_ENTER, &found); HASH_ENTER,
&found);
if (!found) if (!found)
{ {
SHMQueueInsertBefore(&(heaptarget->predicateLocks), SHMQueueInsertBefore(&(heaptarget->predicateLocks),
...@@ -4327,7 +4326,7 @@ FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer) ...@@ -4327,7 +4326,7 @@ FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
*/ */
static void static void
OnConflict_CheckForSerializationFailure(SERIALIZABLEXACT *reader, OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
SERIALIZABLEXACT *writer) SERIALIZABLEXACT *writer)
{ {
bool failure; bool failure;
......
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