Commit 4d567013 authored by Tom Lane's avatar Tom Lane

Remove AMI_OVERRIDE tests from tqual.c routines; they aren't necessary

and just slow down normal operations (only fractionally, but a cycle saved
is a cycle earned).  Improve documentation of AMI_OVERRIDE behavior.
parent 29737d83
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.50 2001/11/05 17:46:24 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.51 2002/05/25 20:00:11 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
...@@ -23,6 +23,18 @@ ...@@ -23,6 +23,18 @@
#include "access/transam.h" #include "access/transam.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 bool TransactionLogTest(TransactionId transactionId, XidStatus status); static bool TransactionLogTest(TransactionId transactionId, XidStatus status);
static void TransactionLogUpdate(TransactionId transactionId, static void TransactionLogUpdate(TransactionId transactionId,
XidStatus status); XidStatus status);
...@@ -160,7 +172,10 @@ bool /* true if given transaction committed */ ...@@ -160,7 +172,10 @@ bool /* true if given transaction committed */
TransactionIdDidCommit(TransactionId transactionId) TransactionIdDidCommit(TransactionId transactionId)
{ {
if (AMI_OVERRIDE) if (AMI_OVERRIDE)
{
Assert(transactionId == BootstrapTransactionId);
return true; return true;
}
return TransactionLogTest(transactionId, TRANSACTION_STATUS_COMMITTED); return TransactionLogTest(transactionId, TRANSACTION_STATUS_COMMITTED);
} }
...@@ -176,7 +191,10 @@ bool /* true if given transaction aborted */ ...@@ -176,7 +191,10 @@ bool /* true if given transaction aborted */
TransactionIdDidAbort(TransactionId transactionId) TransactionIdDidAbort(TransactionId transactionId)
{ {
if (AMI_OVERRIDE) if (AMI_OVERRIDE)
{
Assert(transactionId == BootstrapTransactionId);
return false; return false;
}
return TransactionLogTest(transactionId, TRANSACTION_STATUS_ABORTED); return TransactionLogTest(transactionId, TRANSACTION_STATUS_ABORTED);
} }
...@@ -193,7 +211,10 @@ bool ...@@ -193,7 +211,10 @@ bool
TransactionIdIsInProgress(TransactionId transactionId) TransactionIdIsInProgress(TransactionId transactionId)
{ {
if (AMI_OVERRIDE) if (AMI_OVERRIDE)
{
Assert(transactionId == BootstrapTransactionId);
return false; return false;
}
return TransactionLogTest(transactionId, TRANSACTION_STATUS_IN_PROGRESS); return TransactionLogTest(transactionId, TRANSACTION_STATUS_IN_PROGRESS);
} }
...@@ -215,9 +236,6 @@ TransactionIdIsInProgress(TransactionId transactionId) ...@@ -215,9 +236,6 @@ TransactionIdIsInProgress(TransactionId transactionId)
void void
TransactionIdCommit(TransactionId transactionId) TransactionIdCommit(TransactionId transactionId)
{ {
if (AMI_OVERRIDE)
return;
TransactionLogUpdate(transactionId, TRANSACTION_STATUS_COMMITTED); TransactionLogUpdate(transactionId, TRANSACTION_STATUS_COMMITTED);
} }
...@@ -231,9 +249,6 @@ TransactionIdCommit(TransactionId transactionId) ...@@ -231,9 +249,6 @@ TransactionIdCommit(TransactionId transactionId)
void void
TransactionIdAbort(TransactionId transactionId) TransactionIdAbort(TransactionId transactionId)
{ {
if (AMI_OVERRIDE)
return;
TransactionLogUpdate(transactionId, TRANSACTION_STATUS_ABORTED); TransactionLogUpdate(transactionId, TRANSACTION_STATUS_ABORTED);
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2000, PostgreSQL Global Development Group * Copyright (c) 2000, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.48 2001/10/28 06:25:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.49 2002/05/25 20:00:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -93,13 +93,6 @@ ReadNewTransactionId(void) ...@@ -93,13 +93,6 @@ ReadNewTransactionId(void)
{ {
TransactionId xid; TransactionId xid;
/*
* During bootstrap initialization, we return the special bootstrap
* transaction id.
*/
if (AMI_OVERRIDE)
return BootstrapTransactionId;
LWLockAcquire(XidGenLock, LW_SHARED); LWLockAcquire(XidGenLock, LW_SHARED);
xid = ShmemVariableCache->nextXid; xid = ShmemVariableCache->nextXid;
LWLockRelease(XidGenLock); LWLockRelease(XidGenLock);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.124 2002/05/22 21:40:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.125 2002/05/25 20:00:12 tgl Exp $
* *
* NOTES * NOTES
* Transaction aborts can now occur two ways: * Transaction aborts can now occur two ways:
...@@ -229,13 +229,6 @@ int CommitSiblings = 5; /* number of concurrent xacts needed to ...@@ -229,13 +229,6 @@ int CommitSiblings = 5; /* number of concurrent xacts needed to
static void (*_RollbackFunc) (void *) = NULL; static void (*_RollbackFunc) (void *) = NULL;
static void *_RollbackData = NULL; static void *_RollbackData = NULL;
/* ----------------
* catalog creation transaction bootstrapping flag.
* This should be eliminated and added to the transaction
* state stuff. -cim 3/19/90
* ----------------
*/
bool AMI_OVERRIDE = false;
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* transaction state accessors * transaction state accessors
...@@ -380,6 +373,11 @@ GetCurrentTransactionStartTimeUsec(int *msec) ...@@ -380,6 +373,11 @@ GetCurrentTransactionStartTimeUsec(int *msec)
/* -------------------------------- /* --------------------------------
* 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
...@@ -388,7 +386,10 @@ TransactionIdIsCurrentTransactionId(TransactionId xid) ...@@ -388,7 +386,10 @@ TransactionIdIsCurrentTransactionId(TransactionId xid)
TransactionState s = CurrentTransactionState; TransactionState s = CurrentTransactionState;
if (AMI_OVERRIDE) if (AMI_OVERRIDE)
{
Assert(xid == BootstrapTransactionId);
return false; return false;
}
return TransactionIdEquals(xid, s->transactionIdData); return TransactionIdEquals(xid, s->transactionIdData);
} }
...@@ -403,9 +404,6 @@ CommandIdIsCurrentCommandId(CommandId cid) ...@@ -403,9 +404,6 @@ CommandIdIsCurrentCommandId(CommandId cid)
{ {
TransactionState s = CurrentTransactionState; TransactionState s = CurrentTransactionState;
if (AMI_OVERRIDE)
return false;
return (cid == s->commandId) ? true : false; return (cid == s->commandId) ? true : false;
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.53 2002/05/24 18:57:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.54 2002/05/25 20:00:12 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -202,9 +202,6 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple) ...@@ -202,9 +202,6 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple)
bool bool
HeapTupleSatisfiesNow(HeapTupleHeader tuple) HeapTupleSatisfiesNow(HeapTupleHeader tuple)
{ {
if (AMI_OVERRIDE)
return true;
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
{ {
if (tuple->t_infomask & HEAP_XMIN_INVALID) if (tuple->t_infomask & HEAP_XMIN_INVALID)
...@@ -375,9 +372,6 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid) ...@@ -375,9 +372,6 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid)
{ {
HeapTupleHeader tuple = htuple->t_data; HeapTupleHeader tuple = htuple->t_data;
if (AMI_OVERRIDE)
return HeapTupleMayBeUpdated;
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
{ {
if (tuple->t_infomask & HEAP_XMIN_INVALID) if (tuple->t_infomask & HEAP_XMIN_INVALID)
...@@ -509,9 +503,6 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) ...@@ -509,9 +503,6 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple)
SnapshotDirty->xmin = SnapshotDirty->xmax = InvalidTransactionId; SnapshotDirty->xmin = SnapshotDirty->xmax = InvalidTransactionId;
ItemPointerSetInvalid(&(SnapshotDirty->tid)); ItemPointerSetInvalid(&(SnapshotDirty->tid));
if (AMI_OVERRIDE)
return true;
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
{ {
if (tuple->t_infomask & HEAP_XMIN_INVALID) if (tuple->t_infomask & HEAP_XMIN_INVALID)
...@@ -639,9 +630,6 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) ...@@ -639,9 +630,6 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple)
bool bool
HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot)
{ {
if (AMI_OVERRIDE)
return true;
/* XXX this is horribly ugly: */ /* XXX this is horribly ugly: */
if (ReferentialIntegritySnapshotOverride) if (ReferentialIntegritySnapshotOverride)
return HeapTupleSatisfiesNow(tuple); return HeapTupleSatisfiesNow(tuple);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: transam.h,v 1.44 2001/11/05 17:46:31 momjian Exp $ * $Id: transam.h,v 1.45 2002/05/25 20:00:12 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -92,6 +92,13 @@ typedef VariableCacheData *VariableCache; ...@@ -92,6 +92,13 @@ typedef VariableCacheData *VariableCache;
* ---------------- * ----------------
*/ */
/* in transam/transam.c */
extern bool AMI_OVERRIDE;
/* in transam/varsup.c */
extern VariableCache ShmemVariableCache;
/* /*
* prototypes for functions in transam/transam.c * prototypes for functions in transam/transam.c
*/ */
...@@ -111,15 +118,4 @@ extern TransactionId ReadNewTransactionId(void); ...@@ -111,15 +118,4 @@ extern TransactionId ReadNewTransactionId(void);
extern Oid GetNewObjectId(void); extern Oid GetNewObjectId(void);
extern void CheckMaxObjectId(Oid assigned_oid); extern void CheckMaxObjectId(Oid assigned_oid);
/* ----------------
* global variable extern declarations
* ----------------
*/
/* in xact.c */
extern bool AMI_OVERRIDE;
/* in varsup.c */
extern VariableCache ShmemVariableCache;
#endif /* TRAMSAM_H */ #endif /* TRAMSAM_H */
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