mirror of
https://github.com/postgres/postgres.git
synced 2026-03-03 22:00:57 -05:00
Prefer actual constants to pseudo-constants in equivalence class machinery.
generate_base_implied_equalities_const() should prefer plain Consts over other em_is_const eclass members when choosing the "pivot" value that all the other members will be equated to. This makes it more likely that the generated equalities will be useful in constraint-exclusion proofs. Per report from Rushabh Lathia.
This commit is contained in:
parent
9619fdca10
commit
b1f7ee9218
1 changed files with 8 additions and 2 deletions
|
|
@ -611,7 +611,12 @@ generate_base_implied_equalities_const(PlannerInfo *root,
|
|||
}
|
||||
}
|
||||
|
||||
/* Find the constant member to use */
|
||||
/*
|
||||
* Find the constant member to use. We prefer an actual constant to
|
||||
* pseudo-constants (such as Params), because the constraint exclusion
|
||||
* machinery might be able to exclude relations on the basis of generated
|
||||
* "var = const" equalities, but "var = param" won't work for that.
|
||||
*/
|
||||
foreach(lc, ec->ec_members)
|
||||
{
|
||||
EquivalenceMember *cur_em = (EquivalenceMember *) lfirst(lc);
|
||||
|
|
@ -619,7 +624,8 @@ generate_base_implied_equalities_const(PlannerInfo *root,
|
|||
if (cur_em->em_is_const)
|
||||
{
|
||||
const_em = cur_em;
|
||||
break;
|
||||
if (IsA(cur_em->em_expr, Const))
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert(const_em != NULL);
|
||||
|
|
|
|||
Loading…
Reference in a new issue