提交 4aefe755 编写于 作者: T Tom Lane

Remove some no-longer-needed kluges for bootstrapping, in particular

the AMI_OVERRIDE flag.  The fact that TransactionLogFetch treats
BootstrapTransactionId as always committed is sufficient to make
bootstrap work, and getting rid of extra tests in heavily used code
paths seems like a win.  The files produced by initdb are demonstrably
the same after this change.
上级 57e3b0c9
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.182 2004/12/31 21:59:16 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.183 2005/02/20 21:46:47 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -715,10 +715,6 @@ heap_beginscan(Relation relation, Snapshot snapshot, ...@@ -715,10 +715,6 @@ heap_beginscan(Relation relation, Snapshot snapshot,
*/ */
RelationIncrementReferenceCount(relation); RelationIncrementReferenceCount(relation);
/* XXX someday assert SelfTimeQual if relkind == RELKIND_UNCATALOGED */
if (relation->rd_rel->relkind == RELKIND_UNCATALOGED)
snapshot = SnapshotSelf;
/* /*
* allocate and initialize scan descriptor * allocate and initialize scan descriptor
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.63 2004/12/31 21:59:29 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.64 2005/02/20 21:46:48 tgl Exp $
* *
* NOTES * NOTES
* This file contains the high level access-method interface to the * This file contains the high level access-method interface to the
...@@ -25,18 +25,6 @@ ...@@ -25,18 +25,6 @@
#include "utils/tqual.h" #include "utils/tqual.h"
/* ----------------
* Flag indicating that we are bootstrapping.
*
* Transaction ID generation is disabled during bootstrap; we just use
* BootstrapTransactionId. Also, the transaction ID status-check routines
* are short-circuited; they claim that BootstrapTransactionId has already
* committed, allowing tuples already inserted to be seen immediately.
* ----------------
*/
bool AMI_OVERRIDE = false;
static XidStatus TransactionLogFetch(TransactionId transactionId); static XidStatus TransactionLogFetch(TransactionId transactionId);
static void TransactionLogUpdate(TransactionId transactionId, static void TransactionLogUpdate(TransactionId transactionId,
XidStatus status); XidStatus status);
...@@ -134,18 +122,6 @@ TransactionLogMultiUpdate(int nxids, TransactionId *xids, XidStatus status) ...@@ -134,18 +122,6 @@ TransactionLogMultiUpdate(int nxids, TransactionId *xids, XidStatus status)
TransactionIdSetStatus(xids[i], status); TransactionIdSetStatus(xids[i], status);
} }
/* --------------------------------
* AmiTransactionOverride
*
* This function is used to manipulate the bootstrap flag.
* --------------------------------
*/
void
AmiTransactionOverride(bool flag)
{
AMI_OVERRIDE = flag;
}
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* Interface functions * Interface functions
* *
...@@ -184,12 +160,6 @@ TransactionIdDidCommit(TransactionId transactionId) ...@@ -184,12 +160,6 @@ TransactionIdDidCommit(TransactionId transactionId)
{ {
XidStatus xidstatus; XidStatus xidstatus;
if (AMI_OVERRIDE)
{
Assert(transactionId == BootstrapTransactionId);
return true;
}
xidstatus = TransactionLogFetch(transactionId); xidstatus = TransactionLogFetch(transactionId);
/* /*
...@@ -233,12 +203,6 @@ TransactionIdDidAbort(TransactionId transactionId) ...@@ -233,12 +203,6 @@ TransactionIdDidAbort(TransactionId transactionId)
{ {
XidStatus xidstatus; XidStatus xidstatus;
if (AMI_OVERRIDE)
{
Assert(transactionId == BootstrapTransactionId);
return false;
}
xidstatus = TransactionLogFetch(transactionId); xidstatus = TransactionLogFetch(transactionId);
/* /*
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2000-2005, PostgreSQL Global Development Group * Copyright (c) 2000-2005, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.61 2005/02/20 02:21:28 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.62 2005/02/20 21:46:48 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -41,7 +41,7 @@ GetNewTransactionId(bool isSubXact) ...@@ -41,7 +41,7 @@ GetNewTransactionId(bool isSubXact)
* During bootstrap initialization, we return the special bootstrap * During bootstrap initialization, we return the special bootstrap
* transaction id. * transaction id.
*/ */
if (AMI_OVERRIDE) if (IsBootstrapProcessingMode())
return BootstrapTransactionId; return BootstrapTransactionId;
LWLockAcquire(XidGenLock, LW_EXCLUSIVE); LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.196 2005/02/20 02:21:28 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.197 2005/02/20 21:46:48 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -450,22 +450,23 @@ GetCurrentTransactionNestLevel(void) ...@@ -450,22 +450,23 @@ GetCurrentTransactionNestLevel(void)
/* /*
* TransactionIdIsCurrentTransactionId * TransactionIdIsCurrentTransactionId
*
* During bootstrap, we cheat and say "it's not my transaction ID" even though
* it is. Along with transam.c's cheat to say that the bootstrap XID is
* already committed, this causes the tqual.c routines to see previously
* inserted tuples as committed, which is what we need during bootstrap.
*/ */
bool bool
TransactionIdIsCurrentTransactionId(TransactionId xid) TransactionIdIsCurrentTransactionId(TransactionId xid)
{ {
TransactionState s; TransactionState s;
if (AMI_OVERRIDE) /*
{ * We always say that BootstrapTransactionId is "not my transaction ID"
Assert(xid == BootstrapTransactionId); * even when it is (ie, during bootstrap). Along with the fact that
* transam.c always treats BootstrapTransactionId as already committed,
* this causes the tqual.c routines to see all tuples as committed,
* which is what we need during bootstrap. (Bootstrap mode only inserts
* tuples, it never updates or deletes them, so all tuples can be presumed
* good immediately.)
*/
if (xid == BootstrapTransactionId)
return false; return false;
}
/* /*
* We will return true for the Xid of the current subtransaction, any * We will return true for the Xid of the current subtransaction, any
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.139 2004/12/31 22:01:40 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.140 2005/02/20 21:46:49 tgl Exp $
* *
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
...@@ -328,11 +328,6 @@ InitPostgres(const char *dbname, const char *username) ...@@ -328,11 +328,6 @@ InitPostgres(const char *dbname, const char *username)
if (MyBackendId > MaxBackends || MyBackendId <= 0) if (MyBackendId > MaxBackends || MyBackendId <= 0)
elog(FATAL, "bad backend id: %d", MyBackendId); elog(FATAL, "bad backend id: %d", MyBackendId);
/*
* Initialize the transaction system override state.
*/
AmiTransactionOverride(bootstrap);
/* /*
* Initialize local process's access to XLOG. In bootstrap case we * Initialize local process's access to XLOG. In bootstrap case we
* may skip this since StartupXLOG() was run instead. * may skip this since StartupXLOG() was run instead.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/access/transam.h,v 1.52 2005/02/20 02:22:03 tgl Exp $ * $PostgreSQL: pgsql/src/include/access/transam.h,v 1.53 2005/02/20 21:46:50 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -100,9 +100,6 @@ typedef VariableCacheData *VariableCache; ...@@ -100,9 +100,6 @@ typedef VariableCacheData *VariableCache;
* ---------------- * ----------------
*/ */
/* in transam/transam.c */
extern bool AMI_OVERRIDE;
/* in transam/varsup.c */ /* in transam/varsup.c */
extern VariableCache ShmemVariableCache; extern VariableCache ShmemVariableCache;
...@@ -110,7 +107,6 @@ extern VariableCache ShmemVariableCache; ...@@ -110,7 +107,6 @@ extern VariableCache ShmemVariableCache;
/* /*
* prototypes for functions in transam/transam.c * prototypes for functions in transam/transam.c
*/ */
extern void AmiTransactionOverride(bool flag);
extern bool TransactionIdDidCommit(TransactionId transactionId); extern bool TransactionIdDidCommit(TransactionId transactionId);
extern bool TransactionIdDidAbort(TransactionId transactionId); extern bool TransactionIdDidAbort(TransactionId transactionId);
extern void TransactionIdCommit(TransactionId transactionId); extern void TransactionIdCommit(TransactionId transactionId);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册