diff options
author | Igor Babaev <igor@askmonty.org> | 2011-03-13 03:50:14 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2011-03-13 03:50:14 -0700 |
commit | edc69e3227dee351bd0dda7a835cb696ec502ba1 (patch) | |
tree | 45df8e65d2664224ce065b833bc32f231c3cd34f /sql | |
parent | 26d6806f985900ac906600acc7ebace1312f6638 (diff) | |
parent | 3d3d5f1d431f2631d57a4f28fb5bd5fff9cd6c53 (diff) | |
download | mariadb-git-edc69e3227dee351bd0dda7a835cb696ec502ba1.tar.gz |
Merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_select.cc | 25 | ||||
-rw-r--r-- | sql/sql_select.h | 2 |
2 files changed, 23 insertions, 4 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0fb062e37a3..91f673057ec 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6894,7 +6894,7 @@ static void add_not_null_conds(JOIN *join) UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); not_null_item is the t1.f1, but it's referred_tab is 0. */ - if (!referred_tab || referred_tab->join != join) + if (!referred_tab) continue; if (!(notnull= new Item_func_isnotnull(not_null_item))) DBUG_VOID_RETURN; @@ -6911,9 +6911,14 @@ static void add_not_null_conds(JOIN *join) QT_ORDINARY);); if (!tab->first_inner) { - COND *new_cond= referred_tab->select_cond; + COND *new_cond= referred_tab->join == join ? + referred_tab->select_cond : + join->outer_ref_cond; add_cond_and_fix(&new_cond, notnull); - referred_tab->set_select_cond(new_cond, __LINE__); + if (referred_tab->join == join) + referred_tab->set_select_cond(new_cond, __LINE__); + else + join->outer_ref_cond= new_cond; } else add_cond_and_fix(tab->first_inner->on_expr_ref, notnull); @@ -7130,6 +7135,15 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) DBUG_PRINT("info",("Found impossible WHERE condition")); DBUG_RETURN(1); // Impossible const condition } + + COND *outer_ref_cond= make_cond_for_table(cond, + OUTER_REF_TABLE_BIT, + (table_map) 0, FALSE, FALSE); + if (outer_ref_cond) + { + add_cond_and_fix(&outer_ref_cond, join->outer_ref_cond); + join->outer_ref_cond= outer_ref_cond; + } } } @@ -13401,7 +13415,10 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) else { DBUG_ASSERT(join->tables); - error= join->first_select(join,join_tab,0); + if (join->outer_ref_cond && !join->outer_ref_cond->val_int()) + error= NESTED_LOOP_NO_MORE_ROWS; + else + error= join->first_select(join,join_tab,0); if (error == NESTED_LOOP_OK || error == NESTED_LOOP_NO_MORE_ROWS) error= join->first_select(join,join_tab,1); if (error == NESTED_LOOP_QUERY_LIMIT) diff --git a/sql/sql_select.h b/sql/sql_select.h index 06eaa8c9485..33a278002a1 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -798,6 +798,7 @@ public: ORDER *order, *group_list, *proc_param; //hold parameters of mysql_select COND *conds; // ---"--- Item *conds_history; // store WHERE for explain + COND *outer_ref_cond; ///<part of conds containing only outer references TABLE_LIST *tables_list; ///<hold 'tables' parameter of mysql_select List<TABLE_LIST> *join_list; ///< list of joined tables in reverse order COND_EQUAL *cond_equal; @@ -903,6 +904,7 @@ public: no_const_tables= FALSE; first_select= sub_select; + outer_ref_cond= 0; } int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num, |