On 14/9/21 11:37, Andrey V. Lepikhov wrote:
> Thank you for this good catch!
> The problem was in the adjust_child_relids_multilevel routine. The
> tmp_result variable sometimes points to original required_outer.
> This patch adds new ways which optimizer can generate plans. One
> possible way is optimizer reparameterizes an inner by a plain relation
> from the outer (maybe as a result of join of the plain relation and
> partitioned relation). In this case we have to compare tmp_result with
> original pointer to realize, it was changed or not.
> The patch in attachment fixes this problem. Additional regression test
> added.
>
I thought more and realized there isn't necessary to recurse in the
adjust_child_relids_multilevel() routine if required_outer contains only
normal_relids.
Also, regression tests were improved a bit.
--
regards,
Andrey Lepikhov
Postgres Professional