Hi, The proposed patch removes dead code in src/backend/storage/lmgr/predicate.c
If my understanding is correct, PageIsPredicateLocked() was added in dafaa3efb75 (Feb 2011) but its call was removed in 47ad79122bc (Mar 2011) and we have never used it since. It was mentioned in one recent discussion [1] but it was pointed out that it can't be used there either. If anyone believes that we should keep it alternatively we could cover it with tests or at least add an Assert() somewhere. [1]: http://postgr.es/m/CA%2BCOZaBo%2BZpKgMvxcdACUjNtdYipe9Em06iX5KHLTVaTmFibiw%40mail.gmail.com -- Best regards, Aleksander Alekseev
From 97db712762838b31aa54ba695b927731a9937907 Mon Sep 17 00:00:00 2001 From: Aleksander Alekseev <[email protected]> Date: Wed, 16 Sep 2026 16:08:03 +0300 Subject: [PATCH v1] Remove unused PageIsPredicateLocked() Oversight in 47ad79122bc. Author: Aleksander Alekseev <[email protected]> Reviewed-by: TODO FIXME Discussion: TODO FIXME --- src/backend/storage/lmgr/predicate.c | 40 ---------------------------- src/include/storage/predicate.h | 3 --- 2 files changed, 43 deletions(-) diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 0ae85b7d5b4..b888823f312 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -154,7 +154,6 @@ * * predicate lock reporting * GetPredicateLockStatusData(void) - * PageIsPredicateLocked(Relation relation, BlockNumber blkno) * * predicate lock maintenance * GetSerializableTransactionSnapshot(Snapshot snapshot) @@ -1920,45 +1919,6 @@ RegisterPredicateLockingXid(TransactionId xid) } -/* - * Check whether there are any predicate locks held by any transaction - * for the page at the given block number. - * - * Note that the transaction may be completed but not yet subject to - * cleanup due to overlapping serializable transactions. This must - * return valid information regardless of transaction isolation level. - * - * Also note that this doesn't check for a conflicting relation lock, - * just a lock specifically on the given page. - * - * One use is to support proper behavior during GiST index vacuum. - */ -bool -PageIsPredicateLocked(Relation relation, BlockNumber blkno) -{ - PREDICATELOCKTARGETTAG targettag; - uint32 targettaghash; - LWLock *partitionLock; - PREDICATELOCKTARGET *target; - - SET_PREDICATELOCKTARGETTAG_PAGE(targettag, - relation->rd_locator.dbOid, - relation->rd_id, - blkno); - - targettaghash = PredicateLockTargetTagHashCode(&targettag); - partitionLock = PredicateLockHashPartitionLock(targettaghash); - LWLockAcquire(partitionLock, LW_SHARED); - target = (PREDICATELOCKTARGET *) - hash_search_with_hash_value(PredicateLockTargetHash, - &targettag, targettaghash, - HASH_FIND, NULL); - LWLockRelease(partitionLock); - - return (target != NULL); -} - - /* * Check whether a particular lock is held by this transaction. * diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h index 443bffb58fd..ebc93b07bcd 100644 --- a/src/include/storage/predicate.h +++ b/src/include/storage/predicate.h @@ -43,9 +43,6 @@ typedef void *SerializableXactHandle; */ extern void CheckPointPredicate(void); -/* predicate lock reporting */ -extern bool PageIsPredicateLocked(Relation relation, BlockNumber blkno); - /* predicate lock maintenance */ extern Snapshot GetSerializableTransactionSnapshot(Snapshot snapshot); extern void SetSerializableTransactionSnapshot(Snapshot snapshot, -- 2.43.0
