mirror of
https://github.com/postgres/postgres.git
synced 2025-07-17 06:41:09 +03:00
Fix very old bug which made tuples changed/inserted by a commnd
visible to command itself (so we had multiple update of updated tuples, etc).
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.12 1997/08/19 21:30:19 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.13 1997/08/29 09:02:11 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Transaction aborts can now occur two ways:
|
||||
@ -377,6 +377,22 @@ GetCurrentCommandId()
|
||||
return s->commandId;
|
||||
}
|
||||
|
||||
CommandId
|
||||
GetScanCommandId()
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/* ----------------
|
||||
* if the transaction system is disabled, we return
|
||||
* the special "disabled" command id.
|
||||
* ----------------
|
||||
*/
|
||||
if (s->state == TRANS_DISABLED)
|
||||
return (CommandId) DisabledCommandId;
|
||||
|
||||
return s->scanCommandId;
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------
|
||||
* GetCurrentTransactionStartTime
|
||||
@ -432,6 +448,18 @@ CommandIdIsCurrentCommandId(CommandId cid)
|
||||
(cid == s->commandId) ? true : false;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandIdGEScanCommandId(CommandId cid)
|
||||
{
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
if (AMI_OVERRIDE)
|
||||
return false;
|
||||
|
||||
return
|
||||
(cid >= s->scanCommandId) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------
|
||||
* ClearCommandIdCounterOverflowFlag
|
||||
@ -458,11 +486,22 @@ CommandCounterIncrement()
|
||||
elog(WARN, "You may only have 65535 commands per transaction");
|
||||
}
|
||||
|
||||
CurrentTransactionStateData.scanCommandId =
|
||||
CurrentTransactionStateData.commandId;
|
||||
|
||||
/* make cache changes visible to me */
|
||||
AtCommit_Cache();
|
||||
AtStart_Cache();
|
||||
}
|
||||
|
||||
void
|
||||
SetScanCommandId (CommandId savedId)
|
||||
{
|
||||
|
||||
CurrentTransactionStateData.scanCommandId = savedId;
|
||||
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* initialization stuff
|
||||
* ----------------------------------------------------------------
|
||||
@ -757,6 +796,7 @@ StartTransaction()
|
||||
* ----------------
|
||||
*/
|
||||
s->commandId = FirstCommandId;
|
||||
s->scanCommandId = FirstCommandId;
|
||||
s->startTime = GetCurrentAbsoluteTime();
|
||||
|
||||
/* ----------------
|
||||
|
Reference in New Issue
Block a user