Skip to content

Commit 0b2eb33

Browse files
yjhjstzmy-ship-it
authored andcommitted
Revert "Fix crashes of lateral join (#16958)"
This reverts commit 0f96542.
1 parent c924030 commit 0b2eb33

File tree

10 files changed

+356
-495
lines changed

10 files changed

+356
-495
lines changed

src/backend/cdb/cdbmutate.c

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,107 +1960,3 @@ contains_outer_params(Node *node, void *context)
19601960
}
19611961
return expression_tree_walker(node, contains_outer_params, context);
19621962
}
1963-
1964-
typedef struct CTEMotionSearchContext
1965-
{
1966-
plan_tree_base_prefix base; /* Required prefix for plan_tree_walker/mutator */
1967-
bool bellowMotion; /* True if we are under a Motion node */
1968-
} CTEMotionSearchContext;
1969-
1970-
/*
1971-
* We can not pass params by a motion.
1972-
* So there should not be any motion between RecursiveUnion and WorkTableScan.
1973-
* Check if there is a motion between RecursiveUnion and WorkTableScan.
1974-
*/
1975-
static bool
1976-
cte_motion_search_walker(Node *node, CTEMotionSearchContext *context)
1977-
{
1978-
if (node == NULL)
1979-
return false;
1980-
1981-
if (IsA(node, Motion))
1982-
{
1983-
bool savedBellowMotion = context->bellowMotion;
1984-
context->bellowMotion = true;
1985-
plan_tree_walker(node, cte_motion_search_walker, context, true);
1986-
context->bellowMotion = savedBellowMotion;
1987-
return false;
1988-
}
1989-
if (IsA(node, RecursiveUnion))
1990-
{
1991-
/*
1992-
* We process RecursiveUnion recursively in create_recursiveunion_plan
1993-
* here, we do not process repeatedly.
1994-
*/
1995-
return false;
1996-
}
1997-
if (IsA(node, WorkTableScan))
1998-
{
1999-
if (context->bellowMotion)
2000-
{
2001-
elog(ERROR, "Passing parameters across motion is not supported.");
2002-
}
2003-
return false;
2004-
}
2005-
return plan_tree_walker(node, cte_motion_search_walker, context, true);
2006-
}
2007-
2008-
/*
2009-
* GPDB does not support pass params by a motion.
2010-
* Check the rightplan of RecursiveUnion, wether there is a motion above WorkTableScan,
2011-
* If true, throw an error.
2012-
*/
2013-
void
2014-
checkMotionAboveWorkTableScan(Node* node, PlannerInfo *root)
2015-
{
2016-
CTEMotionSearchContext context;
2017-
planner_init_plan_tree_base(&context.base, root);
2018-
context.bellowMotion = false;
2019-
2020-
(void) cte_motion_search_walker(node, (void *) &context);
2021-
}
2022-
2023-
typedef struct MotionWithParamContext
2024-
{
2025-
plan_tree_base_prefix base; /* Required prefix for plan_tree_walker/mutator */
2026-
Bitmapset *nestLoopParams; /* nestloop params */
2027-
} MotionWithParamContext;
2028-
2029-
/*
2030-
* check whether pass params by a motion
2031-
*/
2032-
static bool
2033-
checkMotionWithParamWalker(Node *node, MotionWithParamContext* motionWithParamcontext)
2034-
{
2035-
if (node == NULL)
2036-
return false;
2037-
2038-
if (IsA(node, Motion))
2039-
{
2040-
Plan * plan = (Plan *) node;
2041-
Bitmapset *finalExtParam;
2042-
if (!bms_is_empty(plan->extParam))
2043-
{
2044-
finalExtParam = bms_intersect(plan->extParam, motionWithParamcontext->nestLoopParams);
2045-
if (!bms_is_empty(finalExtParam))
2046-
{
2047-
elog(ERROR, "Passing parameters across motion is not supported.");
2048-
}
2049-
}
2050-
}
2051-
2052-
return plan_tree_walker(node, checkMotionWithParamWalker, motionWithParamcontext, true);
2053-
}
2054-
2055-
/*
2056-
* We can not deliver a param by a motion node.
2057-
* If there is a param on motion node, we should throw an error.
2058-
*/
2059-
void
2060-
checkMotionWithParam(Node *node, Bitmapset *bmsNestParams, PlannerInfo *root)
2061-
{
2062-
MotionWithParamContext motionWithParamcontext;
2063-
motionWithParamcontext.nestLoopParams = bmsNestParams;
2064-
planner_init_plan_tree_base(&motionWithParamcontext.base, root);
2065-
checkMotionWithParamWalker(node, &motionWithParamcontext);
2066-
}

src/backend/optimizer/plan/createplan.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,11 +3088,6 @@ create_recursiveunion_plan(PlannerInfo *root, RecursiveUnionPath *best_path)
30883088
best_path->distinctList,
30893089
numGroups);
30903090

3091-
/*
3092-
* Check whether there is a motion above WorkTableScan
3093-
*/
3094-
checkMotionAboveWorkTableScan((Node *)rightplan, root);
3095-
30963091
copy_generic_path_info(&plan->plan, (Path *) best_path);
30973092

30983093
return plan;

src/backend/optimizer/plan/subselect.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3334,19 +3334,6 @@ finalize_plan(PlannerInfo *root, Plan *plan,
33343334
gather_param,
33353335
bms_union(nestloop_params, valid_params),
33363336
scan_params);
3337-
/*
3338-
* Currently GPDB doesn't fully support lateral, following sql will
3339-
* pass params by a motion. Then cause panic in QE.
3340-
* So add a walker to check whether motion in righttree of nestloop
3341-
* will pass params, if true throw an error to avoid panic in QE.
3342-
* explain SELECT * FROM
3343-
* (VALUES (0.0),(10.4),(100.7)) v(nrows),
3344-
* LATERAL (SELECT count(*) FROM test_tablesample
3345-
* TABLESAMPLE system_rows (nrows)) ss;
3346-
*/
3347-
if (IsA(plan, NestLoop) && !bms_is_empty(nestloop_params))
3348-
checkMotionWithParam((Node*) plan->righttree, nestloop_params, root);
3349-
33503337
/* ... and they don't count as parameters used at my level */
33513338
child_params = bms_difference(child_params, nestloop_params);
33523339
bms_free(nestloop_params);

src/include/cdb/cdbmutate.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,5 @@ extern void remove_subquery_in_RTEs(Node *node);
5656
extern Plan *cdbpathtoplan_create_sri_plan(RangeTblEntry *rte, PlannerInfo *subroot, Path *subpath, int createplan_flags);
5757

5858
extern bool contains_outer_params(Node *node, void *context);
59-
extern void checkMotionAboveWorkTableScan(Node* node, PlannerInfo *root);
60-
extern void checkMotionWithParam(Node *node, Bitmapset *bmsNestParams, PlannerInfo *root);
59+
6160
#endif /* CDBMUTATE_H */

0 commit comments

Comments
 (0)