mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
BUG#834534: Assertion `0' failed in replace_where_subcondition with semijoin subquery in HAVING
- The problem was that the code that made the check whether the subquery is an AND-part of the WHERE clause didn't work correctly for nested subqueries. In particular, grand-child subquery in HAVING was treated as if it was in the WHERE, which eventually caused an assert when replace_where_subcondition looked for the subquery predicate in the WHERE and couldn't find it there. - The fix: Removed implementation of "thd_marker approach". thd->thd_marker was used to determine the location of subquery predicate: setup_conds() would set accordingly it when making the {where|on_expr}->fix_fields(...) call so that AND-parts of the WHERE/ON clauses can determine they are the AND-parts. Item_cond_or::fix_fields(), Item_func::fix_fields(), Item_subselect::fix_fields (this one was missed), and all other items-that-contain-items had to reset thd->thd_marker before calling fix_fields() for their children items, so that the children can see they are not AND-parts of WHERE/ON. - The "thd_marker approach" required that a lot of code in different locations maintains correct value of thd->thd_marker, so it was replaced with: - The new approach with mark_as_condition_AND_part does not keep context in thd->thd_marker. Instead, setup_conds() now calls {where|on_expr}->mark_as_condition_AND_part() and implementations of that function make sure that: - parts of AND-expressions get the mark_as_condition_AND_part() call - Item_in_subselect objects record that they are AND-parts of WHERE/ON
This commit is contained in:
@ -8276,7 +8276,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
|
||||
SELECT_LEX *select_lex= thd->lex->current_select;
|
||||
Query_arena *arena= thd->stmt_arena, backup;
|
||||
TABLE_LIST *table= NULL; // For HP compilers
|
||||
TABLE_LIST *save_emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest;
|
||||
List_iterator<TABLE_LIST> ti(leaves);
|
||||
/*
|
||||
it_is_update set to TRUE when tables of primary SELECT_LEX (SELECT_LEX
|
||||
@ -8317,7 +8316,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
|
||||
goto err_no_arena;
|
||||
}
|
||||
|
||||
thd->thd_marker.emb_on_expr_nest= NO_JOIN_NEST;
|
||||
if (*conds)
|
||||
{
|
||||
thd->where="where clause";
|
||||
@ -8331,11 +8329,11 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
|
||||
*/
|
||||
if ((*conds)->type() == Item::FIELD_ITEM && !derived)
|
||||
wrap_ident(thd, conds);
|
||||
(*conds)->mark_as_condition_AND_part(NO_JOIN_NEST);
|
||||
if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) ||
|
||||
(*conds)->check_cols(1))
|
||||
goto err_no_arena;
|
||||
}
|
||||
thd->thd_marker.emb_on_expr_nest= save_emb_on_expr_nest;
|
||||
|
||||
/*
|
||||
Apply fix_fields() to all ON clauses at all levels of nesting,
|
||||
@ -8351,8 +8349,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
|
||||
if (embedded->on_expr)
|
||||
{
|
||||
/* Make a join an a expression */
|
||||
thd->thd_marker.emb_on_expr_nest= embedded;
|
||||
thd->where="on clause";
|
||||
embedded->on_expr->mark_as_condition_AND_part(embedded);
|
||||
if ((!embedded->on_expr->fixed &&
|
||||
embedded->on_expr->fix_fields(thd, &embedded->on_expr)) ||
|
||||
embedded->on_expr->check_cols(1))
|
||||
@ -8376,7 +8374,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
|
||||
}
|
||||
}
|
||||
}
|
||||
thd->thd_marker.emb_on_expr_nest= save_emb_on_expr_nest;
|
||||
|
||||
if (!thd->stmt_arena->is_conventional())
|
||||
{
|
||||
|
Reference in New Issue
Block a user