mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Remove dashes in comments that don't need them, rewrap with pgindent.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.42 2001/03/22 03:59:17 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.43 2001/03/22 06:16:10 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains the high level access-method interface to the
|
||||
@@ -124,30 +124,25 @@ TransactionLogTest(TransactionId transactionId, /* transaction id to test */
|
||||
XidStatus xidstatus; /* recorded status of xid */
|
||||
bool fail = false; /* success/failure */
|
||||
|
||||
/* ----------------
|
||||
* during initialization consider all transactions
|
||||
* as having been committed
|
||||
* ----------------
|
||||
/*
|
||||
* during initialization consider all transactions as having been
|
||||
* committed
|
||||
*/
|
||||
if (!RelationIsValid(LogRelation))
|
||||
return (bool) (status == XID_COMMIT);
|
||||
|
||||
/* ----------------
|
||||
* before going to the buffer manager, check our single
|
||||
* item cache to see if we didn't just check the transaction
|
||||
* status a moment ago.
|
||||
* ----------------
|
||||
/*
|
||||
* before going to the buffer manager, check our single item cache to
|
||||
* see if we didn't just check the transaction status a moment ago.
|
||||
*/
|
||||
if (TransactionIdEquals(transactionId, cachedTestXid))
|
||||
return (bool)
|
||||
(status == cachedTestXidStatus);
|
||||
|
||||
/* ----------------
|
||||
* compute the item pointer corresponding to the
|
||||
* page containing our transaction id. We save the item in
|
||||
* our cache to speed up things if we happen to ask for the
|
||||
* same xid's status more than once.
|
||||
* ----------------
|
||||
/*
|
||||
* compute the item pointer corresponding to the page containing our
|
||||
* transaction id. We save the item in our cache to speed up things
|
||||
* if we happen to ask for the same xid's status more than once.
|
||||
*/
|
||||
TransComputeBlockNumber(LogRelation, transactionId, &blockNumber);
|
||||
xidstatus = TransBlockNumberGetXidStatus(LogRelation,
|
||||
@@ -169,9 +164,8 @@ TransactionLogTest(TransactionId transactionId, /* transaction id to test */
|
||||
return (bool) (status == xidstatus);
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* here the block didn't contain the information we wanted
|
||||
* ----------------
|
||||
/*
|
||||
* here the block didn't contain the information we wanted
|
||||
*/
|
||||
elog(ERROR, "TransactionLogTest: failed to get xidstatus");
|
||||
|
||||
@@ -192,16 +186,14 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */
|
||||
BlockNumber blockNumber;
|
||||
bool fail = false; /* success/failure */
|
||||
|
||||
/* ----------------
|
||||
* during initialization we don't record any updates.
|
||||
* ----------------
|
||||
/*
|
||||
* during initialization we don't record any updates.
|
||||
*/
|
||||
if (!RelationIsValid(LogRelation))
|
||||
return;
|
||||
|
||||
/* ----------------
|
||||
* update the log relation
|
||||
* ----------------
|
||||
/*
|
||||
* update the log relation
|
||||
*/
|
||||
TransComputeBlockNumber(LogRelation, transactionId, &blockNumber);
|
||||
TransBlockNumberSetXidStatus(LogRelation,
|
||||
@@ -292,43 +284,38 @@ static void
|
||||
TransRecover(Relation logRelation)
|
||||
{
|
||||
#ifdef NOT_USED
|
||||
/* ----------------
|
||||
* first get the last recorded transaction in the log.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* first get the last recorded transaction in the log.
|
||||
*/
|
||||
TransGetLastRecordedTransaction(logRelation, logLastXid, &fail);
|
||||
if (fail == true)
|
||||
elog(ERROR, "TransRecover: failed TransGetLastRecordedTransaction");
|
||||
|
||||
/* ----------------
|
||||
* next get the "last" and "next" variables
|
||||
* ----------------
|
||||
/*
|
||||
* next get the "last" and "next" variables
|
||||
*/
|
||||
VariableRelationGetLastXid(&varLastXid);
|
||||
VariableRelationGetNextXid(&varNextXid);
|
||||
|
||||
/* ----------------
|
||||
* intregity test (1)
|
||||
* ----------------
|
||||
/*
|
||||
* intregity test (1)
|
||||
*/
|
||||
if (TransactionIdIsLessThan(varNextXid, logLastXid))
|
||||
elog(ERROR, "TransRecover: varNextXid < logLastXid");
|
||||
|
||||
/* ----------------
|
||||
* intregity test (2)
|
||||
* ----------------
|
||||
/*
|
||||
* intregity test (2)
|
||||
*/
|
||||
|
||||
/* ----------------
|
||||
* intregity test (3)
|
||||
* ----------------
|
||||
/*
|
||||
* intregity test (3)
|
||||
*/
|
||||
|
||||
/* ----------------
|
||||
* here we have a valid "
|
||||
/*
|
||||
* here we have a valid "
|
||||
*
|
||||
* **** RESUME HERE ****
|
||||
* ----------------
|
||||
**** RESUME HERE ****
|
||||
*/
|
||||
varNextXid = TransactionIdDup(varLastXid);
|
||||
TransactionIdIncrement(&varNextXid);
|
||||
@@ -375,51 +362,45 @@ InitializeTransactionLog(void)
|
||||
Relation logRelation;
|
||||
MemoryContext oldContext;
|
||||
|
||||
/* ----------------
|
||||
* don't do anything during bootstrapping
|
||||
* ----------------
|
||||
/*
|
||||
* don't do anything during bootstrapping
|
||||
*/
|
||||
if (AMI_OVERRIDE)
|
||||
return;
|
||||
|
||||
/* ----------------
|
||||
* disable the transaction system so the access methods
|
||||
* don't interfere during initialization.
|
||||
* ----------------
|
||||
/*
|
||||
* disable the transaction system so the access methods don't
|
||||
* interfere during initialization.
|
||||
*/
|
||||
OverrideTransactionSystem(true);
|
||||
|
||||
/* ----------------
|
||||
* make sure allocations occur within the top memory context
|
||||
* so that our log management structures are protected from
|
||||
* garbage collection at the end of every transaction.
|
||||
* ----------------
|
||||
/*
|
||||
* make sure allocations occur within the top memory context so that
|
||||
* our log management structures are protected from garbage collection
|
||||
* at the end of every transaction.
|
||||
*/
|
||||
oldContext = MemoryContextSwitchTo(TopMemoryContext);
|
||||
|
||||
/* ----------------
|
||||
* first open the log and time relations
|
||||
* (these are created by amiint so they are guaranteed to exist)
|
||||
* ----------------
|
||||
/*
|
||||
* first open the log and time relations (these are created by amiint
|
||||
* so they are guaranteed to exist)
|
||||
*/
|
||||
logRelation = heap_openr(LogRelationName, NoLock);
|
||||
VariableRelation = heap_openr(VariableRelationName, NoLock);
|
||||
|
||||
/* ----------------
|
||||
* XXX TransactionLogUpdate requires that LogRelation
|
||||
* is valid so we temporarily set it so we can initialize
|
||||
* things properly. This could be done cleaner.
|
||||
* ----------------
|
||||
/*
|
||||
* XXX TransactionLogUpdate requires that LogRelation is valid so we
|
||||
* temporarily set it so we can initialize things properly. This could
|
||||
* be done cleaner.
|
||||
*/
|
||||
LogRelation = logRelation;
|
||||
|
||||
/* ----------------
|
||||
* 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
|
||||
* happens as a side effect of bootstrapping in varsup.c.
|
||||
* ----------------
|
||||
/*
|
||||
* 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 happens as a side
|
||||
* effect of bootstrapping in varsup.c.
|
||||
*/
|
||||
SpinAcquire(OidGenLockId);
|
||||
if (!TransactionIdDidCommit(AmiTransactionId))
|
||||
@@ -433,33 +414,30 @@ InitializeTransactionLog(void)
|
||||
}
|
||||
else if (RecoveryCheckingEnabled())
|
||||
{
|
||||
/* ----------------
|
||||
* if we have a pre-initialized database and if the
|
||||
* perform recovery checking flag was passed then we
|
||||
* do our database integrity checking.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* if we have a pre-initialized database and if the perform
|
||||
* recovery checking flag was passed then we do our database
|
||||
* integrity checking.
|
||||
*/
|
||||
TransRecover(logRelation);
|
||||
}
|
||||
LogRelation = (Relation) NULL;
|
||||
SpinRelease(OidGenLockId);
|
||||
|
||||
/* ----------------
|
||||
* now re-enable the transaction system
|
||||
* ----------------
|
||||
/*
|
||||
* now re-enable the transaction system
|
||||
*/
|
||||
OverrideTransactionSystem(false);
|
||||
|
||||
/* ----------------
|
||||
* instantiate the global variables
|
||||
* ----------------
|
||||
/*
|
||||
* instantiate the global variables
|
||||
*/
|
||||
LogRelation = logRelation;
|
||||
|
||||
/* ----------------
|
||||
* restore the memory context to the previous context
|
||||
* before we return from initialization.
|
||||
* ----------------
|
||||
/*
|
||||
* restore the memory context to the previous context before we return
|
||||
* from initialization.
|
||||
*/
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.29 2001/03/22 03:59:17 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.30 2001/03/22 06:16:10 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains support functions for the high
|
||||
@@ -56,11 +56,9 @@ TransComputeBlockNumber(Relation relation, /* relation to test */
|
||||
{
|
||||
long itemsPerBlock = 0;
|
||||
|
||||
/* ----------------
|
||||
* we calculate the block number of our transaction
|
||||
* by dividing the transaction id by the number of
|
||||
* transaction things per block.
|
||||
* ----------------
|
||||
/*
|
||||
* we calculate the block number of our transaction by dividing the
|
||||
* transaction id by the number of transaction things per block.
|
||||
*/
|
||||
if (relation == LogRelation)
|
||||
itemsPerBlock = TP_NumXidStatusPerBlock;
|
||||
@@ -109,18 +107,16 @@ TransBlockGetLastTransactionIdStatus(Block tblock,
|
||||
BitIndex offset;
|
||||
XidStatus xstatus;
|
||||
|
||||
/* ----------------
|
||||
* sanity check
|
||||
* ----------------
|
||||
/*
|
||||
* sanity check
|
||||
*/
|
||||
Assert((tblock != NULL));
|
||||
|
||||
/* ----------------
|
||||
* search downward from the top of the block data, looking
|
||||
* for the first Non-in progress transaction status. Since we
|
||||
* are scanning backward, this will be last recorded transaction
|
||||
* status on the block.
|
||||
* ----------------
|
||||
/*
|
||||
* search downward from the top of the block data, looking for the
|
||||
* first Non-in progress transaction status. Since we are scanning
|
||||
* backward, this will be last recorded transaction status on the
|
||||
* block.
|
||||
*/
|
||||
maxIndex = TP_NumXidStatusPerBlock;
|
||||
for (index = maxIndex; index > 0; index--)
|
||||
@@ -131,11 +127,10 @@ TransBlockGetLastTransactionIdStatus(Block tblock,
|
||||
|
||||
xstatus = (bit1 | bit2);
|
||||
|
||||
/* ----------------
|
||||
* here we have the status of some transaction, so test
|
||||
* if the status is recorded as "in progress". If so, then
|
||||
* we save the transaction id in the place specified by the caller.
|
||||
* ----------------
|
||||
/*
|
||||
* here we have the status of some transaction, so test if the
|
||||
* status is recorded as "in progress". If so, then we save the
|
||||
* transaction id in the place specified by the caller.
|
||||
*/
|
||||
if (xstatus != XID_INPROGRESS)
|
||||
{
|
||||
@@ -148,12 +143,11 @@ TransBlockGetLastTransactionIdStatus(Block tblock,
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* if we get here and index is 0 it means we couldn't find
|
||||
* a non-inprogress transaction on the block. For now we just
|
||||
* return this info to the user. They can check if the return
|
||||
* status is "in progress" to know this condition has arisen.
|
||||
* ----------------
|
||||
/*
|
||||
* if we get here and index is 0 it means we couldn't find a
|
||||
* non-inprogress transaction on the block. For now we just return
|
||||
* this info to the user. They can check if the return status is "in
|
||||
* progress" to know this condition has arisen.
|
||||
*/
|
||||
if (index == 0)
|
||||
{
|
||||
@@ -161,9 +155,8 @@ TransBlockGetLastTransactionIdStatus(Block tblock,
|
||||
TransactionIdStore(baseXid, returnXidP);
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* return the status to the user
|
||||
* ----------------
|
||||
/*
|
||||
* return the status to the user
|
||||
*/
|
||||
return xstatus;
|
||||
}
|
||||
@@ -200,17 +193,15 @@ TransBlockGetXidStatus(Block tblock,
|
||||
*/
|
||||
index = transactionId % TP_NumXidStatusPerBlock;
|
||||
|
||||
/* ----------------
|
||||
* get the data at the specified index
|
||||
* ----------------
|
||||
/*
|
||||
* get the data at the specified index
|
||||
*/
|
||||
offset = BitIndexOf(index);
|
||||
bit1 = ((bits8) BitArrayBitIsSet((BitArray) tblock, offset++)) << 1;
|
||||
bit2 = (bits8) BitArrayBitIsSet((BitArray) tblock, offset);
|
||||
|
||||
/* ----------------
|
||||
* return the transaction status to the caller
|
||||
* ----------------
|
||||
/*
|
||||
* return the transaction status to the caller
|
||||
*/
|
||||
return (XidStatus) (bit1 | bit2);
|
||||
}
|
||||
@@ -245,9 +236,8 @@ TransBlockSetXidStatus(Block tblock,
|
||||
|
||||
offset = BitIndexOf(index);
|
||||
|
||||
/* ----------------
|
||||
* store the transaction value at the specified offset
|
||||
* ----------------
|
||||
/*
|
||||
* store the transaction value at the specified offset
|
||||
*/
|
||||
switch (xstatus)
|
||||
{
|
||||
@@ -291,18 +281,16 @@ TransBlockNumberGetXidStatus(Relation relation,
|
||||
XidStatus xstatus; /* recorded status of xid */
|
||||
bool localfail; /* bool used if failP = NULL */
|
||||
|
||||
/* ----------------
|
||||
* get the page containing the transaction information
|
||||
* ----------------
|
||||
/*
|
||||
* get the page containing the transaction information
|
||||
*/
|
||||
buffer = ReadBuffer(relation, blockNumber);
|
||||
LockBuffer(buffer, BUFFER_LOCK_SHARE);
|
||||
block = BufferGetBlock(buffer);
|
||||
|
||||
/* ----------------
|
||||
* get the status from the block. note, for now we always
|
||||
* return false in failP.
|
||||
* ----------------
|
||||
/*
|
||||
* get the status from the block. note, for now we always return
|
||||
* false in failP.
|
||||
*/
|
||||
if (failP == NULL)
|
||||
failP = &localfail;
|
||||
@@ -310,9 +298,8 @@ TransBlockNumberGetXidStatus(Relation relation,
|
||||
|
||||
xstatus = TransBlockGetXidStatus(block, xid);
|
||||
|
||||
/* ----------------
|
||||
* release the buffer and return the status
|
||||
* ----------------
|
||||
/*
|
||||
* release the buffer and return the status
|
||||
*/
|
||||
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
|
||||
ReleaseBuffer(buffer);
|
||||
@@ -335,19 +322,17 @@ TransBlockNumberSetXidStatus(Relation relation,
|
||||
Block block; /* block containing xstatus */
|
||||
bool localfail; /* bool used if failP = NULL */
|
||||
|
||||
/* ----------------
|
||||
* get the block containing the transaction status
|
||||
* ----------------
|
||||
/*
|
||||
* get the block containing the transaction status
|
||||
*/
|
||||
buffer = ReadBuffer(relation, blockNumber);
|
||||
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
|
||||
block = BufferGetBlock(buffer);
|
||||
|
||||
/* ----------------
|
||||
* attempt to update the status 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.
|
||||
* ----------------
|
||||
/*
|
||||
* attempt to update the status 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;
|
||||
@@ -381,22 +366,20 @@ TransGetLastRecordedTransaction(Relation relation,
|
||||
|
||||
(*failP) = false;
|
||||
|
||||
/* ----------------
|
||||
* SOMEDAY gain exclusive access to the log relation
|
||||
/*
|
||||
* SOMEDAY gain exclusive access to the log relation
|
||||
*
|
||||
* That someday is today 5 Aug. 1991 -mer
|
||||
* It looks to me like we only need to set a read lock here, despite
|
||||
* the above comment about exclusive access. The block is never
|
||||
* actually written into, we only check status bits.
|
||||
* ----------------
|
||||
* That someday is today 5 Aug. 1991 -mer It looks to me like we only
|
||||
* need to set a read lock here, despite the above comment about
|
||||
* exclusive access. The block is never actually written into, we
|
||||
* only check status bits.
|
||||
*/
|
||||
RelationSetLockForRead(relation);
|
||||
|
||||
/* ----------------
|
||||
* we assume the last block of the log contains the last
|
||||
* recorded transaction. If the relation is empty we return
|
||||
* failure to the user.
|
||||
* ----------------
|
||||
/*
|
||||
* we assume the last block of the log contains the last recorded
|
||||
* transaction. If the relation is empty we return failure to the
|
||||
* user.
|
||||
*/
|
||||
n = RelationGetNumberOfBlocks(relation);
|
||||
if (n == 0)
|
||||
@@ -405,17 +388,15 @@ TransGetLastRecordedTransaction(Relation relation,
|
||||
return;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* get the block containing the transaction information
|
||||
* ----------------
|
||||
/*
|
||||
* get the block containing the transaction information
|
||||
*/
|
||||
blockNumber = n - 1;
|
||||
buffer = ReadBuffer(relation, blockNumber);
|
||||
block = BufferGetBlock(buffer);
|
||||
|
||||
/* ----------------
|
||||
* get the last xid on the block
|
||||
* ----------------
|
||||
/*
|
||||
* get the last xid on the block
|
||||
*/
|
||||
baseXid = blockNumber * TP_NumXidStatusPerBlock;
|
||||
|
||||
@@ -424,9 +405,8 @@ TransGetLastRecordedTransaction(Relation relation,
|
||||
|
||||
ReleaseBuffer(buffer);
|
||||
|
||||
/* ----------------
|
||||
* SOMEDAY release our lock on the log relation
|
||||
* ----------------
|
||||
/*
|
||||
* SOMEDAY release our lock on the log relation
|
||||
*/
|
||||
RelationUnsetLockForRead(relation);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.100 2001/03/22 03:59:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.101 2001/03/22 06:16:10 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Transaction aborts can now occur two ways:
|
||||
@@ -396,17 +396,15 @@ GetCurrentTransactionId(void)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* if the transaction system is disabled, we return
|
||||
* the special "disabled" transaction id.
|
||||
* ----------------
|
||||
/*
|
||||
* if the transaction system is disabled, we return the special
|
||||
* "disabled" transaction id.
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return (TransactionId) DisabledTransactionId;
|
||||
|
||||
/* ----------------
|
||||
* otherwise return the current transaction id.
|
||||
* ----------------
|
||||
/*
|
||||
* otherwise return the current transaction id.
|
||||
*/
|
||||
return (TransactionId) s->transactionIdData;
|
||||
}
|
||||
@@ -421,10 +419,9 @@ GetCurrentCommandId(void)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* if the transaction system is disabled, we return
|
||||
* the special "disabled" command id.
|
||||
* ----------------
|
||||
/*
|
||||
* if the transaction system is disabled, we return the special
|
||||
* "disabled" command id.
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return (CommandId) DisabledCommandId;
|
||||
@@ -437,10 +434,9 @@ GetScanCommandId(void)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* if the transaction system is disabled, we return
|
||||
* the special "disabled" command id.
|
||||
* ----------------
|
||||
/*
|
||||
* if the transaction system is disabled, we return the special
|
||||
* "disabled" command id.
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return (CommandId) DisabledCommandId;
|
||||
@@ -458,10 +454,9 @@ GetCurrentTransactionStartTime(void)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* if the transaction system is disabled, we return
|
||||
* the special "disabled" starting time.
|
||||
* ----------------
|
||||
/*
|
||||
* if the transaction system is disabled, we return the special
|
||||
* "disabled" starting time.
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return (AbsoluteTime) DisabledStartTime;
|
||||
@@ -608,16 +603,15 @@ AtStart_Locks(void)
|
||||
static void
|
||||
AtStart_Memory(void)
|
||||
{
|
||||
/* ----------------
|
||||
* We shouldn't have any transaction contexts already.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* We shouldn't have any transaction contexts already.
|
||||
*/
|
||||
Assert(TopTransactionContext == NULL);
|
||||
Assert(TransactionCommandContext == NULL);
|
||||
|
||||
/* ----------------
|
||||
* Create a toplevel context for the transaction.
|
||||
* ----------------
|
||||
/*
|
||||
* Create a toplevel context for the transaction.
|
||||
*/
|
||||
TopTransactionContext =
|
||||
AllocSetContextCreate(TopMemoryContext,
|
||||
@@ -626,9 +620,8 @@ AtStart_Memory(void)
|
||||
ALLOCSET_DEFAULT_INITSIZE,
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
|
||||
/* ----------------
|
||||
* Create a statement-level context and make it active.
|
||||
* ----------------
|
||||
/*
|
||||
* Create a statement-level context and make it active.
|
||||
*/
|
||||
TransactionCommandContext =
|
||||
AllocSetContextCreate(TopTransactionContext,
|
||||
@@ -732,9 +725,9 @@ RecordTransactionCommit()
|
||||
static void
|
||||
AtCommit_Cache(void)
|
||||
{
|
||||
/* ----------------
|
||||
|
||||
/*
|
||||
* Make catalog changes visible to all backend.
|
||||
* ----------------
|
||||
*/
|
||||
RegisterInvalid(true);
|
||||
}
|
||||
@@ -746,9 +739,9 @@ AtCommit_Cache(void)
|
||||
static void
|
||||
AtCommit_LocalCache(void)
|
||||
{
|
||||
/* ----------------
|
||||
|
||||
/*
|
||||
* Make catalog changes visible to me for the next command.
|
||||
* ----------------
|
||||
*/
|
||||
ImmediateLocalInvalidation(true);
|
||||
}
|
||||
@@ -760,11 +753,11 @@ AtCommit_LocalCache(void)
|
||||
static void
|
||||
AtCommit_Locks(void)
|
||||
{
|
||||
/* ----------------
|
||||
* XXX What if ProcReleaseLocks fails? (race condition?)
|
||||
|
||||
/*
|
||||
* XXX What if ProcReleaseLocks fails? (race condition?)
|
||||
*
|
||||
* Then you're up a creek! -mer 5/24/92
|
||||
* ----------------
|
||||
* Then you're up a creek! -mer 5/24/92
|
||||
*/
|
||||
ProcReleaseLocks(true);
|
||||
}
|
||||
@@ -776,17 +769,16 @@ AtCommit_Locks(void)
|
||||
static void
|
||||
AtCommit_Memory(void)
|
||||
{
|
||||
/* ----------------
|
||||
* Now that we're "out" of a transaction, have the
|
||||
* system allocate things in the top memory context instead
|
||||
* of per-transaction contexts.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* Now that we're "out" of a transaction, have the system allocate
|
||||
* things in the top memory context instead of per-transaction
|
||||
* contexts.
|
||||
*/
|
||||
MemoryContextSwitchTo(TopMemoryContext);
|
||||
|
||||
/* ----------------
|
||||
* Release all transaction-local memory.
|
||||
* ----------------
|
||||
/*
|
||||
* Release all transaction-local memory.
|
||||
*/
|
||||
Assert(TopTransactionContext != NULL);
|
||||
MemoryContextDelete(TopTransactionContext);
|
||||
@@ -862,11 +854,11 @@ AtAbort_Cache(void)
|
||||
static void
|
||||
AtAbort_Locks(void)
|
||||
{
|
||||
/* ----------------
|
||||
* XXX What if ProcReleaseLocks() fails? (race condition?)
|
||||
|
||||
/*
|
||||
* XXX What if ProcReleaseLocks() fails? (race condition?)
|
||||
*
|
||||
* Then you're up a creek without a paddle! -mer
|
||||
* ----------------
|
||||
* Then you're up a creek without a paddle! -mer
|
||||
*/
|
||||
ProcReleaseLocks(false);
|
||||
}
|
||||
@@ -879,21 +871,20 @@ AtAbort_Locks(void)
|
||||
static void
|
||||
AtAbort_Memory(void)
|
||||
{
|
||||
/* ----------------
|
||||
* Make sure we are in a valid context (not a child of
|
||||
* TransactionCommandContext...). Note that it is possible
|
||||
* for this code to be called when we aren't in a transaction
|
||||
* at all; go directly to TopMemoryContext in that case.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* Make sure we are in a valid context (not a child of
|
||||
* TransactionCommandContext...). Note that it is possible for this
|
||||
* code to be called when we aren't in a transaction at all; go
|
||||
* directly to TopMemoryContext in that case.
|
||||
*/
|
||||
if (TransactionCommandContext != NULL)
|
||||
{
|
||||
MemoryContextSwitchTo(TransactionCommandContext);
|
||||
|
||||
/* ----------------
|
||||
* We do not want to destroy transaction contexts yet,
|
||||
* but it should be OK to delete any command-local memory.
|
||||
* ----------------
|
||||
/*
|
||||
* We do not want to destroy transaction contexts yet, but it
|
||||
* should be OK to delete any command-local memory.
|
||||
*/
|
||||
MemoryContextResetAndDeleteChildren(TransactionCommandContext);
|
||||
}
|
||||
@@ -914,17 +905,16 @@ AtAbort_Memory(void)
|
||||
static void
|
||||
AtCleanup_Memory(void)
|
||||
{
|
||||
/* ----------------
|
||||
* Now that we're "out" of a transaction, have the
|
||||
* system allocate things in the top memory context instead
|
||||
* of per-transaction contexts.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* Now that we're "out" of a transaction, have the system allocate
|
||||
* things in the top memory context instead of per-transaction
|
||||
* contexts.
|
||||
*/
|
||||
MemoryContextSwitchTo(TopMemoryContext);
|
||||
|
||||
/* ----------------
|
||||
* Release all transaction-local memory.
|
||||
* ----------------
|
||||
/*
|
||||
* Release all transaction-local memory.
|
||||
*/
|
||||
if (TopTransactionContext != NULL)
|
||||
MemoryContextDelete(TopTransactionContext);
|
||||
@@ -951,61 +941,54 @@ StartTransaction(void)
|
||||
FreeXactSnapshot();
|
||||
XactIsoLevel = DefaultXactIsoLevel;
|
||||
|
||||
/* ----------------
|
||||
* Check the current transaction state. If the transaction system
|
||||
* is switched off, or if we're already in a transaction, do nothing.
|
||||
* We're already in a transaction when the monitor sends a null
|
||||
* command to the backend to flush the comm channel. This is a
|
||||
* hacky fix to a communications problem, and we keep having to
|
||||
* deal with it here. We should fix the comm channel code. mao 080891
|
||||
* ----------------
|
||||
/*
|
||||
* Check the current transaction state. If the transaction system is
|
||||
* switched off, or if we're already in a transaction, do nothing.
|
||||
* We're already in a transaction when the monitor sends a null
|
||||
* command to the backend to flush the comm channel. This is a hacky
|
||||
* fix to a communications problem, and we keep having to deal with it
|
||||
* here. We should fix the comm channel code. mao 080891
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED || s->state == TRANS_INPROGRESS)
|
||||
return;
|
||||
|
||||
/* ----------------
|
||||
* set the current transaction state information
|
||||
* appropriately during start processing
|
||||
* ----------------
|
||||
/*
|
||||
* set the current transaction state information appropriately during
|
||||
* start processing
|
||||
*/
|
||||
s->state = TRANS_START;
|
||||
|
||||
SetReindexProcessing(false);
|
||||
|
||||
/* ----------------
|
||||
* generate a new transaction id
|
||||
* ----------------
|
||||
/*
|
||||
* generate a new transaction id
|
||||
*/
|
||||
GetNewTransactionId(&(s->transactionIdData));
|
||||
|
||||
XactLockTableInsert(s->transactionIdData);
|
||||
|
||||
/* ----------------
|
||||
* initialize current transaction state fields
|
||||
* ----------------
|
||||
/*
|
||||
* initialize current transaction state fields
|
||||
*/
|
||||
s->commandId = FirstCommandId;
|
||||
s->scanCommandId = FirstCommandId;
|
||||
s->startTime = GetCurrentAbsoluteTime();
|
||||
|
||||
/* ----------------
|
||||
* initialize the various transaction subsystems
|
||||
* ----------------
|
||||
/*
|
||||
* initialize the various transaction subsystems
|
||||
*/
|
||||
AtStart_Memory();
|
||||
AtStart_Cache();
|
||||
AtStart_Locks();
|
||||
|
||||
/* ----------------
|
||||
* Tell the trigger manager to we're starting a transaction
|
||||
* ----------------
|
||||
/*
|
||||
* Tell the trigger manager to we're starting a transaction
|
||||
*/
|
||||
DeferredTriggerBeginXact();
|
||||
|
||||
/* ----------------
|
||||
* done with start processing, set current transaction
|
||||
* state to "in progress"
|
||||
* ----------------
|
||||
/*
|
||||
* done with start processing, set current transaction state to "in
|
||||
* progress"
|
||||
*/
|
||||
s->state = TRANS_INPROGRESS;
|
||||
|
||||
@@ -1034,9 +1017,8 @@ CommitTransaction(void)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* check the current transaction state
|
||||
* ----------------
|
||||
/*
|
||||
* check the current transaction state
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return;
|
||||
@@ -1047,24 +1029,21 @@ CommitTransaction(void)
|
||||
/* Prevent cancel/die interrupt while cleaning up */
|
||||
HOLD_INTERRUPTS();
|
||||
|
||||
/* ----------------
|
||||
* Tell the trigger manager that this transaction is about to be
|
||||
* committed. He'll invoke all trigger deferred until XACT before
|
||||
* we really start on committing the transaction.
|
||||
* ----------------
|
||||
/*
|
||||
* Tell the trigger manager that this transaction is about to be
|
||||
* committed. He'll invoke all trigger deferred until XACT before we
|
||||
* really start on committing the transaction.
|
||||
*/
|
||||
DeferredTriggerEndXact();
|
||||
|
||||
/* ----------------
|
||||
* set the current transaction state information
|
||||
* appropriately during the abort processing
|
||||
* ----------------
|
||||
/*
|
||||
* set the current transaction state information appropriately during
|
||||
* the abort processing
|
||||
*/
|
||||
s->state = TRANS_COMMIT;
|
||||
|
||||
/* ----------------
|
||||
* do commit processing
|
||||
* ----------------
|
||||
/*
|
||||
* do commit processing
|
||||
*/
|
||||
|
||||
/* handle commit for large objects [ PA, 7/17/98 ] */
|
||||
@@ -1109,10 +1088,9 @@ CommitTransaction(void)
|
||||
|
||||
SharedBufferChanged = false;/* safest place to do it */
|
||||
|
||||
/* ----------------
|
||||
* done with commit processing, set current transaction
|
||||
* state back to default
|
||||
* ----------------
|
||||
/*
|
||||
* done with commit processing, set current transaction state back to
|
||||
* default
|
||||
*/
|
||||
s->state = TRANS_DEFAULT;
|
||||
|
||||
@@ -1157,9 +1135,8 @@ AbortTransaction(void)
|
||||
*/
|
||||
LockWaitCancel();
|
||||
|
||||
/* ----------------
|
||||
* check the current transaction state
|
||||
* ----------------
|
||||
/*
|
||||
* check the current transaction state
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
{
|
||||
@@ -1170,10 +1147,9 @@ AbortTransaction(void)
|
||||
if (s->state != TRANS_INPROGRESS)
|
||||
elog(NOTICE, "AbortTransaction and not in in-progress state");
|
||||
|
||||
/* ----------------
|
||||
* set the current transaction state information
|
||||
* appropriately during the abort processing
|
||||
* ----------------
|
||||
/*
|
||||
* set the current transaction state information appropriately during
|
||||
* the abort processing
|
||||
*/
|
||||
s->state = TRANS_ABORT;
|
||||
|
||||
@@ -1182,9 +1158,8 @@ AbortTransaction(void)
|
||||
*/
|
||||
SetUserId(GetSessionUserId());
|
||||
|
||||
/* ----------------
|
||||
* do abort processing
|
||||
* ----------------
|
||||
/*
|
||||
* do abort processing
|
||||
*/
|
||||
DeferredTriggerAbortXact();
|
||||
lo_commit(false); /* 'false' means it's abort */
|
||||
@@ -1207,9 +1182,8 @@ AbortTransaction(void)
|
||||
|
||||
SharedBufferChanged = false;/* safest place to do it */
|
||||
|
||||
/* ----------------
|
||||
* State remains TRANS_ABORT until CleanupTransaction().
|
||||
* ----------------
|
||||
/*
|
||||
* State remains TRANS_ABORT until CleanupTransaction().
|
||||
*/
|
||||
RESUME_INTERRUPTS();
|
||||
}
|
||||
@@ -1227,23 +1201,20 @@ CleanupTransaction(void)
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return;
|
||||
|
||||
/* ----------------
|
||||
* State should still be TRANS_ABORT from AbortTransaction().
|
||||
* ----------------
|
||||
/*
|
||||
* State should still be TRANS_ABORT from AbortTransaction().
|
||||
*/
|
||||
if (s->state != TRANS_ABORT)
|
||||
elog(FATAL, "CleanupTransaction and not in abort state");
|
||||
|
||||
/* ----------------
|
||||
* do abort cleanup processing
|
||||
* ----------------
|
||||
/*
|
||||
* do abort cleanup processing
|
||||
*/
|
||||
AtCleanup_Memory();
|
||||
|
||||
/* ----------------
|
||||
* done with abort processing, set current transaction
|
||||
* state back to default
|
||||
* ----------------
|
||||
/*
|
||||
* done with abort processing, set current transaction state back to
|
||||
* default
|
||||
*/
|
||||
s->state = TRANS_DEFAULT;
|
||||
}
|
||||
@@ -1259,44 +1230,41 @@ StartTransactionCommand(void)
|
||||
|
||||
switch (s->blockState)
|
||||
{
|
||||
/* ----------------
|
||||
* if we aren't in a transaction block, we
|
||||
* just do our usual start transaction.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* if we aren't in a transaction block, we just do our usual
|
||||
* start transaction.
|
||||
*/
|
||||
case TBLOCK_DEFAULT:
|
||||
StartTransaction();
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* We should never experience this -- if we do it
|
||||
* means the BEGIN state was not changed in the previous
|
||||
* CommitTransactionCommand(). If we get it, we print
|
||||
* a warning and change to the in-progress state.
|
||||
* ----------------
|
||||
/*
|
||||
* We should never experience this -- if we do it means the
|
||||
* BEGIN state was not changed in the previous
|
||||
* CommitTransactionCommand(). If we get it, we print a
|
||||
* warning and change to the in-progress state.
|
||||
*/
|
||||
case TBLOCK_BEGIN:
|
||||
elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_BEGIN");
|
||||
s->blockState = TBLOCK_INPROGRESS;
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* This is the case when are somewhere in a transaction
|
||||
* block and about to start a new command. For now we
|
||||
* do nothing but someday we may do command-local resource
|
||||
* initialization.
|
||||
* ----------------
|
||||
/*
|
||||
* This is the case when are somewhere in a transaction block
|
||||
* and about to start a new command. For now we do nothing
|
||||
* but someday we may do command-local resource
|
||||
* initialization.
|
||||
*/
|
||||
case TBLOCK_INPROGRESS:
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* As with BEGIN, we should never experience this
|
||||
* if we do it means the END state was not changed in the
|
||||
* previous CommitTransactionCommand(). If we get it, we
|
||||
* print a warning, commit the transaction, start a new
|
||||
* transaction and change to the default state.
|
||||
* ----------------
|
||||
/*
|
||||
* As with BEGIN, we should never experience this if we do it
|
||||
* means the END state was not changed in the previous
|
||||
* CommitTransactionCommand(). If we get it, we print a
|
||||
* warning, commit the transaction, start a new transaction
|
||||
* and change to the default state.
|
||||
*/
|
||||
case TBLOCK_END:
|
||||
elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_END");
|
||||
@@ -1305,23 +1273,21 @@ StartTransactionCommand(void)
|
||||
StartTransaction();
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* Here we are in the middle of a transaction block but
|
||||
* one of the commands caused an abort so we do nothing
|
||||
* but remain in the abort state. Eventually we will get
|
||||
* to the "END TRANSACTION" which will set things straight.
|
||||
* ----------------
|
||||
/*
|
||||
* Here we are in the middle of a transaction block but one of
|
||||
* the commands caused an abort so we do nothing but remain in
|
||||
* the abort state. Eventually we will get to the "END
|
||||
* TRANSACTION" which will set things straight.
|
||||
*/
|
||||
case TBLOCK_ABORT:
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* This means we somehow aborted and the last call to
|
||||
* CommitTransactionCommand() didn't clear the state so
|
||||
* we remain in the ENDABORT state and maybe next time
|
||||
* we get to CommitTransactionCommand() the state will
|
||||
* get reset to default.
|
||||
* ----------------
|
||||
/*
|
||||
* This means we somehow aborted and the last call to
|
||||
* CommitTransactionCommand() didn't clear the state so we
|
||||
* remain in the ENDABORT state and maybe next time we get to
|
||||
* CommitTransactionCommand() the state will get reset to
|
||||
* default.
|
||||
*/
|
||||
case TBLOCK_ENDABORT:
|
||||
elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_ENDABORT");
|
||||
@@ -1347,68 +1313,62 @@ CommitTransactionCommand(void)
|
||||
|
||||
switch (s->blockState)
|
||||
{
|
||||
/* ----------------
|
||||
* if we aren't in a transaction block, we
|
||||
* just do our usual transaction commit
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* if we aren't in a transaction block, we just do our usual
|
||||
* transaction commit
|
||||
*/
|
||||
case TBLOCK_DEFAULT:
|
||||
CommitTransaction();
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* This is the case right after we get a "BEGIN TRANSACTION"
|
||||
* command, but the user hasn't done anything else yet, so
|
||||
* we change to the "transaction block in progress" state
|
||||
* and return.
|
||||
* ----------------
|
||||
/*
|
||||
* This is the case right after we get a "BEGIN TRANSACTION"
|
||||
* command, but the user hasn't done anything else yet, so we
|
||||
* change to the "transaction block in progress" state and
|
||||
* return.
|
||||
*/
|
||||
case TBLOCK_BEGIN:
|
||||
s->blockState = TBLOCK_INPROGRESS;
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* This is the case when we have finished executing a command
|
||||
* someplace within a transaction block. We increment the
|
||||
* command counter and return. Someday we may free resources
|
||||
* local to the command.
|
||||
/*
|
||||
* This is the case when we have finished executing a command
|
||||
* someplace within a transaction block. We increment the
|
||||
* command counter and return. Someday we may free resources
|
||||
* local to the command.
|
||||
*
|
||||
* That someday is today, at least for memory allocated in
|
||||
* TransactionCommandContext.
|
||||
* - vadim 03/25/97
|
||||
* ----------------
|
||||
* That someday is today, at least for memory allocated in
|
||||
* TransactionCommandContext. - vadim 03/25/97
|
||||
*/
|
||||
case TBLOCK_INPROGRESS:
|
||||
CommandCounterIncrement();
|
||||
MemoryContextResetAndDeleteChildren(TransactionCommandContext);
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* This is the case when we just got the "END TRANSACTION"
|
||||
* statement, so we commit the transaction and go back to
|
||||
* the default state.
|
||||
* ----------------
|
||||
/*
|
||||
* This is the case when we just got the "END TRANSACTION"
|
||||
* statement, so we commit the transaction and go back to the
|
||||
* default state.
|
||||
*/
|
||||
case TBLOCK_END:
|
||||
CommitTransaction();
|
||||
s->blockState = TBLOCK_DEFAULT;
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* Here we are in the middle of a transaction block but
|
||||
* one of the commands caused an abort so we do nothing
|
||||
* but remain in the abort state. Eventually we will get
|
||||
* to the "END TRANSACTION" which will set things straight.
|
||||
* ----------------
|
||||
/*
|
||||
* Here we are in the middle of a transaction block but one of
|
||||
* the commands caused an abort so we do nothing but remain in
|
||||
* the abort state. Eventually we will get to the "END
|
||||
* TRANSACTION" which will set things straight.
|
||||
*/
|
||||
case TBLOCK_ABORT:
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* Here we were in an aborted transaction block which
|
||||
* just processed the "END TRANSACTION" command from the
|
||||
* user, so clean up and return to the default state.
|
||||
* ----------------
|
||||
/*
|
||||
* Here we were in an aborted transaction block which just
|
||||
* processed the "END TRANSACTION" command from the user, so
|
||||
* clean up and return to the default state.
|
||||
*/
|
||||
case TBLOCK_ENDABORT:
|
||||
CleanupTransaction();
|
||||
@@ -1428,22 +1388,21 @@ AbortCurrentTransaction(void)
|
||||
|
||||
switch (s->blockState)
|
||||
{
|
||||
/* ----------------
|
||||
* if we aren't in a transaction block, we
|
||||
* just do the basic abort & cleanup transaction.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* if we aren't in a transaction block, we just do the basic
|
||||
* abort & cleanup transaction.
|
||||
*/
|
||||
case TBLOCK_DEFAULT:
|
||||
AbortTransaction();
|
||||
CleanupTransaction();
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* If we are in the TBLOCK_BEGIN it means something
|
||||
* screwed up right after reading "BEGIN TRANSACTION"
|
||||
* so we enter the abort state. Eventually an "END
|
||||
* TRANSACTION" will fix things.
|
||||
* ----------------
|
||||
/*
|
||||
* If we are in the TBLOCK_BEGIN it means something screwed up
|
||||
* right after reading "BEGIN TRANSACTION" so we enter the
|
||||
* abort state. Eventually an "END TRANSACTION" will fix
|
||||
* things.
|
||||
*/
|
||||
case TBLOCK_BEGIN:
|
||||
s->blockState = TBLOCK_ABORT;
|
||||
@@ -1451,12 +1410,11 @@ AbortCurrentTransaction(void)
|
||||
/* CleanupTransaction happens when we exit TBLOCK_ABORT */
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* This is the case when are somewhere in a transaction
|
||||
* block which aborted so we abort the transaction and
|
||||
* set the ABORT state. Eventually an "END TRANSACTION"
|
||||
* will fix things and restore us to a normal state.
|
||||
* ----------------
|
||||
/*
|
||||
* This is the case when are somewhere in a transaction block
|
||||
* which aborted so we abort the transaction and set the ABORT
|
||||
* state. Eventually an "END TRANSACTION" will fix things and
|
||||
* restore us to a normal state.
|
||||
*/
|
||||
case TBLOCK_INPROGRESS:
|
||||
s->blockState = TBLOCK_ABORT;
|
||||
@@ -1464,12 +1422,10 @@ AbortCurrentTransaction(void)
|
||||
/* CleanupTransaction happens when we exit TBLOCK_ABORT */
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* Here, the system was fouled up just after the
|
||||
* user wanted to end the transaction block so we
|
||||
* abort the transaction and put us back into the
|
||||
* default state.
|
||||
* ----------------
|
||||
/*
|
||||
* Here, the system was fouled up just after the user wanted
|
||||
* to end the transaction block so we abort the transaction
|
||||
* and put us back into the default state.
|
||||
*/
|
||||
case TBLOCK_END:
|
||||
s->blockState = TBLOCK_DEFAULT;
|
||||
@@ -1477,22 +1433,20 @@ AbortCurrentTransaction(void)
|
||||
CleanupTransaction();
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* Here, we are already in an aborted transaction
|
||||
* state and are waiting for an "END TRANSACTION" to
|
||||
* come along and lo and behold, we abort again!
|
||||
* So we just remain in the abort state.
|
||||
* ----------------
|
||||
/*
|
||||
* Here, we are already in an aborted transaction state and
|
||||
* are waiting for an "END TRANSACTION" to come along and lo
|
||||
* and behold, we abort again! So we just remain in the abort
|
||||
* state.
|
||||
*/
|
||||
case TBLOCK_ABORT:
|
||||
break;
|
||||
|
||||
/* ----------------
|
||||
* Here we were in an aborted transaction block which
|
||||
* just processed the "END TRANSACTION" command but somehow
|
||||
* aborted again.. since we must have done the abort
|
||||
* processing, we clean up and return to the default state.
|
||||
* ----------------
|
||||
/*
|
||||
* Here we were in an aborted transaction block which just
|
||||
* processed the "END TRANSACTION" command but somehow aborted
|
||||
* again.. since we must have done the abort processing, we
|
||||
* clean up and return to the default state.
|
||||
*/
|
||||
case TBLOCK_ENDABORT:
|
||||
CleanupTransaction();
|
||||
@@ -1514,9 +1468,8 @@ BeginTransactionBlock(void)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* check the current transaction state
|
||||
* ----------------
|
||||
/*
|
||||
* check the current transaction state
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return;
|
||||
@@ -1524,21 +1477,18 @@ BeginTransactionBlock(void)
|
||||
if (s->blockState != TBLOCK_DEFAULT)
|
||||
elog(NOTICE, "BEGIN: already a transaction in progress");
|
||||
|
||||
/* ----------------
|
||||
* set the current transaction block state information
|
||||
* appropriately during begin processing
|
||||
* ----------------
|
||||
/*
|
||||
* set the current transaction block state information appropriately
|
||||
* during begin processing
|
||||
*/
|
||||
s->blockState = TBLOCK_BEGIN;
|
||||
|
||||
/* ----------------
|
||||
* do begin processing
|
||||
* ----------------
|
||||
/*
|
||||
* do begin processing
|
||||
*/
|
||||
|
||||
/* ----------------
|
||||
* done with begin processing, set block state to inprogress
|
||||
* ----------------
|
||||
/*
|
||||
* done with begin processing, set block state to inprogress
|
||||
*/
|
||||
s->blockState = TBLOCK_INPROGRESS;
|
||||
}
|
||||
@@ -1552,22 +1502,20 @@ EndTransactionBlock(void)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* check the current transaction state
|
||||
* ----------------
|
||||
/*
|
||||
* check the current transaction state
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return;
|
||||
|
||||
if (s->blockState == TBLOCK_INPROGRESS)
|
||||
{
|
||||
/* ----------------
|
||||
* here we are in a transaction block which should commit
|
||||
* when we get to the upcoming CommitTransactionCommand()
|
||||
* so we set the state to "END". CommitTransactionCommand()
|
||||
* will recognize this and commit the transaction and return
|
||||
* us to the default state
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* here we are in a transaction block which should commit when we
|
||||
* get to the upcoming CommitTransactionCommand() so we set the
|
||||
* state to "END". CommitTransactionCommand() will recognize this
|
||||
* and commit the transaction and return us to the default state
|
||||
*/
|
||||
s->blockState = TBLOCK_END;
|
||||
return;
|
||||
@@ -1575,25 +1523,23 @@ EndTransactionBlock(void)
|
||||
|
||||
if (s->blockState == TBLOCK_ABORT)
|
||||
{
|
||||
/* ----------------
|
||||
* here, we are in a transaction block which aborted
|
||||
* and since the AbortTransaction() was already done,
|
||||
* we do whatever is needed and change to the special
|
||||
* "END ABORT" state. The upcoming CommitTransactionCommand()
|
||||
* will recognise this and then put us back in the default
|
||||
* state.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* here, we are in a transaction block which aborted and since the
|
||||
* AbortTransaction() was already done, we do whatever is needed
|
||||
* and change to the special "END ABORT" state. The upcoming
|
||||
* CommitTransactionCommand() will recognise this and then put us
|
||||
* back in the default state.
|
||||
*/
|
||||
s->blockState = TBLOCK_ENDABORT;
|
||||
return;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* here, the user issued COMMIT when not inside a transaction.
|
||||
* Issue a notice and go to abort state. The upcoming call to
|
||||
* CommitTransactionCommand() will then put us back into the
|
||||
* default state.
|
||||
* ----------------
|
||||
/*
|
||||
* here, the user issued COMMIT when not inside a transaction. Issue a
|
||||
* notice and go to abort state. The upcoming call to
|
||||
* CommitTransactionCommand() will then put us back into the default
|
||||
* state.
|
||||
*/
|
||||
elog(NOTICE, "COMMIT: no transaction in progress");
|
||||
AbortTransaction();
|
||||
@@ -1610,34 +1556,31 @@ AbortTransactionBlock(void)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* check the current transaction state
|
||||
* ----------------
|
||||
/*
|
||||
* check the current transaction state
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return;
|
||||
|
||||
if (s->blockState == TBLOCK_INPROGRESS)
|
||||
{
|
||||
/* ----------------
|
||||
* here we were inside a transaction block something
|
||||
* screwed up inside the system so we enter the abort state,
|
||||
* do the abort processing and then return.
|
||||
* We remain in the abort state until we see an
|
||||
* END TRANSACTION command.
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* here we were inside a transaction block something screwed up
|
||||
* inside the system so we enter the abort state, do the abort
|
||||
* processing and then return. We remain in the abort state until
|
||||
* we see an END TRANSACTION command.
|
||||
*/
|
||||
s->blockState = TBLOCK_ABORT;
|
||||
AbortTransaction();
|
||||
return;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* here, the user issued ABORT when not inside a transaction.
|
||||
* Issue a notice and go to abort state. The upcoming call to
|
||||
* CommitTransactionCommand() will then put us back into the
|
||||
* default state.
|
||||
* ----------------
|
||||
/*
|
||||
* here, the user issued ABORT when not inside a transaction. Issue a
|
||||
* notice and go to abort state. The upcoming call to
|
||||
* CommitTransactionCommand() will then put us back into the default
|
||||
* state.
|
||||
*/
|
||||
elog(NOTICE, "ROLLBACK: no transaction in progress");
|
||||
AbortTransaction();
|
||||
@@ -1655,9 +1598,8 @@ UserAbortTransactionBlock(void)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* check the current transaction state
|
||||
* ----------------
|
||||
/*
|
||||
* check the current transaction state
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return;
|
||||
@@ -1675,14 +1617,13 @@ UserAbortTransactionBlock(void)
|
||||
|
||||
if (s->blockState == TBLOCK_INPROGRESS)
|
||||
{
|
||||
/* ----------------
|
||||
* here we were inside a transaction block and we
|
||||
* got an abort command from the user, so we move to
|
||||
* the abort state, do the abort processing and
|
||||
* then change to the ENDABORT state so we will end up
|
||||
* in the default state after the upcoming
|
||||
* CommitTransactionCommand().
|
||||
* ----------------
|
||||
|
||||
/*
|
||||
* here we were inside a transaction block and we got an abort
|
||||
* command from the user, so we move to the abort state, do the
|
||||
* abort processing and then change to the ENDABORT state so we
|
||||
* will end up in the default state after the upcoming
|
||||
* CommitTransactionCommand().
|
||||
*/
|
||||
s->blockState = TBLOCK_ABORT;
|
||||
AbortTransaction();
|
||||
@@ -1690,12 +1631,11 @@ UserAbortTransactionBlock(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* here, the user issued ABORT when not inside a transaction.
|
||||
* Issue a notice and go to abort state. The upcoming call to
|
||||
* CommitTransactionCommand() will then put us back into the
|
||||
* default state.
|
||||
* ----------------
|
||||
/*
|
||||
* here, the user issued ABORT when not inside a transaction. Issue a
|
||||
* notice and go to abort state. The upcoming call to
|
||||
* CommitTransactionCommand() will then put us back into the default
|
||||
* state.
|
||||
*/
|
||||
elog(NOTICE, "ROLLBACK: no transaction in progress");
|
||||
AbortTransaction();
|
||||
|
||||
Reference in New Issue
Block a user