• Tom Lane's avatar
    Fix old bug in get_loop_count(). · b746d0c3
    Tom Lane authored
    While poking at David Kubečka's issue I noticed an ancient logic error
    in get_loop_count(): it used 1.0 as a "no data yet" indicator, but since
    that is actually a valid rowcount estimate, this doesn't work.  If we
    have one input relation with 1.0 as rowcount and then another one with
    a larger rowcount, we should use 1.0 as the result, but we picked the
    larger rowcount instead.  (I think when I coded this, I recognized the
    conflict, but mistakenly thought that the logic would pick the desired
    count anyway.)
    
    Fixing this changed the plan for one existing regression test case.
    Since the point of that test is to exercise creation of a particular
    shape of nestloop plan, I tweaked the query a little bit so it still
    results in the same plan choice.
    
    This is definitely a bug, but I'm hesitant to back-patch since it might
    change plan choices unexpectedly, and anyway failure to implement a
    heuristic precisely as intended is a pretty low-grade bug.
    b746d0c3
indxpath.c 128 KB