diff options
Diffstat (limited to 'src/backend/access/transam')
-rw-r--r-- | src/backend/access/transam/transam.c | 127 | ||||
-rw-r--r-- | src/backend/access/transam/transsup.c | 225 | ||||
-rw-r--r-- | src/backend/access/transam/varsup.c | 124 | ||||
-rw-r--r-- | src/backend/access/transam/xact.c | 4 | ||||
-rw-r--r-- | src/backend/access/transam/xid.c | 40 |
5 files changed, 18 insertions, 502 deletions
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index 91c7ec8a3d2..02b7fa97693 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.13 1997/09/08 21:41:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.14 1997/11/02 15:24:42 vadim Exp $ * * NOTES * This file contains the high level access-method interface to the @@ -41,17 +41,14 @@ TransactionLogUpdate(TransactionId transactionId, */ Relation LogRelation = (Relation) NULL; -Relation TimeRelation = (Relation) NULL; Relation VariableRelation = (Relation) NULL; /* ---------------- * global variables holding cached transaction id's and statuses. * ---------------- */ -TransactionId cachedGetCommitTimeXid; -AbsoluteTime cachedGetCommitTime; -TransactionId cachedTestXid; -XidStatus cachedTestXidStatus; +TransactionId cachedTestXid; +XidStatus cachedTestXidStatus; /* ---------------- * transaction system constants @@ -118,7 +115,7 @@ SetRecoveryCheckingEnabled(bool state) #endif /* ---------------------------------------------------------------- - * postgres log/time access method interface + * postgres log access method interface * * TransactionLogTest * TransactionLogUpdate @@ -204,7 +201,6 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */ { BlockNumber blockNumber; bool fail = false; /* success/failure */ - AbsoluteTime currentTime; /* time of this transaction */ /* ---------------- * during initialization we don't record any updates. @@ -214,12 +210,6 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */ return; /* ---------------- - * get the transaction commit time - * ---------------- - */ - currentTime = getSystemTime(); - - /* ---------------- * update the log relation * ---------------- */ @@ -234,91 +224,12 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */ * update (invalidate) our single item TransactionLogTest cache. * ---------------- */ - TransactionIdStore(transactionId, &cachedTestXid); - cachedTestXidStatus = status; - - /* ---------------- - * now we update the time relation, if necessary - * (we only record commit times) - * ---------------- - */ - if (RelationIsValid(TimeRelation) && status == XID_COMMIT) + if (status != XID_COMMIT) { - TransComputeBlockNumber(TimeRelation, transactionId, &blockNumber); - TransBlockNumberSetCommitTime(TimeRelation, - blockNumber, - transactionId, - currentTime, - &fail); - /* ---------------- - * update (invalidate) our single item GetCommitTime cache. - * ---------------- - */ - TransactionIdStore(transactionId, &cachedGetCommitTimeXid); - cachedGetCommitTime = currentTime; + TransactionIdStore(transactionId, &cachedTestXid); + cachedTestXidStatus = status; } - /* ---------------- - * now we update the "last committed transaction" field - * in the variable relation if we are recording a commit. - * ---------------- - */ - if (RelationIsValid(VariableRelation) && status == XID_COMMIT) - UpdateLastCommittedXid(transactionId); -} - -/* -------------------------------- - * TransactionIdGetCommitTime - * -------------------------------- - */ - -AbsoluteTime /* commit time of transaction id */ -TransactionIdGetCommitTime(TransactionId transactionId) /* transaction id to - * test */ -{ - BlockNumber blockNumber; - AbsoluteTime commitTime; /* commit time */ - bool fail = false; /* success/failure */ - - /* ---------------- - * return invalid if we aren't running yet... - * ---------------- - */ - if (!RelationIsValid(TimeRelation)) - return INVALID_ABSTIME; - - /* ---------------- - * before going to the buffer manager, check our single - * item cache to see if we didn't just get the commit time - * a moment ago. - * ---------------- - */ - if (TransactionIdEquals(transactionId, cachedGetCommitTimeXid)) - return cachedGetCommitTime; - - /* ---------------- - * compute the item pointer corresponding to the - * page containing our transaction commit time - * ---------------- - */ - TransComputeBlockNumber(TimeRelation, transactionId, &blockNumber); - commitTime = TransBlockNumberGetCommitTime(TimeRelation, - blockNumber, - transactionId, - &fail); - - /* ---------------- - * update our cache and return the transaction commit time - * ---------------- - */ - if (!fail) - { - TransactionIdStore(transactionId, &cachedGetCommitTimeXid); - cachedGetCommitTime = commitTime; - return commitTime; - } - else - return INVALID_ABSTIME; } /* ---------------------------------------------------------------- @@ -472,7 +383,6 @@ void InitializeTransactionLog(void) { Relation logRelation; - Relation timeRelation; MemoryContext oldContext; /* ---------------- @@ -503,20 +413,17 @@ InitializeTransactionLog(void) * ---------------- */ logRelation = heap_openr(LogRelationName); - timeRelation = heap_openr(TimeRelationName); VariableRelation = heap_openr(VariableRelationName); /* ---------------- * XXX TransactionLogUpdate requires that LogRelation - * and TimeRelation are valid so we temporarily set - * them so we can initialize things properly. - * This could be done cleaner. + * is valid so we temporarily set it so we can initialize + * things properly. This could be done cleaner. * ---------------- */ LogRelation = logRelation; - TimeRelation = timeRelation; /* ---------------- - * if we have a virgin database, we initialize the log and time + * if we have a virgin database, we initialize the log * relation by committing the AmiTransactionId (id 512) and we * initialize the variable relation by setting the next available * transaction id to FirstTransactionId (id 514). OID initialization @@ -529,10 +436,12 @@ InitializeTransactionLog(void) /* ---------------- * SOMEDAY initialize the information stored in - * the headers of the log/time/variable relations. + * the headers of the log/variable relations. * ---------------- */ TransactionLogUpdate(AmiTransactionId, XID_COMMIT); + TransactionIdStore(AmiTransactionId, &cachedTestXid); + cachedTestXidStatus = XID_COMMIT; VariableRelationPutNextXid(FirstTransactionId); } @@ -547,7 +456,6 @@ InitializeTransactionLog(void) TransRecover(logRelation); } LogRelation = (Relation) NULL; - TimeRelation = (Relation) NULL; SpinRelease(OidGenLockId); /* ---------------- @@ -561,7 +469,6 @@ InitializeTransactionLog(void) * ---------------- */ LogRelation = logRelation; - TimeRelation = timeRelation; /* ---------------- * restore the memory context to the previous context @@ -651,15 +558,7 @@ TransactionIdCommit(TransactionId transactionId) if (AMI_OVERRIDE) return; - /* - * Within TransactionLogUpdate we call UpdateLastCommited() which - * assumes we have exclusive access to pg_variable. Therefore we need - * to get exclusive access before calling TransactionLogUpdate. -mer - * 18 Aug 1992 - */ - SpinAcquire(OidGenLockId); TransactionLogUpdate(transactionId, XID_COMMIT); - SpinRelease(OidGenLockId); } /* diff --git a/src/backend/access/transam/transsup.c b/src/backend/access/transam/transsup.c index 227c47ef546..a80b769982a 100644 --- a/src/backend/access/transam/transsup.c +++ b/src/backend/access/transam/transsup.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.13 1997/09/08 21:41:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.14 1997/11/02 15:24:44 vadim Exp $ * * NOTES * This file contains support functions for the high @@ -23,16 +23,10 @@ #include <access/xact.h> #include <storage/lmgr.h> -static AbsoluteTime -TransBlockGetCommitTime(Block tblock, - TransactionId transactionId); static XidStatus TransBlockGetXidStatus(Block tblock, TransactionId transactionId); static void -TransBlockSetCommitTime(Block tblock, - TransactionId transactionId, AbsoluteTime commitTime); -static void TransBlockSetXidStatus(Block tblock, TransactionId transactionId, XidStatus xstatus); @@ -73,8 +67,6 @@ TransComputeBlockNumber(Relation relation, /* relation to test */ */ if (relation == LogRelation) itemsPerBlock = TP_NumXidStatusPerBlock; - else if (relation == TimeRelation) - itemsPerBlock = TP_NumTimePerBlock; else elog(WARN, "TransComputeBlockNumber: unknown relation"); @@ -198,15 +190,6 @@ TransBlockGetXidStatus(Block tblock, BitIndex offset; /* ---------------- - * sanity check - * ---------------- - */ - if (tblock == NULL) - { - return XID_INVALID; - } - - /* ---------------- * calculate the index into the transaction data where * our transaction status is located * @@ -249,13 +232,6 @@ TransBlockSetXidStatus(Block tblock, BitIndex offset; /* ---------------- - * sanity check - * ---------------- - */ - if (tblock == NULL) - return; - - /* ---------------- * calculate the index into the transaction data where * we sould store our transaction status. * @@ -295,90 +271,6 @@ TransBlockSetXidStatus(Block tblock, } } -/* -------------------------------- - * TransBlockGetCommitTime - * - * This returns the transaction commit time for the - * specified transaction id in the trans block. - * -------------------------------- - */ -static AbsoluteTime -TransBlockGetCommitTime(Block tblock, - TransactionId transactionId) -{ - Index index; - AbsoluteTime *timeArray; - - /* ---------------- - * sanity check - * ---------------- - */ - if (tblock == NULL) - return INVALID_ABSTIME; - - /* ---------------- - * calculate the index into the transaction data where - * our transaction commit time is located - * - * XXX this will be replaced soon when we move to the - * new transaction id scheme -cim 3/23/90 - * - * The new scheme is here. -mer 5/24/92 - * ---------------- - */ - index = transactionId % TP_NumTimePerBlock; - - /* ---------------- - * return the commit time to the caller - * ---------------- - */ - timeArray = (AbsoluteTime *) tblock; - return (AbsoluteTime) - timeArray[index]; -} - -/* -------------------------------- - * TransBlockSetCommitTime - * - * This sets the commit time of the specified transaction - * -------------------------------- - */ -static void -TransBlockSetCommitTime(Block tblock, - TransactionId transactionId, - AbsoluteTime commitTime) -{ - Index index; - AbsoluteTime *timeArray; - - /* ---------------- - * sanity check - * ---------------- - */ - if (tblock == NULL) - return; - - - /* ---------------- - * calculate the index into the transaction data where - * we sould store our transaction status. - * - * XXX this will be replaced soon when we move to the - * new transaction id scheme -cim 3/23/90 - * - * The new scheme is here. -mer 5/24/92 - * ---------------- - */ - index = transactionId % TP_NumTimePerBlock; - - /* ---------------- - * store the transaction commit time at the specified index - * ---------------- - */ - timeArray = (AbsoluteTime *) tblock; - timeArray[index] = commitTime; -} - /* ---------------------------------------------------------------- * transam i/o support routines * ---------------------------------------------------------------- @@ -495,121 +387,6 @@ TransBlockNumberSetXidStatus(Relation relation, } /* -------------------------------- - * TransBlockNumberGetCommitTime - * -------------------------------- - */ -AbsoluteTime -TransBlockNumberGetCommitTime(Relation relation, - BlockNumber blockNumber, - TransactionId xid, - bool *failP) -{ - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing commit time */ - bool localfail; /* bool used if failP = NULL */ - AbsoluteTime xtime; /* commit time */ - - /* ---------------- - * SOMEDAY place a read lock on the time relation - * - * That someday is today 5 Aug. 1991 -mer - * ---------------- - */ - RelationSetLockForRead(relation); - - /* ---------------- - * get the block containing the transaction information - * ---------------- - */ - buffer = ReadBuffer(relation, blockNumber); - block = BufferGetBlock(buffer); - - /* ---------------- - * get the commit time from the block - * note, for now we always return false in failP. - * ---------------- - */ - if (failP == NULL) - failP = &localfail; - (*failP) = false; - - xtime = TransBlockGetCommitTime(block, xid); - - /* ---------------- - * release the buffer and return the commit time - * ---------------- - */ - ReleaseBuffer(buffer); - - /* ---------------- - * SOMEDAY release our lock on the time relation - * ---------------- - */ - RelationUnsetLockForRead(relation); - - if ((*failP) == false) - return xtime; - else - return INVALID_ABSTIME; - -} - -/* -------------------------------- - * TransBlockNumberSetCommitTime - * -------------------------------- - */ -void -TransBlockNumberSetCommitTime(Relation relation, - BlockNumber blockNumber, - TransactionId xid, - AbsoluteTime xtime, - bool *failP) -{ - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing commit time */ - bool localfail; /* bool used if failP = NULL */ - - /* ---------------- - * SOMEDAY gain exclusive access to the time relation - * - * That someday is today 5 Aug. 1991 -mer - * ---------------- - */ - RelationSetLockForWrite(relation); - - /* ---------------- - * get the block containing our commit time - * ---------------- - */ - buffer = ReadBuffer(relation, blockNumber); - block = BufferGetBlock(buffer); - - /* ---------------- - * attempt to update the commit time of the transaction on the block. - * if we are successful, write the block. otherwise release the buffer. - * note, for now we always return false in failP. - * ---------------- - */ - if (failP == NULL) - failP = &localfail; - (*failP) = false; - - TransBlockSetCommitTime(block, xid, xtime); - - if ((*failP) == false) - WriteBuffer(buffer); - else - ReleaseBuffer(buffer); - - /* ---------------- - * SOMEDAY release our lock on the time relation - * ---------------- - */ - RelationUnsetLockForWrite(relation); - -} - -/* -------------------------------- * TransGetLastRecordedTransaction * -------------------------------- */ diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 7fdbfd3bcc8..e082350cb66 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.12 1997/09/08 21:41:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.13 1997/11/02 15:24:45 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -23,9 +23,7 @@ static void GetNewObjectIdBlock(Oid *oid_return, int oid_block_size); static void VariableRelationGetNextOid(Oid *oid_return); static void VariableRelationGetNextXid(TransactionId *xidP); -static void VariableRelationPutLastXid(TransactionId xid); static void VariableRelationPutNextOid(Oid *oidP); -static void VariableRelationGetLastXid(TransactionId *xidP); /* --------------------- * spin lock for oid generation @@ -81,49 +79,6 @@ VariableRelationGetNextXid(TransactionId *xidP) } /* -------------------------------- - * VariableRelationGetLastXid - * -------------------------------- - */ -static void -VariableRelationGetLastXid(TransactionId *xidP) -{ - Buffer buf; - VariableRelationContents var; - - /* ---------------- - * We assume that a spinlock has been acquire to guarantee - * exclusive access to the variable relation. - * ---------------- - */ - - /* ---------------- - * do nothing before things are initialized - * ---------------- - */ - if (!RelationIsValid(VariableRelation)) - return; - - /* ---------------- - * read the variable page, get the the lastXid field and - * release the buffer - * ---------------- - */ - buf = ReadBuffer(VariableRelation, 0); - - if (!BufferIsValid(buf)) - { - SpinRelease(OidGenLockId); - elog(WARN, "VariableRelationGetNextXid: ReadBuffer failed"); - } - - var = (VariableRelationContents) BufferGetBlock(buf); - - TransactionIdStore(var->lastXidData, xidP); - - ReleaseBuffer(buf); -} - -/* -------------------------------- * VariableRelationPutNextXid * -------------------------------- */ @@ -170,49 +125,6 @@ VariableRelationPutNextXid(TransactionId xid) } /* -------------------------------- - * VariableRelationPutLastXid - * -------------------------------- - */ -static void -VariableRelationPutLastXid(TransactionId xid) -{ - Buffer buf; - VariableRelationContents var; - - /* ---------------- - * We assume that a spinlock has been acquire to guarantee - * exclusive access to the variable relation. - * ---------------- - */ - - /* ---------------- - * do nothing before things are initialized - * ---------------- - */ - if (!RelationIsValid(VariableRelation)) - return; - - /* ---------------- - * read the variable page, update the lastXid field and - * force the page back out to disk. - * ---------------- - */ - buf = ReadBuffer(VariableRelation, 0); - - if (!BufferIsValid(buf)) - { - SpinRelease(OidGenLockId); - elog(WARN, "VariableRelationPutLastXid: ReadBuffer failed"); - } - - var = (VariableRelationContents) BufferGetBlock(buf); - - TransactionIdStore(xid, &(var->lastXidData)); - - WriteBuffer(buf); -} - -/* -------------------------------- * VariableRelationGetNextOid * -------------------------------- */ @@ -449,40 +361,6 @@ GetNewTransactionId(TransactionId *xid) prefetched_xid_count--; } -/* ---------------- - * UpdateLastCommittedXid - * ---------------- - */ - -void -UpdateLastCommittedXid(TransactionId xid) -{ - TransactionId lastid; - - - /* - * we assume that spinlock OidGenLockId has been acquired prior to - * entering this function - */ - - /* ---------------- - * get the "last committed" transaction id from - * the variable relation page. - * ---------------- - */ - VariableRelationGetLastXid(&lastid); - - /* ---------------- - * if the transaction id is greater than the last committed - * transaction then we update the last committed transaction - * in the variable relation. - * ---------------- - */ - if (TransactionIdIsLessThan(lastid, xid)) - VariableRelationPutLastXid(xid); - -} - /* ---------------------------------------------------------------- * object id generation support * ---------------------------------------------------------------- diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index e5e1057bba2..ea5f1146d88 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.16 1997/09/08 21:41:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.17 1997/11/02 15:24:46 vadim Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -497,7 +497,7 @@ CommandCounterIncrement() if (CurrentTransactionStateData.commandId == FirstCommandId) { CommandIdCounterOverflowFlag = true; - elog(WARN, "You may only have 65535 commands per transaction"); + elog(WARN, "You may only have 2^32-1 commands per transaction"); } CurrentTransactionStateData.scanCommandId = diff --git a/src/backend/access/transam/xid.c b/src/backend/access/transam/xid.c index b60c6ba7ef3..4a0799ac2ca 100644 --- a/src/backend/access/transam/xid.c +++ b/src/backend/access/transam/xid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.10 1997/09/08 21:41:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.11 1997/11/02 15:24:47 vadim Exp $ * * OLD COMMENTS * XXX WARNING @@ -30,18 +30,6 @@ extern TransactionId DisabledTransactionId; extern TransactionId AmiTransactionId; extern TransactionId FirstTransactionId; -/* ---------------------------------------------------------------- - * TransactionIdIsValid - * - * Macro-ize me. - * ---------------------------------------------------------------- - */ -bool -TransactionIdIsValid(TransactionId transactionId) -{ - return ((bool) (transactionId != NullTransactionId)); -} - /* XXX char16 name for catalogs */ TransactionId xidin(char *representation) @@ -66,32 +54,6 @@ xidout(TransactionId transactionId) } /* ---------------------------------------------------------------- - * StoreInvalidTransactionId - * - * Maybe do away with Pointer types in these routines. - * Macro-ize this one. - * ---------------------------------------------------------------- - */ -void -StoreInvalidTransactionId(TransactionId *destination) -{ - *destination = NullTransactionId; -} - -/* ---------------------------------------------------------------- - * TransactionIdStore - * - * Macro-ize this one. - * ---------------------------------------------------------------- - */ -void -TransactionIdStore(TransactionId transactionId, - TransactionId *destination) -{ - *destination = transactionId; -} - -/* ---------------------------------------------------------------- * TransactionIdEquals * ---------------------------------------------------------------- */ |