*** ./src/backend/executor/spi.c.orig	2008-06-01 17:26:19.000000000 +0200
--- ./src/backend/executor/spi.c	2008-06-01 17:35:01.000000000 +0200
***************
*** 63,68 ****
--- 63,71 ----
  static MemoryContext _SPI_execmem(void);
  static MemoryContext _SPI_procmem(void);
  static bool _SPI_checktuples(void);
+ static Portal _SPI_cursor_open(const char *name, SPIPlanPtr plan,
+ 				Datum *Values, const char *Nulls,
+ 				bool read_only, int pflags);
  
  
  /* =================== interface functions =================== */
***************
*** 908,921 ****
  
  
  /*
!  * SPI_cursor_open()
!  *
!  *	Open a prepared SPI plan as a portal
   */
! Portal
! SPI_cursor_open(const char *name, SPIPlanPtr plan,
  				Datum *Values, const char *Nulls,
! 				bool read_only)
  {
  	CachedPlanSource *plansource;
  	CachedPlan *cplan;
--- 911,923 ----
  
  
  /*
!  * _SPI_cursor_open()
!  *	Open a prepared SPI plan as portal, allows set parameter's pflags
   */
! static Portal
! _SPI_cursor_open(const char *name, SPIPlanPtr plan,
  				Datum *Values, const char *Nulls,
! 				bool read_only, int pflags)
  {
  	CachedPlanSource *plansource;
  	CachedPlan *cplan;
***************
*** 997,1003 ****
  			ParamExternData *prm = &paramLI->params[k];
  
  			prm->ptype = plan->argtypes[k];
! 			prm->pflags = 0;
  			prm->isnull = (Nulls && Nulls[k] == 'n');
  			if (prm->isnull)
  			{
--- 999,1005 ----
  			ParamExternData *prm = &paramLI->params[k];
  
  			prm->ptype = plan->argtypes[k];
! 			prm->pflags = pflags;
  			prm->isnull = (Nulls && Nulls[k] == 'n');
  			if (prm->isnull)
  			{
***************
*** 1130,1135 ****
--- 1132,1154 ----
  
  
  /*
+  * SPI_cursor_open()
+  *
+  *	Open a prepared SPI plan as a portal
+  */
+ Portal
+ SPI_cursor_open(const char *name, SPIPlanPtr plan,
+ 				Datum *Values, const char *Nulls,
+ 				bool read_only)
+ {
+ 	return _SPI_cursor_open(name, plan,
+ 				Values, Nulls,
+ 				read_only, 0);
+ 
+ }
+ 
+ 
+ /*
   * SPI_cursor_open_with_args()
   *
   * Parse and plan a query and open it as a portal.  Like SPI_execute_with_args,
***************
*** 1177,1183 ****
  	/* SPI_cursor_open expects to be called in procedure memory context */
  	_SPI_procmem();
  
! 	result = SPI_cursor_open(name, &plan, Values, Nulls, read_only);
  
  	/* And clean up */
  	_SPI_curid++;
--- 1196,1203 ----
  	/* SPI_cursor_open expects to be called in procedure memory context */
  	_SPI_procmem();
  
! 	/* all params has PARAM_FLAG_CONST flag */
! 	result = _SPI_cursor_open(name, &plan, Values, Nulls, read_only, PARAM_FLAG_CONST);
  
  	/* And clean up */
  	_SPI_curid++;
