Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 17804fa

Browse files
committed
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.
1 parent 5a39114 commit 17804fa

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/optimizer/path/equivclass.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,15 +769,21 @@ generate_base_implied_equalities_const(PlannerInfo *root,
769769
}
770770
}
771771

772-
/* Find the constant member to use */
772+
/*
773+
* Find the constant member to use. We prefer an actual constant to
774+
* pseudo-constants (such as Params), because the constraint exclusion
775+
* machinery might be able to exclude relations on the basis of generated
776+
* "var = const" equalities, but "var = param" won't work for that.
777+
*/
773778
foreach(lc, ec->ec_members)
774779
{
775780
EquivalenceMember *cur_em = (EquivalenceMember *) lfirst(lc);
776781

777782
if (cur_em->em_is_const)
778783
{
779784
const_em = cur_em;
780-
break;
785+
if (IsA(cur_em->em_expr, Const))
786+
break;
781787
}
782788
}
783789
Assert(const_em != NULL);

0 commit comments

Comments
 (0)