|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.36 2000/10/05 19:11:26 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.37 2000/11/09 18:12:53 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -493,27 +493,32 @@ ExecEndAppend(Append *node)
|
493 | 493 |
|
494 | 494 | /* ----------------
|
495 | 495 | * close out the different result relations
|
| 496 | + * |
| 497 | + * NB: this must agree with what EndPlan() does to close a result rel |
496 | 498 | * ----------------
|
497 | 499 | */
|
498 | 500 | resultRelationInfoList = appendstate->as_result_relation_info_list;
|
499 | 501 | while (resultRelationInfoList != NIL)
|
500 | 502 | {
|
501 | 503 | RelationInfo *resultRelationInfo;
|
502 |
| - Relation resultRelationDesc; |
503 | 504 |
|
504 | 505 | resultRelationInfo = (RelationInfo *) lfirst(resultRelationInfoList);
|
505 |
| - resultRelationDesc = resultRelationInfo->ri_RelationDesc; |
506 |
| - heap_close(resultRelationDesc, NoLock); |
| 506 | + |
| 507 | + heap_close(resultRelationInfo->ri_RelationDesc, NoLock); |
| 508 | + /* close indices on the result relation, too */ |
| 509 | + ExecCloseIndices(resultRelationInfo); |
| 510 | + |
| 511 | + /* |
| 512 | + * estate may (or may not) be pointing at one of my result relations. |
| 513 | + * If so, make sure EndPlan() doesn't try to close it again! |
| 514 | + */ |
| 515 | + if (estate->es_result_relation_info == resultRelationInfo) |
| 516 | + estate->es_result_relation_info = NULL; |
| 517 | + |
507 | 518 | pfree(resultRelationInfo);
|
508 | 519 | resultRelationInfoList = lnext(resultRelationInfoList);
|
509 | 520 | }
|
510 | 521 | appendstate->as_result_relation_info_list = NIL;
|
511 |
| - /* |
512 |
| - * This next step is critical to prevent EndPlan() from trying to close |
513 |
| - * an already-closed-and-deleted RelationInfo --- es_result_relation_info |
514 |
| - * is pointing at one of the nodes we just zapped above. |
515 |
| - */ |
516 |
| - estate->es_result_relation_info = NULL; |
517 | 522 |
|
518 | 523 | /*
|
519 | 524 | * XXX should free appendstate->as_junkfilter_list here
|
|
0 commit comments