|
14 | 14 | *
|
15 | 15 | *
|
16 | 16 | * IDENTIFICATION
|
17 |
| - * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.79 2009/06/11 14:48:56 momjian Exp $ |
| 17 | + * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.80 2009/10/02 17:57:29 alvherre Exp $ |
18 | 18 | *
|
19 | 19 | *-------------------------------------------------------------------------
|
20 | 20 | */
|
@@ -47,6 +47,7 @@ PerformCursorOpen(PlannedStmt *stmt, ParamListInfo params,
|
47 | 47 | DeclareCursorStmt *cstmt = (DeclareCursorStmt *) stmt->utilityStmt;
|
48 | 48 | Portal portal;
|
49 | 49 | MemoryContext oldContext;
|
| 50 | + Snapshot snapshot; |
50 | 51 |
|
51 | 52 | if (cstmt == NULL || !IsA(cstmt, DeclareCursorStmt))
|
52 | 53 | elog(ERROR, "PerformCursorOpen called for non-cursor query");
|
@@ -118,10 +119,18 @@ PerformCursorOpen(PlannedStmt *stmt, ParamListInfo params,
|
118 | 119 | portal->cursorOptions |= CURSOR_OPT_NO_SCROLL;
|
119 | 120 | }
|
120 | 121 |
|
| 122 | + /* |
| 123 | + * Set up snapshot for portal. Note that we need a fresh, independent copy |
| 124 | + * of the snapshot because we don't want it to be modified by future |
| 125 | + * CommandCounterIncrement calls. We do not register it, because |
| 126 | + * portalmem.c will take care of that internally. |
| 127 | + */ |
| 128 | + snapshot = CopySnapshot(GetActiveSnapshot()); |
| 129 | + |
121 | 130 | /*
|
122 | 131 | * Start execution, inserting parameters if any.
|
123 | 132 | */
|
124 |
| - PortalStart(portal, params, GetActiveSnapshot()); |
| 133 | + PortalStart(portal, params, snapshot); |
125 | 134 |
|
126 | 135 | Assert(portal->strategy == PORTAL_ONE_SELECT);
|
127 | 136 |
|
|
0 commit comments