{
Relids top_parent_relids = child_joinrel->top_parent_relids;
Relids child_relids = child_joinrel->relids;
+ MemoryContext oldcontext;
ListCell *lc1;
Assert(IS_JOIN_REL(child_joinrel) && IS_JOIN_REL(parent_joinrel));
+ /*
+ * If we're being called during GEQO join planning, we still have to
+ * create any new EC members in the main planner context, to avoid having
+ * a corrupt EC data structure after the GEQO context is reset. This is
+ * problematic since we'll leak memory across repeated GEQO cycles. For
+ * now, though, bloat is better than crash. If it becomes a real issue
+ * we'll have to do something to avoid generating duplicate EC members.
+ */
+ oldcontext = MemoryContextSwitchTo(root->planner_cxt);
+
foreach(lc1, root->eq_classes)
{
EquivalenceClass *cur_ec = (EquivalenceClass *) lfirst(lc1);
}
}
}
+
+ MemoryContextSwitchTo(oldcontext);
}