From ab226166518936d81029fbaab7c8aba9fe1550ec Mon Sep 17 00:00:00 2001 From: Andy Fan Date: Mon, 17 Oct 2022 09:08:37 +0800 Subject: [PATCH v1 2/2] This patch doesn't mean I insist on this at all, it just shows where I'm lost. --- src/backend/optimizer/prep/prepjointree.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index 41c7066d90a..581ff2db36b 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -551,12 +551,24 @@ pull_up_sublinks_qual_recurse(PlannerInfo *root, Node *node, * joins can get stacked onto either j->larg or j->rarg, * depending on which rels they reference. */ + + /* + * Here the j comes from convert_EXISTS_sublink_to_join, so + * j->jointype must be SEMIJOIN, so no left/right/full outer + * join involved. I prefer to believe that: + * + * A semi join B on exists (select 1 from C on (Pbc)) -- id1 + * = A semi join (B semi join C on (Pbc) ) on true -- id2 current master does. + * = (A semi join B on true) semi join C on (Pbc) -- id3 this patch does. + * + * I think this is the place I lost:( + */ j->quals = pull_up_sublinks_qual_recurse(root, j->quals, - &j->larg, - available_rels1, - &j->rarg, - child_rels); + jtlink1, + bms_union(available_rels1, child_rels), + NULL, + NULL); /* Return NULL representing constant TRUE */ return NULL; } -- 2.21.0