diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-02-14 15:24:10 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-02-14 15:24:10 +0000 |
commit | 3576820e7852ab20d552fe5aa7abb2847db62f6f (patch) | |
tree | 207f056de4c5e95b5000b119c4d6e0d8b0380ffa /src/backend/commands/command.c | |
parent | 13920423466a345e832ed844e9513ad2eed43731 (diff) | |
download | postgresql-3576820e7852ab20d552fe5aa7abb2847db62f6f.tar.gz postgresql-3576820e7852ab20d552fe5aa7abb2847db62f6f.zip |
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.
Diffstat (limited to 'src/backend/commands/command.c')
-rw-r--r-- | src/backend/commands/command.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 646511eb18d..9b1a33673c7 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -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, @@ -169,6 +170,14 @@ PerformPortalFetch(char *name, 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 * so, do nothing. (This check exists because not all plan node types @@ -215,6 +224,11 @@ PerformPortalFetch(char *name, } /* + * Restore outer command ID. + */ + SetScanCommandId(savedId); + + /* * Clean up and switch back to old context. */ if (temp_desc) |