diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-01-15 19:07:46 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-01-15 19:07:46 +0100 |
commit | aca8e7ed6b176f28e8a34ebddc989574d93f305c (patch) | |
tree | c0d20e5b3e9518f48d789e2220eea46d9010966d /sql/table.cc | |
parent | 750b9147fced7202b541be946e044eb739b20a03 (diff) | |
parent | 4f67a14700c0266c58b05be0dbd8fc10f88464a6 (diff) | |
download | mariadb-git-aca8e7ed6b176f28e8a34ebddc989574d93f305c.tar.gz |
5.3 merge
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/sql/table.cc b/sql/table.cc index cc3ab6f8c36..a36a6d19484 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -4966,19 +4966,33 @@ TABLE *TABLE_LIST::get_real_join_table() DBUG_ASSERT(tbl->derived == NULL || tbl->derived->first_select()->next_select() == NULL); - if (tbl->table) - table= tbl->table; - tbl= (tbl->view != NULL ? - tbl->view->select_lex.get_table_list() : - tbl->derived->first_select()->get_table_list()); - - /* find left table in outer join on this level */ - while(tbl->outer_join & JOIN_TYPE_RIGHT) { - DBUG_ASSERT(tbl->next_local); - tbl= tbl->next_local; + List_iterator_fast<TABLE_LIST> ti; + { + List_iterator_fast<TABLE_LIST> + ti(tbl->view != NULL ? + tbl->view->select_lex.top_join_list : + tbl->derived->first_select()->top_join_list); + for (;;) + { + tbl= NULL; + /* + Find left table in outer join on this level + (the list is reverted). + */ + for (TABLE_LIST *t= ti++; t; t= ti++) + tbl= t; + /* + It is impossible that the list is empty + so tbl can't be NULL after above loop. + */ + if (!tbl->nested_join) + break; + /* go deeper if we've found nested join */ + ti= tbl->nested_join->join_list; + } + } } - } return tbl->table; |