Asymmetric partition-wise JOIN: new bug

x000055ef9a0d872e in bms_equal (a=0x55ef9c48abf8, b=0x55ef9c48abf8) at bitmapset.c:126
#1  0x000055ef9a1b6079 in find_param_path_info (rel=0x55ef9c44a308, required_outer=0x55ef9c48abf8) at relnode.c:1634
#2  0x000055ef9a1aa70d in reparameterize_path_by_child (root=0x55ef9c446bf8, path=0x55ef9c48ad10, child_rel=0x55ef9c511530) at pathnode.c:4205
#3  0x000055ef9a1501e4 in try_nestloop_path (root=0x55ef9c446bf8, joinrel=0x55ef9c5224f0, outer_path=0x55ef9c512358, inner_path=0x55ef9c48ad10, pathkeys=0x0, jointype=JOIN_LEFT, 
    extra=0x7fff67683170) at joinpath.c:662
#4  0x000055ef9a151b14 in match_unsorted_outer (root=0x55ef9c446bf8, joinrel=0x55ef9c5224f0, outerrel=0x55ef9c511530, innerrel=0x55ef9c44a308, jointype=JOIN_LEFT, extra=0x7fff67683170)
    at joinpath.c:1702
#5  0x000055ef9a14f845 in add_paths_to_joinrel (root=0x55ef9c446bf8, joinrel=0x55ef9c5224f0, outerrel=0x55ef9c511530, innerrel=0x55ef9c44a308, jointype=JOIN_LEFT, sjinfo=0x55ef9c5220a0, 
    restrictlist=0x55ef9c522498) at joinpath.c:291
#6  0x000055ef9a154299 in populate_joinrel_with_paths (root=0x55ef9c446bf8, rel1=0x55ef9c511530, rel2=0x55ef9c44a308, joinrel=0x55ef9c5224f0, sjinfo=0x55ef9c5220a0, restrictlist=0x55ef9c522498)
    at joinrels.c:825
#7  0x000055ef9a155bcd in extract_asymmetric_partitionwise_subjoin (root=0x55ef9c446bf8, joinrel=0x55ef9c520648, append_path=0x55ef9c515138, inner_rel=0x55ef9c44a308, jointype=JOIN_LEFT, 
    extra=0x7fff67683480) at joinrels.c:1617
#8  0x000055ef9a155f1f in try_asymmetric_partitionwise_join (root=0x55ef9c446bf8, joinrel=0x55ef9c520648, outer_rel=0x55ef9c4ff9d8, inner_rel=0x55ef9c44a308, jointype=JOIN_LEFT, 
    extra=0x7fff67683480) at joinrels.c:1713
#9  0x000055ef9a14f953 in add_paths_to_joinrel (root=0x55ef9c446bf8, joinrel=0x55ef9c520648, outerrel=0x55ef9c4ff9d8, innerrel=0x55ef9c44a308, jointype=JOIN_LEFT, sjinfo=0x55ef9c44dcd0, 
    restrictlist=0x55ef9c5208e0) at joinpath.c:344
#10 0x000055ef9a154299 in populate_joinrel_with_paths (root=0x55ef9c446bf8, rel1=0x55ef9c4ff9d8, rel2=0x55ef9c44a308, joinrel=0x55ef9c520648, sjinfo=0x55ef9c44dcd0, restrictlist=0x55ef9c5208e0)
    at joinrels.c:825
#11 0x000055ef9a1540ba in make_join_rel (root=0x55ef9c446bf8, rel1=0x55ef9c4ff9d8, rel2=0x55ef9c44a308) at joinrels.c:761
#12 0x000055ef9a1535ef in make_rels_by_clause_joins (root=0x55ef9c446bf8, old_rel=0x55ef9c4ff9d8, other_rels_list=0x55ef9c48e718, other_rels=0x55ef9c48e730) at joinrels.c:313
#13 0x000055ef9a153112 in join_search_one_level (root=0x55ef9c446bf8, level=4) at joinrels.c:124
#14 0x000055ef9a134964 in standard_join_search (root=0x55ef9c446bf8, levels_needed=5, initial_rels=0x55ef9c48e718) at allpaths.c:3020
#15 0x000055ef9a1348d3 in make_rel_from_joinlist (root=0x55ef9c446bf8, joinlist=0x55ef9c412780) at allpaths.c:2951
#16 0x000055ef9a130287 in make_one_rel (root=0x55ef9c446bf8, joinlist=0x55ef9c412780) at allpaths.c:228
#17 0x000055ef9a16f38c in query_planner (root=0x55ef9c446bf8, qp_callback=0x55ef9a175023 <standard_qp_callback>, qp_extra=0x7fff67683960) at planmain.c:276
#18 0x000055ef9a171b06 in grouping_planner (root=0x55ef9c446bf8, tuple_fraction=0) at planner.c:1447
#19 0x000055ef9a1711c6 in subquery_planner (glob=0x55ef9c446ac8, parse=0x55ef9c389450, parent_root=0x0, hasRecursion=false, tuple_fraction=0) at planner.c:1025

Запрос (вставляется в partitionwise_aggregate.sql):

set enable_partitionwise_join to on;

select
  1
from fkpart5.fk as ref_1
     inner join fkpart5.pk31 as sample_0 tablesample system (4.1) on (ref_1.a = sample_0.a )
     inner join public.pagg_tab_para_p2 as ref_3 on (ref_1.a > 0.3)
     inner join fkpart5.pk2 as ref_4
     right join regress_indexing.pk as ref_5 on (ref_4.a = ref_5.a )
on (false);

Судя по всему, здесь и required_outer и ppi->ppi_req_outer указывают на уже освобожденный контекст. Причем виноват, видимо, именно ppi_req_outer. Проблема оказалась в новой логике, которую не понимает adjust_child_relids(): Иногда репараметризация может закончиться без изменений relids. Например, если параметр ссылается на таблицу, которая не является OTHER RELATION, а обычной таблицей.