On Wed, Jun 28, 2023 at 10:09 PM Tom Lane <t...@sss.pgh.pa.us> wrote:

> Those cases will go through calc_non_nestloop_required_outer
> which has
>
>         /* neither path can require rels from the other */
>         Assert(!bms_overlap(outer_paramrels, inner_path->parent->relids));
>         Assert(!bms_overlap(inner_paramrels, outer_path->parent->relids));


Looking at these two assertions it occurred to me that shouldn't we
check against top_parent_relids for an otherrel since paths are
parameterized by top-level parents?  We do that in try_nestloop_path.

    /* neither path can require rels from the other */
-   Assert(!bms_overlap(outer_paramrels, inner_path->parent->relids));
-   Assert(!bms_overlap(inner_paramrels, outer_path->parent->relids));
+   Assert(!bms_overlap(outer_paramrels,
+                       inner_path->parent->top_parent_relids ?
+                       inner_path->parent->top_parent_relids :
+                       inner_path->parent->relids));
+   Assert(!bms_overlap(inner_paramrels,
+                       outer_path->parent->top_parent_relids ?
+                       outer_path->parent->top_parent_relids :
+                       outer_path->parent->relids));

This is not related to the issue being discussed here.  Maybe it should
be a separate issue.

Thanks
Richard

Reply via email to