8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.6 1997/08/12 22:52:35 momjian Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.7 1997/08/29 09:02:50 vadim Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -365,9 +365,19 @@ postquel_execute(execution_state *es,
365
365
Datum
366
366
postquel_function (Func * funcNode , char * * args , bool * isNull , bool * isDone )
367
367
{
368
- execution_state * es ;
369
- Datum result = 0 ;
370
- FunctionCachePtr fcache = funcNode -> func_fcache ;
368
+ execution_state * es ;
369
+ Datum result = 0 ;
370
+ FunctionCachePtr fcache = funcNode -> func_fcache ;
371
+ CommandId savedId ;
372
+
373
+ /*
374
+ * Before we start do anything we must save CurrentScanCommandId
375
+ * to restore it before return to upper Executor. Also, we have to
376
+ * set CurrentScanCommandId equal to CurrentCommandId.
377
+ * - vadim 08/29/97
378
+ */
379
+ savedId = GetScanCommandId ();
380
+ SetScanCommandId (GetCurrentCommandId ());
371
381
372
382
es = (execution_state * ) fcache -> func_state ;
373
383
if (es == NULL )
@@ -401,22 +411,23 @@ postquel_function(Func *funcNode, char **args, bool *isNull, bool *isDone)
401
411
* If we've gone through every command in this function, we are done.
402
412
*/
403
413
if (es == (execution_state * )NULL )
414
+ {
415
+ /*
416
+ * Reset the execution states to start over again
417
+ */
418
+ es = (execution_state * )fcache -> func_state ;
419
+ while (es )
404
420
{
405
- /*
406
- * Reset the execution states to start over again
407
- */
408
- es = (execution_state * )fcache -> func_state ;
409
- while (es )
410
- {
411
- es -> status = F_EXEC_START ;
412
- es = es -> next ;
413
- }
414
- /*
415
- * Let caller know we're finished.
416
- */
417
- * isDone = true;
418
- return (fcache -> oneResult ) ? result : (Datum )NULL ;
421
+ es -> status = F_EXEC_START ;
422
+ es = es -> next ;
419
423
}
424
+ /*
425
+ * Let caller know we're finished.
426
+ */
427
+ * isDone = true;
428
+ SetScanCommandId (savedId );
429
+ return (fcache -> oneResult ) ? result : (Datum )NULL ;
430
+ }
420
431
/*
421
432
* If we got a result from a command within the function it has
422
433
* to be the final command. All others shouldn't be returing
@@ -425,5 +436,6 @@ postquel_function(Func *funcNode, char **args, bool *isNull, bool *isDone)
425
436
Assert ( LAST_POSTQUEL_COMMAND (es ) );
426
437
* isDone = false;
427
438
439
+ SetScanCommandId (savedId );
428
440
return result ;
429
441
}
0 commit comments