Skip to content

Commit 32278d2

Browse files
committed
Rethink the way make_union_unique fetch upper rel.
Corrected the fetching of the upper UPPERREL_SETOP relation to avoid NULL bitmaps, which caused consider_parallel to be false. This inconsistency led to assertion failures in add_partial_path. Ensured the correct relation IDs are set before entering the function make_union_unique. Authored-by: Zhang Mingli avamingli@gmail.com
1 parent 7933cbd commit 32278d2

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/backend/optimizer/prep/prepunion.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ static List *plan_union_children(PlannerInfo *root,
7979
List *refnames_tlist,
8080
List **tlist_list);
8181
static Path *make_union_unique(SetOperationStmt *op, Path *path, List *tlist,
82-
PlannerInfo *root);
82+
PlannerInfo *root,
83+
Relids relids);
8384
static void postprocess_setop_rel(PlannerInfo *root, RelOptInfo *rel);
8485
static bool choose_hashed_setop(PlannerInfo *root, List *groupClauses,
8586
Path *input_path,
@@ -573,7 +574,7 @@ generate_recursion_path(SetOperationStmt *setOp, PlannerInfo *root,
573574
if (!setOp->all && CdbPathLocus_IsPartitioned(path->locus))
574575
{
575576
path = make_motion_hash_all_targets(root, path, tlist);
576-
path = make_union_unique(setOp, path, tlist, root);
577+
path = make_union_unique(setOp, path, tlist, root, bms_union(lrel->relids, rrel->relids));
577578
}
578579

579580
add_path(result_rel, path, root);
@@ -680,7 +681,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root,
680681
/* CDB: Hash motion to collocate non-distinct tuples. */
681682
path = make_motion_hash_all_targets(root, path, tlist);
682683
}
683-
path = make_union_unique(op, path, tlist, root);
684+
path = make_union_unique(op, path, tlist, root, relids);
684685
}
685686

686687
add_path(result_rel, path, root);
@@ -745,9 +746,9 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root,
745746
{
746747
ppath = make_motion_hash_all_targets(root, ppath, tlist);
747748
}
748-
ppath = make_union_unique(op, ppath, tlist, root);
749+
ppath = make_union_unique(op, ppath, tlist, root, relids);
749750
}
750-
add_path(result_rel, ppath, root);
751+
add_partial_path(result_rel, ppath);
751752
}
752753

753754
/* Undo effects of possibly forcing tuple_fraction to 0 */
@@ -1017,9 +1018,9 @@ plan_union_children(PlannerInfo *root,
10171018
*/
10181019
static Path *
10191020
make_union_unique(SetOperationStmt *op, Path *path, List *tlist,
1020-
PlannerInfo *root)
1021+
PlannerInfo *root, Relids relids)
10211022
{
1022-
RelOptInfo *result_rel = fetch_upper_rel(root, UPPERREL_SETOP, NULL);
1023+
RelOptInfo *result_rel = fetch_upper_rel(root, UPPERREL_SETOP, relids);
10231024
List *groupList;
10241025
double dNumGroups;
10251026

0 commit comments

Comments
 (0)