1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

Ensure that a cursor is scanned under the same scanCommandId it was

originally created with, so that the set of visible tuples does not
change as a result of other activity.  This essentially makes PG cursors
INSENSITIVE per the SQL92 definition.  See bug report of 13-Feb-02.
This commit is contained in:
Tom Lane
2002-02-14 15:24:10 +00:00
parent 1392042346
commit 3576820e78
4 changed files with 48 additions and 13 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.152 2002/01/03 23:19:30 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.153 2002/02/14 15:24:06 tgl Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
@@ -103,6 +103,7 @@ PerformPortalFetch(char *name,
QueryDesc *queryDesc;
EState *estate;
MemoryContext oldcontext;
CommandId savedId;
bool temp_desc = false;
/*
@@ -156,7 +157,7 @@ PerformPortalFetch(char *name,
}
/*
* tell the destination to prepare to receive some tuples.
* Tell the destination to prepare to receive some tuples.
*/
BeginCommand(name,
queryDesc->operation,
@@ -168,6 +169,14 @@ PerformPortalFetch(char *name,
tag,
queryDesc->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));
/*
* Determine which direction to go in, and check to see if we're
* already at the end of the available tuples in that direction. If
@@ -214,6 +223,11 @@ PerformPortalFetch(char *name,
}
}
/*
* Restore outer command ID.
*/
SetScanCommandId(savedId);
/*
* Clean up and switch back to old context.
*/