From 4d567013cf127d10acb5da01c4a484bb635eebe8 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 25 May 2002 20:00:12 +0000 Subject: [PATCH] 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. --- src/backend/access/transam/transam.c | 29 +++++++++++++++++++++------- src/backend/access/transam/varsup.c | 9 +-------- src/backend/access/transam/xact.c | 20 +++++++++---------- src/backend/utils/time/tqual.c | 14 +------------- src/include/access/transam.h | 20 ++++++++----------- 5 files changed, 41 insertions(+), 51 deletions(-) diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index 5c26227748..34a13d3ae6 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -8,7 +8,7 @@ * * * 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 * This file contains the high level access-method interface to the @@ -23,6 +23,18 @@ #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 void TransactionLogUpdate(TransactionId transactionId, XidStatus status); @@ -160,7 +172,10 @@ bool /* true if given transaction committed */ TransactionIdDidCommit(TransactionId transactionId) { if (AMI_OVERRIDE) + { + Assert(transactionId == BootstrapTransactionId); return true; + } return TransactionLogTest(transactionId, TRANSACTION_STATUS_COMMITTED); } @@ -176,7 +191,10 @@ bool /* true if given transaction aborted */ TransactionIdDidAbort(TransactionId transactionId) { if (AMI_OVERRIDE) + { + Assert(transactionId == BootstrapTransactionId); return false; + } return TransactionLogTest(transactionId, TRANSACTION_STATUS_ABORTED); } @@ -193,7 +211,10 @@ bool TransactionIdIsInProgress(TransactionId transactionId) { if (AMI_OVERRIDE) + { + Assert(transactionId == BootstrapTransactionId); return false; + } return TransactionLogTest(transactionId, TRANSACTION_STATUS_IN_PROGRESS); } @@ -215,9 +236,6 @@ TransactionIdIsInProgress(TransactionId transactionId) void TransactionIdCommit(TransactionId transactionId) { - if (AMI_OVERRIDE) - return; - TransactionLogUpdate(transactionId, TRANSACTION_STATUS_COMMITTED); } @@ -231,9 +249,6 @@ TransactionIdCommit(TransactionId transactionId) void TransactionIdAbort(TransactionId transactionId) { - if (AMI_OVERRIDE) - return; - TransactionLogUpdate(transactionId, TRANSACTION_STATUS_ABORTED); } diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index cd58ed7ad8..80618e3de1 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -6,7 +6,7 @@ * Copyright (c) 2000, PostgreSQL Global Development Group * * 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) { TransactionId xid; - /* - * During bootstrap initialization, we return the special bootstrap - * transaction id. - */ - if (AMI_OVERRIDE) - return BootstrapTransactionId; - LWLockAcquire(XidGenLock, LW_SHARED); xid = ShmemVariableCache->nextXid; LWLockRelease(XidGenLock); diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index b874b4790a..f2a3caeabd 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -8,7 +8,7 @@ * * * 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 * Transaction aborts can now occur two ways: @@ -229,13 +229,6 @@ int CommitSiblings = 5; /* number of concurrent xacts needed to static void (*_RollbackFunc) (void *) = 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 @@ -380,6 +373,11 @@ GetCurrentTransactionStartTimeUsec(int *msec) /* -------------------------------- * 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 @@ -388,7 +386,10 @@ TransactionIdIsCurrentTransactionId(TransactionId xid) TransactionState s = CurrentTransactionState; if (AMI_OVERRIDE) + { + Assert(xid == BootstrapTransactionId); return false; + } return TransactionIdEquals(xid, s->transactionIdData); } @@ -403,9 +404,6 @@ CommandIdIsCurrentCommandId(CommandId cid) { TransactionState s = CurrentTransactionState; - if (AMI_OVERRIDE) - return false; - return (cid == s->commandId) ? true : false; } diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index 9f51304e68..31a2894b0a 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -16,7 +16,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * 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) bool HeapTupleSatisfiesNow(HeapTupleHeader tuple) { - if (AMI_OVERRIDE) - return true; - if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) { if (tuple->t_infomask & HEAP_XMIN_INVALID) @@ -375,9 +372,6 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid) { HeapTupleHeader tuple = htuple->t_data; - if (AMI_OVERRIDE) - return HeapTupleMayBeUpdated; - if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) { if (tuple->t_infomask & HEAP_XMIN_INVALID) @@ -509,9 +503,6 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) SnapshotDirty->xmin = SnapshotDirty->xmax = InvalidTransactionId; ItemPointerSetInvalid(&(SnapshotDirty->tid)); - if (AMI_OVERRIDE) - return true; - if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) { if (tuple->t_infomask & HEAP_XMIN_INVALID) @@ -639,9 +630,6 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) { - if (AMI_OVERRIDE) - return true; - /* XXX this is horribly ugly: */ if (ReferentialIntegritySnapshotOverride) return HeapTupleSatisfiesNow(tuple); diff --git a/src/include/access/transam.h b/src/include/access/transam.h index 6df60abb2d..d13e5608ba 100644 --- a/src/include/access/transam.h +++ b/src/include/access/transam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * 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; * ---------------- */ +/* in transam/transam.c */ +extern bool AMI_OVERRIDE; + +/* in transam/varsup.c */ +extern VariableCache ShmemVariableCache; + + /* * prototypes for functions in transam/transam.c */ @@ -111,15 +118,4 @@ extern TransactionId ReadNewTransactionId(void); extern Oid GetNewObjectId(void); 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 */