aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/ipc/sinval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/ipc/sinval.c')
-rw-r--r--src/backend/storage/ipc/sinval.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c
index 985577c4a6c..1d43b1ead44 100644
--- a/src/backend/storage/ipc/sinval.c
+++ b/src/backend/storage/ipc/sinval.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.39 2001/08/25 18:52:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.40 2001/08/26 16:56:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,6 +20,8 @@
#include "storage/sinval.h"
#include "storage/sinvaladt.h"
#include "utils/tqual.h"
+#include "miscadmin.h"
+
SPINLOCK SInvalLock = (SPINLOCK) NULL;
@@ -210,17 +212,23 @@ TransactionIdIsInProgress(TransactionId xid)
}
/*
- * GetXmaxRecent -- returns oldest transaction that was running
- * when all current transaction were started.
- * It's used by vacuum to decide what deleted
- * tuples must be preserved in a table.
+ * GetOldestXmin -- returns oldest transaction that was running
+ * when any current transaction was started.
+ *
+ * If allDbs is TRUE then all backends are considered; if allDbs is FALSE
+ * then only backends running in my own database are considered.
*
- * Note: we include all currently running xids in the set of considered xids.
+ * This is used by VACUUM to decide which deleted tuples must be preserved
+ * in a table. allDbs = TRUE is needed for shared relations, but allDbs =
+ * FALSE is sufficient for non-shared relations, since only backends in my
+ * own database could ever see the tuples in them.
+ *
+ * Note: we include the currently running xids in the set of considered xids.
* This ensures that if a just-started xact has not yet set its snapshot,
* when it does set the snapshot it cannot set xmin less than what we compute.
*/
-void
-GetXmaxRecent(TransactionId *XmaxRecent)
+TransactionId
+GetOldestXmin(bool allDbs)
{
SISeg *segP = shmInvalBuffer;
ProcState *stateP = segP->procState;
@@ -238,24 +246,28 @@ GetXmaxRecent(TransactionId *XmaxRecent)
if (pOffset != INVALID_OFFSET)
{
PROC *proc = (PROC *) MAKE_PTR(pOffset);
- /* Fetch xid just once - see GetNewTransactionId */
- TransactionId xid = proc->xid;
- if (TransactionIdIsNormal(xid))
+ if (allDbs || proc->databaseId == MyDatabaseId)
{
- if (TransactionIdPrecedes(xid, result))
- result = xid;
- xid = proc->xmin;
+ /* Fetch xid just once - see GetNewTransactionId */
+ TransactionId xid = proc->xid;
+
if (TransactionIdIsNormal(xid))
+ {
if (TransactionIdPrecedes(xid, result))
result = xid;
+ xid = proc->xmin;
+ if (TransactionIdIsNormal(xid))
+ if (TransactionIdPrecedes(xid, result))
+ result = xid;
+ }
}
}
}
SpinRelease(SInvalLock);
- *XmaxRecent = result;
+ return result;
}
/*----------