mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +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:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.69 2002/04/15 05:22:04 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.70 2002/05/21 22:05:55 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -106,11 +106,7 @@ SPI_connect(void)
|
||||
/* ... and switch to procedure's context */
|
||||
_SPI_current->savedcxt = MemoryContextSwitchTo(_SPI_current->procCxt);
|
||||
|
||||
_SPI_current->savedId = GetScanCommandId();
|
||||
SetScanCommandId(GetCurrentCommandId());
|
||||
|
||||
return SPI_OK_CONNECT;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
@ -129,8 +125,6 @@ SPI_finish(void)
|
||||
MemoryContextDelete(_SPI_current->execCxt);
|
||||
MemoryContextDelete(_SPI_current->procCxt);
|
||||
|
||||
SetScanCommandId(_SPI_current->savedId);
|
||||
|
||||
/*
|
||||
* After _SPI_begin_call _SPI_connected == _SPI_curid. Now we are
|
||||
* closing connection to SPI and returning to upper Executor and so
|
||||
@ -1233,7 +1227,6 @@ _SPI_cursor_operation(Portal portal, bool forward, int count,
|
||||
EState *estate;
|
||||
MemoryContext oldcontext;
|
||||
ScanDirection direction;
|
||||
CommandId savedId;
|
||||
CommandDest olddest;
|
||||
|
||||
/* Check that the portal is valid */
|
||||
@ -1260,14 +1253,6 @@ _SPI_cursor_operation(Portal portal, bool forward, int count,
|
||||
olddest = querydesc->dest;
|
||||
querydesc->dest = dest;
|
||||
|
||||
/*
|
||||
* Restore the scanCommandId that was current when the cursor was
|
||||
* opened. This ensures that we see the same tuples throughout the
|
||||
* execution of the cursor.
|
||||
*/
|
||||
savedId = GetScanCommandId();
|
||||
SetScanCommandId(PortalGetCommandId(portal));
|
||||
|
||||
/* Run the executor like PerformPortalFetch and remember states */
|
||||
if (forward)
|
||||
{
|
||||
@ -1300,11 +1285,6 @@ _SPI_cursor_operation(Portal portal, bool forward, int count,
|
||||
|
||||
_SPI_current->processed = estate->es_processed;
|
||||
|
||||
/*
|
||||
* Restore outer command ID.
|
||||
*/
|
||||
SetScanCommandId(savedId);
|
||||
|
||||
/* Restore the old command destination and switch back to callers */
|
||||
/* memory context */
|
||||
querydesc->dest = olddest;
|
||||
|
Reference in New Issue
Block a user