Skip to content

Commit f28eddf

Browse files
authored
Resolve conflicts in src/backend/optimizer/plan/subselect.c (#2579)
Commit d6c08e2 in the file src/backend/optimizer/plan/subselect.c in the make_subplan and subplan_is_hashable functions changed work_mem to hash_mem, and commit 41efb83 in the file src/backend/optimizer/plan/subselect.c in the make_subplan function changed the call to the subplan_is_hashable function to call a new function subpath_is_hashable, and also moved the call to the create_plan function under the condition, while the early commit 6b0e52b had already added the PlannerInfo *root argument and its use to the subplan_is_hashable function, and other early GPDB-specific commits had already added initialization of the curSlice and flow fields. Add a similar PlannerInfo *root argument to the subpath_is_hashable function and move the initialization of the curSlice and flow fields under the condition.
1 parent 2cb064c commit f28eddf

1 file changed

Lines changed: 11 additions & 23 deletions

File tree

src/backend/optimizer/plan/subselect.c

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,8 @@ static List *generate_subquery_params(PlannerInfo *root, List *tlist,
8787
List **paramIds);
8888
static Node *convert_testexpr_mutator(Node *node,
8989
convert_testexpr_context *context);
90-
<<<<<<< HEAD
9190
static bool subplan_is_hashable(PlannerInfo *root, Plan *plan);
92-
=======
93-
static bool subplan_is_hashable(Plan *plan);
94-
static bool subpath_is_hashable(Path *path);
95-
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d
91+
static bool subpath_is_hashable(PlannerInfo *root, Path *path);
9692
static bool testexpr_is_hashable(Node *testexpr, List *param_ids);
9793
static bool test_opexpr_is_hashable(OpExpr *testexpr, List *param_ids);
9894
static bool hash_ok_operator(OpExpr *expr);
@@ -477,27 +473,20 @@ make_subplan(PlannerInfo *root, Query *orig_subquery,
477473
final_rel = fetch_upper_rel(subroot, UPPERREL_FINAL, NULL);
478474
best_path = final_rel->cheapest_total_path;
479475

480-
<<<<<<< HEAD
481-
subroot->curSlice = palloc0(sizeof(PlanSlice));
482-
subroot->curSlice->gangType = GANGTYPE_UNALLOCATED;
483-
484-
plan = create_plan(subroot, best_path, subroot->curSlice);
485-
/* Decorate the top node of the plan with a Flow node. */
486-
plan->flow = cdbpathtoplan_create_flow(subroot, best_path->locus);
487-
488-
/* Now we can check if it'll fit in hash_mem */
489-
/* XXX can we check this at the Path stage? */
490-
if (subplan_is_hashable(root, plan))
491-
=======
492476
/* Now we can check if it'll fit in hash_mem */
493-
if (subpath_is_hashable(best_path))
494-
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d
477+
if (subpath_is_hashable(root, best_path))
495478
{
496479
SubPlan *hashplan;
497480
AlternativeSubPlan *asplan;
498481

482+
subroot->curSlice = palloc0(sizeof(PlanSlice));
483+
subroot->curSlice->gangType = GANGTYPE_UNALLOCATED;
484+
499485
/* OK, finish planning the ANY subquery */
500-
plan = create_plan(subroot, best_path);
486+
plan = create_plan(subroot, best_path, subroot->curSlice);
487+
/* Decorate the top node of the plan with a Flow node. */
488+
plan->flow = cdbpathtoplan_create_flow(subroot,
489+
best_path->locus);
501490

502491
/* ... and convert to SubPlan format */
503492
hashplan = castNode(SubPlan,
@@ -984,10 +973,9 @@ subplan_is_hashable(PlannerInfo *root, Plan *plan)
984973
* Identical to subplan_is_hashable, but work from a Path for the subplan.
985974
*/
986975
static bool
987-
subpath_is_hashable(Path *path)
976+
subpath_is_hashable(PlannerInfo *root, Path *path)
988977
{
989978
double subquery_size;
990-
int hash_mem = get_hash_mem();
991979

992980
/*
993981
* The estimated size of the subquery result must fit in hash_mem. (Note:
@@ -997,7 +985,7 @@ subpath_is_hashable(Path *path)
997985
*/
998986
subquery_size = path->rows *
999987
(MAXALIGN(path->pathtarget->width) + MAXALIGN(SizeofHeapTupleHeader));
1000-
if (subquery_size > hash_mem * 1024L)
988+
if (subquery_size > global_work_mem(root))
1001989
return false;
1002990

1003991
return true;

0 commit comments

Comments
 (0)