|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.151 2003/11/29 19:51:48 pgsql Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.152 2003/12/18 22:23:42 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -636,9 +636,26 @@ init_fcache(Oid foid, FuncExprState *fcache, MemoryContext fcacheCxt)
|
636 | 636 |
|
637 | 637 | /* Initialize additional info */
|
638 | 638 | fcache->setArgsValid = false;
|
| 639 | + fcache->shutdown_reg = false; |
639 | 640 | fcache->func.fn_expr = (Node *) fcache->xprstate.expr;
|
640 | 641 | }
|
641 | 642 |
|
| 643 | +/* |
| 644 | + * callback function in case a FuncExpr returning a set needs to be shut down |
| 645 | + * before it has been run to completion |
| 646 | + */ |
| 647 | +static void |
| 648 | +ShutdownFuncExpr(Datum arg) |
| 649 | +{ |
| 650 | + FuncExprState *fcache = (FuncExprState *) DatumGetPointer(arg); |
| 651 | + |
| 652 | + /* Clear any active set-argument state */ |
| 653 | + fcache->setArgsValid = false; |
| 654 | + |
| 655 | + /* execUtils will deregister the callback... */ |
| 656 | + fcache->shutdown_reg = false; |
| 657 | +} |
| 658 | + |
642 | 659 | /*
|
643 | 660 | * Evaluate arguments for a function.
|
644 | 661 | */
|
@@ -827,6 +844,14 @@ ExecMakeFunctionResult(FuncExprState *fcache,
|
827 | 844 | memcpy(&fcache->setArgs, &fcinfo, sizeof(fcinfo));
|
828 | 845 | fcache->setHasSetArg = hasSetArg;
|
829 | 846 | fcache->setArgsValid = true;
|
| 847 | + /* Register cleanup callback if we didn't already */ |
| 848 | + if (!fcache->shutdown_reg) |
| 849 | + { |
| 850 | + RegisterExprContextCallback(econtext, |
| 851 | + ShutdownFuncExpr, |
| 852 | + PointerGetDatum(fcache)); |
| 853 | + fcache->shutdown_reg = true; |
| 854 | + } |
830 | 855 | }
|
831 | 856 |
|
832 | 857 | /*
|
|
0 commit comments