[MDEV-5387] Assertion `0' fails in Item_equal::get_first with materialization+semijoin, EXPLAIN, IN subquery Created: 2013-12-04 Updated: 2022-09-08 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.3.12, 5.5.34, 10.0.6 |
| Fix Version/s: | 5.5 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Elena Stepanova | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||
| Description |
|
I've set it to 'Minor' because there is a rather senseless condition in WHERE, so it can be considered a corner case, and because it's a debug assertion only
|
| Comments |
| Comment by Sergei Petrunia [ 2014-02-17 ] |
|
Modified the query to make table names unique: create table t3a like t3; The crash happens when attempting to substitute_for_best_equal() for ref access on table t3a. The ref access is for "t3.e= t2.c" We're looking for top-level multi-equalities (cond_equal->current_level). The first one we find is The substitution happens in the context of JOIN_TAB(t3a). In Item_equal::get_first(..) we have: (gdb) p emb_nest Item_equal has only "t2.c" and "t1.a". Basically, we're inside an SJ-Materialization nest, and we're looking for an appropriate substitute for item that's outside the SJM-nest. We fail to find it, and assertion is fired. |
| Comment by Sergei Petrunia [ 2014-02-17 ] |
|
Prettified the query:
t2.b is NULLable, there is an index on t2.b (which means that the optimizer should infer that the top select has "Impossible WHERE"). |
| Comment by Sergei Petrunia [ 2014-02-17 ] |
|
Debugging in fix_semijoin_strategies_for_picked_join_order(), I can see that t2 fix_semijoin_strategies_for_picked_join_order calls best_access_path() for |
| Comment by Sergei Petrunia [ 2014-02-17 ] |
|
... I actually don't understand why fix_semijoin_...() re-runs best_access_path() for tables inside the SJM nest. Query plan for performing SJ-materialization has been produced and stashed away by optimize_semijoin_tests(). Why not re-use it? We might want to re-run best_access_path() for some tables outside the SJM nest, because SJ-Materialization changes their fanout. But this doesn't apply to tables inside the SJM nest. |
| Comment by Sergei Petrunia [ 2014-02-17 ] |
|
Another puzzling thing is, why is join optimizer invoked at all, when we know that the WHERE has an impossible condition? If I work around the crash in debugger, the EXPLAIN will show "Impossible WHERE noticed after reading const tables". |