diff options
author | Georgi Kodinov <joro@sun.com> | 2009-10-29 17:24:29 +0200 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2009-10-29 17:24:29 +0200 |
commit | ac37324843b97fc69c307f8bab52af69c81c1245 (patch) | |
tree | d221a0705d7d09709a1d08cb97b87e91416f5248 /sql | |
parent | 0b10509e3b985a13af197f54decb7682bfacde77 (diff) | |
download | mariadb-git-ac37324843b97fc69c307f8bab52af69c81c1245.tar.gz |
Bug #42116 : Mysql crash on specific query
Queries with nested outer joins may lead to crashes or
bad results because an internal data structure is not handled
correctly.
The optimizer uses bitmaps of nested JOINs to determine
if certain table can be placed at a certain place in the
JOIN order.
It does maintain a bitmap describing in which JOINs
last placed table is nested.
When it puts a table it makes sure the bit of every JOIN that
contains the table in question is set (because JOINs can be nested).
It does that by recursively setting the bit for the next enclosing
JOIN when this is the first table in the JOIN and recursively
resetting the bit if it's the last table in the JOIN.
When it removes a table from the join order it should do the
opposite : recursively unset the bit if it's the only remaining
table in this join and and recursively set the bit if it's removing
the last table of a JOIN.
There was an error in how the bits was set for the upper levels :
when removing a table it was setting the bit for all the enclosing
nested JOINs even if there were more tables left in the current JOIN
(which practically means that the upper nested JOINs were not affected).
Fixed by stopping the recursion at the relevant level.
mysql-test/r/join.result:
Bug #42116: test case
mysql-test/t/join.test:
Bug #42116: test case
sql/sql_select.cc:
Bug #41116: don't go up and set the bits if more tables in
at the current JOIN level
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3bf67299d58..8136c6f7635 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8640,7 +8640,10 @@ static void restore_prev_nj_state(JOIN_TAB *last) join->cur_embedding_map&= ~last_emb->nested_join->nj_map; else if (last_emb->nested_join->join_list.elements-1 == last_emb->nested_join->counter) + { join->cur_embedding_map|= last_emb->nested_join->nj_map; + break; + } else break; last_emb= last_emb->embedding; |