1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Remove global variable scanCommandId in favor of storing a command ID

in snapshots, per my proposal of a few days ago.  Also, tweak heapam.c
routines (heap_insert, heap_update, heap_delete, heap_mark4update) to
be passed the command ID to use, instead of doing GetCurrentCommandID.
For catalog updates they'll still get passed current command ID, but
for updates generated from the main executor they'll get passed the
command ID saved in the snapshot the query is using.  This should fix
some corner cases associated with functions and triggers that advance
current command ID while an outer query is still in progress.
This commit is contained in:
Tom Lane
2002-05-21 22:05:55 +00:00
parent 0a2682445e
commit 959e61e917
37 changed files with 191 additions and 235 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.122 2002/05/17 20:53:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.123 2002/05/21 22:05:53 tgl Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@ -350,14 +350,6 @@ GetCurrentCommandId(void)
return s->commandId;
}
CommandId
GetScanCommandId(void)
{
TransactionState s = CurrentTransactionState;
return s->scanCommandId;
}
/* --------------------------------
* GetCurrentTransactionStartTime
@ -418,17 +410,6 @@ CommandIdIsCurrentCommandId(CommandId cid)
return (cid == s->commandId) ? true : false;
}
bool
CommandIdGEScanCommandId(CommandId cid)
{
TransactionState s = CurrentTransactionState;
if (AMI_OVERRIDE)
return false;
return (cid >= s->scanCommandId) ? true : false;
}
/* --------------------------------
* CommandCounterIncrement
@ -437,11 +418,17 @@ CommandIdGEScanCommandId(CommandId cid)
void
CommandCounterIncrement(void)
{
CurrentTransactionStateData.commandId += 1;
if (CurrentTransactionStateData.commandId == FirstCommandId)
TransactionState s = CurrentTransactionState;
s->commandId += 1;
if (s->commandId == FirstCommandId) /* check for overflow */
elog(ERROR, "You may only have 2^32-1 commands per transaction");
CurrentTransactionStateData.scanCommandId = CurrentTransactionStateData.commandId;
/* Propagate new command ID into query snapshots, if set */
if (QuerySnapshot)
QuerySnapshot->curcid = s->commandId;
if (SerializableSnapshot)
SerializableSnapshot->curcid = s->commandId;
/*
* make cache changes visible to me. AtCommit_LocalCache() instead of
@ -451,11 +438,6 @@ CommandCounterIncrement(void)
AtStart_Cache();
}
void
SetScanCommandId(CommandId savedId)
{
CurrentTransactionStateData.scanCommandId = savedId;
}
/* ----------------------------------------------------------------
* StartTransaction stuff
@ -889,10 +871,6 @@ StartTransaction(void)
* initialize current transaction state fields
*/
s->commandId = FirstCommandId;
s->scanCommandId = FirstCommandId;
#if NOT_USED
s->startTime = GetCurrentAbsoluteTime();
#endif
s->startTime = GetCurrentAbsoluteTimeUsec(&(s->startTimeUsec));
/*