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