aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeAppend.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-11-09 18:12:53 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-11-09 18:12:53 +0000
commit343f615e3ada8a7e9662b33341b73f09e182d105 (patch)
tree3cb77c470442e2a05647b4cb5b0724ca10c5ed67 /src/backend/executor/nodeAppend.c
parent5cbbdd2ecb1ff820e37793fc2237339df756d3dc (diff)
downloadpostgresql-343f615e3ada8a7e9662b33341b73f09e182d105.tar.gz
postgresql-343f615e3ada8a7e9662b33341b73f09e182d105.zip
ExecEndAppend() neglected to close indices on appended result rels,
and improperly prevented the main result rel from being closed if it wasn't one of the Append's own result rels. Per report from Hiroshi.
Diffstat (limited to 'src/backend/executor/nodeAppend.c')
-rw-r--r--src/backend/executor/nodeAppend.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c
index 6c547854b55..81eeb1e8b0b 100644
--- a/src/backend/executor/nodeAppend.c
+++ b/src/backend/executor/nodeAppend.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.36 2000/10/05 19:11:26 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.37 2000/11/09 18:12:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -493,27 +493,32 @@ ExecEndAppend(Append *node)
/* ----------------
* close out the different result relations
+ *
+ * NB: this must agree with what EndPlan() does to close a result rel
* ----------------
*/
resultRelationInfoList = appendstate->as_result_relation_info_list;
while (resultRelationInfoList != NIL)
{
RelationInfo *resultRelationInfo;
- Relation resultRelationDesc;
resultRelationInfo = (RelationInfo *) lfirst(resultRelationInfoList);
- resultRelationDesc = resultRelationInfo->ri_RelationDesc;
- heap_close(resultRelationDesc, NoLock);
+
+ heap_close(resultRelationInfo->ri_RelationDesc, NoLock);
+ /* close indices on the result relation, too */
+ ExecCloseIndices(resultRelationInfo);
+
+ /*
+ * estate may (or may not) be pointing at one of my result relations.
+ * If so, make sure EndPlan() doesn't try to close it again!
+ */
+ if (estate->es_result_relation_info == resultRelationInfo)
+ estate->es_result_relation_info = NULL;
+
pfree(resultRelationInfo);
resultRelationInfoList = lnext(resultRelationInfoList);
}
appendstate->as_result_relation_info_list = NIL;
- /*
- * This next step is critical to prevent EndPlan() from trying to close
- * an already-closed-and-deleted RelationInfo --- es_result_relation_info
- * is pointing at one of the nodes we just zapped above.
- */
- estate->es_result_relation_info = NULL;
/*
* XXX should free appendstate->as_junkfilter_list here