Remove long-unused TransactionIdIsActive()
authorAndres Freund <[email protected]>
Sat, 12 Jul 2025 15:00:44 +0000 (11:00 -0400)
committerAndres Freund <[email protected]>
Sat, 12 Jul 2025 15:00:44 +0000 (11:00 -0400)
TransactionIdIsActive() has not been used since bb38fb0d43c, in 2014. There
are no known uses in extensions either and it's hard to see valid uses for
it. Therefore remove TransactionIdIsActive().

Discussion: https://postgr.es/m/odgftbtwp5oq7cxjgf4kjkmyq7ypoftmqy7eqa7w3awnouzot6@hrwnl5tdqrgu

src/backend/storage/ipc/procarray.c
src/include/storage/procarray.h

index e5b945a9ee39cb537036e7a108eb428bddcde371..2418967def6954597ebbd7364943600402b16020 100644 (file)
@@ -1622,58 +1622,6 @@ TransactionIdIsInProgress(TransactionId xid)
    return false;
 }
 
-/*
- * TransactionIdIsActive -- is xid the top-level XID of an active backend?
- *
- * This differs from TransactionIdIsInProgress in that it ignores prepared
- * transactions, as well as transactions running on the primary if we're in
- * hot standby.  Also, we ignore subtransactions since that's not needed
- * for current uses.
- */
-bool
-TransactionIdIsActive(TransactionId xid)
-{
-   bool        result = false;
-   ProcArrayStruct *arrayP = procArray;
-   TransactionId *other_xids = ProcGlobal->xids;
-   int         i;
-
-   /*
-    * Don't bother checking a transaction older than RecentXmin; it could not
-    * possibly still be running.
-    */
-   if (TransactionIdPrecedes(xid, RecentXmin))
-       return false;
-
-   LWLockAcquire(ProcArrayLock, LW_SHARED);
-
-   for (i = 0; i < arrayP->numProcs; i++)
-   {
-       int         pgprocno = arrayP->pgprocnos[i];
-       PGPROC     *proc = &allProcs[pgprocno];
-       TransactionId pxid;
-
-       /* Fetch xid just once - see GetNewTransactionId */
-       pxid = UINT32_ACCESS_ONCE(other_xids[i]);
-
-       if (!TransactionIdIsValid(pxid))
-           continue;
-
-       if (proc->pid == 0)
-           continue;           /* ignore prepared transactions */
-
-       if (TransactionIdEquals(pxid, xid))
-       {
-           result = true;
-           break;
-       }
-   }
-
-   LWLockRelease(ProcArrayLock);
-
-   return result;
-}
-
 
 /*
  * Determine XID horizons.
index ef0b733ebe8be02243f8b25aa05bafeebd6c0190..e4877d88e8f9ea62cb2b26d352bb112e1cb886fe 100644 (file)
@@ -53,7 +53,6 @@ extern bool ProcArrayInstallRestoredXmin(TransactionId xmin, PGPROC *proc);
 extern RunningTransactions GetRunningTransactionData(void);
 
 extern bool TransactionIdIsInProgress(TransactionId xid);
-extern bool TransactionIdIsActive(TransactionId xid);
 extern TransactionId GetOldestNonRemovableTransactionId(Relation rel);
 extern TransactionId GetOldestTransactionIdConsideredRunning(void);
 extern TransactionId GetOldestActiveTransactionId(void);