diff options
author | unknown <bell@sanja.is.com.ua> | 2004-09-10 22:39:04 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-09-10 22:39:04 +0300 |
commit | 8b2ffdbfb97688d763c69a0563fa2de7504d59a5 (patch) | |
tree | 33f69f1b9e240b091e62d5d65cf94145a15f0fed /sql/table.cc | |
parent | b5983daa8cb962957d58b2a3b4e4b65a5b62882c (diff) | |
download | mariadb-git-8b2ffdbfb97688d763c69a0563fa2de7504d59a5.tar.gz |
view with WHERE in nested join (BUG#5511)
mysql-test/r/view.result:
view with WHERE in nested join
mysql-test/t/view.test:
view with WHERE in nested join
sql/table.cc:
fixed merging of VIEW
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/sql/table.cc b/sql/table.cc index 00913363635..4156da2d71a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1583,6 +1583,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds) if (where) { Item_arena *arena= thd->current_arena, backup; + TABLE_LIST *tbl= this; if (arena->is_conventional()) arena= 0; // For easier test @@ -1591,17 +1592,23 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds) if (arena) thd->set_n_backup_item_arena(arena, &backup); - if (outer_join) + + /* Go up to join tree and try to find left join */ + for (; tbl; tbl= tbl->embedding) { - /* - Store WHERE condition to ON expression for outer join, because we - can't use WHERE to correctly execute jeft joins on VIEWs and this - expression will not be moved to WHERE condition (i.e. will be clean - correctly for PS/SP) - */ - on_expr= and_conds(on_expr, where); + if (tbl->outer_join) + { + /* + Store WHERE condition to ON expression for outer join, because we + can't use WHERE to correctly execute jeft joins on VIEWs and this + expression will not be moved to WHERE condition (i.e. will be clean + correctly for PS/SP) + */ + on_expr= and_conds(tbl->on_expr, where); + break; + } } - else + if (tbl == 0) { /* It is conds of JOIN, but it will be stored in st_select_lex::prep_where @@ -1609,6 +1616,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds) */ *conds= and_conds(*conds, where); } + if (arena) thd->restore_backup_item_arena(arena, &backup); } |