Skip to content

Commit

Permalink
Invert condition 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyacheslav Kompan committed Dec 8, 2023
1 parent d89f9da commit 37323e4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/backend/optimizer/path/allpaths.c
Original file line number Diff line number Diff line change
Expand Up @@ -2112,10 +2112,10 @@ set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)

/*
* Sharing General and SegmentGeneral subplan may lead to deadlock
* when executed with 1-gang and joined with n-gang.
* when executed with 1-gang and joined with N-gang.
*/
if (CdbPathLocus_IsGeneral(*subplan->flow) ||
CdbPathLocus_IsSegmentGeneral(*subplan->flow))
CdbPathLocus_IsSegmentGeneral(*subplan->flow))
{
cteplaninfo->subplan = subplan;
}
Expand All @@ -2132,19 +2132,20 @@ set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
* subplan if not avoiding sharing for General and SegmentGeneral
* subplans.
*/
if (!CdbPathLocus_IsGeneral(*cteplaninfo->subplan->flow) &&
!CdbPathLocus_IsSegmentGeneral(*cteplaninfo->subplan->flow))
{
subplan = share_prepared_plan(cteroot, cteplaninfo->subplan);
}
else if (subplan == NULL)
if (CdbPathLocus_IsGeneral(*cteplaninfo->subplan->flow) ||
CdbPathLocus_IsSegmentGeneral(*cteplaninfo->subplan->flow))
{
/*
* If we are not sharing and subplan was created just now, use it.
* Otherwise, make a copy of it to avoid construction of DAG
* instead of a tree.
*/
subplan = (Plan *) copyObject(cteplaninfo->subplan);
if (subplan == NULL)
subplan = (Plan *) copyObject(cteplaninfo->subplan);
}
else
{
subplan = share_prepared_plan(cteroot, cteplaninfo->subplan);
}

subroot = cteplaninfo->subroot;
Expand Down

0 comments on commit 37323e4

Please sign in to comment.