diff --git a/src/backend/distributed/planner/distributed_planner.c b/src/backend/distributed/planner/distributed_planner.c index a38488626..cc83c66b6 100644 --- a/src/backend/distributed/planner/distributed_planner.c +++ b/src/backend/distributed/planner/distributed_planner.c @@ -1742,8 +1742,8 @@ multi_join_restriction_hook(PlannerInfo *root, * later safely convert any semi joins in the rewritten query to inner * joins. */ - plannerRestrictionContext->hasSemiJoin = plannerRestrictionContext->hasSemiJoin || - extra->sjinfo->jointype == JOIN_SEMI; + joinRestrictionContext->hasSemiJoin = joinRestrictionContext->hasSemiJoin || + extra->sjinfo->jointype == JOIN_SEMI; MemoryContextSwitchTo(oldMemoryContext); } diff --git a/src/backend/distributed/planner/query_pushdown_planning.c b/src/backend/distributed/planner/query_pushdown_planning.c index 863933759..dfade2acd 100644 --- a/src/backend/distributed/planner/query_pushdown_planning.c +++ b/src/backend/distributed/planner/query_pushdown_planning.c @@ -138,7 +138,9 @@ ShouldUseSubqueryPushDown(Query *originalQuery, Query *rewrittenQuery, * joins of type JOIN_SEMI are sent it is safe to convert all JOIN_SEMI * nodes to JOIN_INNER nodes (which is what is done in MultiNodeTree). */ - if (plannerRestrictionContext->hasSemiJoin) + JoinRestrictionContext *joinRestrictionContext = + plannerRestrictionContext->joinRestrictionContext; + if (joinRestrictionContext->hasSemiJoin) { return true; } diff --git a/src/backend/distributed/planner/relation_restriction_equivalence.c b/src/backend/distributed/planner/relation_restriction_equivalence.c index ae535f8bc..7b80b94e1 100644 --- a/src/backend/distributed/planner/relation_restriction_equivalence.c +++ b/src/backend/distributed/planner/relation_restriction_equivalence.c @@ -1897,6 +1897,9 @@ FilterJoinRestrictionContext(JoinRestrictionContext *joinRestrictionContext, Rel } } + /* the filtered restriction might not have semiJoin, but it is OK for now */ + filtererdJoinRestrictionContext->hasSemiJoin = joinRestrictionContext->hasSemiJoin; + return filtererdJoinRestrictionContext; } @@ -2016,6 +2019,9 @@ RemoveDuplicateJoinRestrictions(JoinRestrictionContext *joinRestrictionContext) lappend(filteredContext->joinRestrictionList, joinRestriction); } + /* the filtered restriction might not have semiJoin, but it is OK for now */ + filteredContext->hasSemiJoin = joinRestrictionContext->hasSemiJoin; + return filteredContext; } diff --git a/src/include/distributed/distributed_planner.h b/src/include/distributed/distributed_planner.h index 39d1de053..2b5836789 100644 --- a/src/include/distributed/distributed_planner.h +++ b/src/include/distributed/distributed_planner.h @@ -75,6 +75,7 @@ typedef struct RelationRestriction typedef struct JoinRestrictionContext { List *joinRestrictionList; + bool hasSemiJoin; } JoinRestrictionContext; typedef struct JoinRestriction @@ -116,7 +117,6 @@ typedef struct PlannerRestrictionContext * Instead, we keep this struct to pass some extra information. */ FastPathRestrictionContext *fastPathRestrictionContext; - bool hasSemiJoin; MemoryContext memoryContext; } PlannerRestrictionContext;