diff options
author | unknown <igor@olga.mysql.com> | 2007-07-11 18:45:35 -0700 |
---|---|---|
committer | unknown <igor@olga.mysql.com> | 2007-07-11 18:45:35 -0700 |
commit | b1e55680437cefcfa087fd7531c0d351da87306e (patch) | |
tree | e6e15595445a2187d8dbc6728634481883343ed7 /sql/sql_select.cc | |
parent | 25cba4500946f8c31488b008e86b54989ccd9c38 (diff) | |
download | mariadb-git-b1e55680437cefcfa087fd7531c0d351da87306e.tar.gz |
Fixed bug #29604.
A bug in the restore_prev_nj_state function allowed interleaving
inner tables of outer join operations with outer tables. With the
current implementation of the nested loops algorithm it could lead
to wrong result sets for queries with nested outer joins.
Another bug in this procedure effectively blocked evaluation of some
valid execution plans for queries with nested outer joins.
mysql-test/r/join_nested.result:
Added a test case for bug #29604.
mysql-test/t/join_nested.test:
Added a test case for bug #29604.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9d27ab4bb4e..c62a19b2752 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8486,9 +8486,15 @@ static void restore_prev_nj_state(JOIN_TAB *last) { TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding; JOIN *join= last->join; - while (last_emb && !(--last_emb->nested_join->counter)) + while (last_emb) { - join->cur_embedding_map &= last_emb->nested_join->nj_map; + if (!(--last_emb->nested_join->counter)) + 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; + else + break; last_emb= last_emb->embedding; } } |