|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.121 2005/04/14 20:03:24 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.122 2005/04/23 21:32:34 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -620,27 +620,26 @@ ExecAssignProjectionInfo(PlanState *planstate)
|
620 | 620 | /* ----------------
|
621 | 621 | * ExecFreeExprContext
|
622 | 622 | *
|
623 |
| - * A plan node's ExprContext should be freed explicitly during ExecEndNode |
624 |
| - * because there may be shutdown callbacks to call. (Other resources made |
625 |
| - * by the above routines, such as projection info, don't need to be freed |
| 623 | + * A plan node's ExprContext should be freed explicitly during executor |
| 624 | + * shutdown because there may be shutdown callbacks to call. (Other resources |
| 625 | + * made by the above routines, such as projection info, don't need to be freed |
626 | 626 | * explicitly because they're just memory in the per-query memory context.)
|
| 627 | + * |
| 628 | + * However ... there is no particular need to do it during ExecEndNode, |
| 629 | + * because FreeExecutorState will free any remaining ExprContexts within |
| 630 | + * the EState. Letting FreeExecutorState do it allows the ExprContexts to |
| 631 | + * be freed in reverse order of creation, rather than order of creation as |
| 632 | + * will happen if we delete them here, which saves O(N^2) work in the list |
| 633 | + * cleanup inside FreeExprContext. |
627 | 634 | * ----------------
|
628 | 635 | */
|
629 | 636 | void
|
630 | 637 | ExecFreeExprContext(PlanState *planstate)
|
631 | 638 | {
|
632 |
| - ExprContext *econtext; |
633 |
| - |
634 | 639 | /*
|
635 |
| - * get expression context. if NULL then this node has none so we just |
636 |
| - * return. |
| 640 | + * Per above discussion, don't actually delete the ExprContext. |
| 641 | + * We do unlink it from the plan node, though. |
637 | 642 | */
|
638 |
| - econtext = planstate->ps_ExprContext; |
639 |
| - if (econtext == NULL) |
640 |
| - return; |
641 |
| - |
642 |
| - FreeExprContext(econtext); |
643 |
| - |
644 | 643 | planstate->ps_ExprContext = NULL;
|
645 | 644 | }
|
646 | 645 |
|
|
0 commit comments