This patch removes a useless pushing of an active snapshot on
PortalStart.  Instead of push/get/pop of the active snapshot, without
any intervening use of the active snapshot, we just pass a local
snapshot down to CreateQueryDesc.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
Index: src/backend/tcop/pquery.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/tcop/pquery.c,v
retrieving revision 1.131
diff -c -p -r1.131 pquery.c
*** src/backend/tcop/pquery.c	11 Jun 2009 14:49:02 -0000	1.131
--- src/backend/tcop/pquery.c	2 Oct 2009 18:11:32 -0000
*************** PortalStart(Portal portal, ParamListInfo
*** 466,471 ****
--- 466,472 ----
  	MemoryContext oldContext;
  	QueryDesc  *queryDesc;
  	int			eflags;
+ 	Snapshot	mysnap;
  
  	AssertArg(PortalIsValid(portal));
  	AssertState(portal->status == PORTAL_DEFINED);
*************** PortalStart(Portal portal, ParamListInfo
*** 499,509 ****
  		{
  			case PORTAL_ONE_SELECT:
  
! 				/* Must set snapshot before starting executor. */
! 				if (snapshot)
! 					PushActiveSnapshot(snapshot);
! 				else
! 					PushActiveSnapshot(GetTransactionSnapshot());
  
  				/*
  				 * Create QueryDesc in portal's context; for the moment, set
--- 500,506 ----
  		{
  			case PORTAL_ONE_SELECT:
  
! 				mysnap = snapshot ? snapshot : GetTransactionSnapshot();
  
  				/*
  				 * Create QueryDesc in portal's context; for the moment, set
*************** PortalStart(Portal portal, ParamListInfo
*** 511,517 ****
  				 */
  				queryDesc = CreateQueryDesc((PlannedStmt *) linitial(portal->stmts),
  											portal->sourceText,
! 											GetActiveSnapshot(),
  											InvalidSnapshot,
  											None_Receiver,
  											params,
--- 508,514 ----
  				 */
  				queryDesc = CreateQueryDesc((PlannedStmt *) linitial(portal->stmts),
  											portal->sourceText,
! 											mysnap,
  											InvalidSnapshot,
  											None_Receiver,
  											params,
*************** PortalStart(Portal portal, ParamListInfo
*** 556,562 ****
  				portal->portalPos = 0;
  				portal->posOverflow = false;
  
- 				PopActiveSnapshot();
  				break;
  
  			case PORTAL_ONE_RETURNING:
--- 553,558 ----
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to