From: Tom Lane Date: Fri, 29 Oct 2010 18:44:49 +0000 (-0400) Subject: Oops, missed one fix for EquivalenceClass rearrangement. X-Git-Tag: REL9_1_ALPHA2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=48a1fb23900d73e7d9cb2dc0408c745cd03597a7;p=thirdparty%2Fpostgresql.git Oops, missed one fix for EquivalenceClass rearrangement. Now that we're expecting a mergeclause's left_ec/right_ec to persist from the initial assignments, we can't just blithely zero these out when transforming such a clause in adjust_appendrel_attrs. But really it should be okay to keep the parent's values, since a child table's derived Var ought to be equivalent to the parent Var for all EquivalenceClass purposes. (Indeed, I'm wondering whether we couldn't find a way to dispense with add_child_rel_equivalences altogether. But this is wrong in any case.) --- diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 0d3a739175a..45ecde416f9 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -1682,13 +1682,13 @@ adjust_appendrel_attrs_mutator(Node *node, AppendRelInfo *context) /* * Reset cached derivative fields, since these might need to have - * different values when considering the child relation. + * different values when considering the child relation. Note we + * don't reset left_ec/right_ec: each child variable is implicitly + * equivalent to its parent, so still a member of the same EC if any. */ newinfo->eval_cost.startup = -1; newinfo->norm_selec = -1; newinfo->outer_selec = -1; - newinfo->left_ec = NULL; - newinfo->right_ec = NULL; newinfo->left_em = NULL; newinfo->right_em = NULL; newinfo->scansel_cache = NIL;