diff options
author | Michael Widenius <monty@askmonty.org> | 2010-10-06 13:11:06 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2010-10-06 13:11:06 +0300 |
commit | 00a2f36bbf22a4d8b2367724e7919c0603cf6f71 (patch) | |
tree | 71973f36df84d2f49752b01d6d18df9ec76f710c /sql | |
parent | 7d66e48d129ea46ace7c0d5dd67e39b3bae749ba (diff) | |
parent | ab428381ab27ffd04d44503a9dd0dd8d0ec3f27d (diff) | |
download | mariadb-git-00a2f36bbf22a4d8b2367724e7919c0603cf6f71.tar.gz |
Automatic merge with 5.1
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 1 | ||||
-rw-r--r-- | sql/records.cc | 3 | ||||
-rw-r--r-- | sql/sql_select.cc | 28 | ||||
-rw-r--r-- | sql/sql_select.h | 4 |
4 files changed, 24 insertions, 12 deletions
diff --git a/sql/item.h b/sql/item.h index e654458218a..2ec9044cd16 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2591,6 +2591,7 @@ public: { return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT; } + table_map not_null_tables() const { return 0; } virtual Ref_Type ref_type() { return OUTER_REF; } bool check_inner_refs_processor(uchar * arg); }; diff --git a/sql/records.cc b/sql/records.cc index 4c75ec10f0a..bdb27322a28 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -197,7 +197,8 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, tempfile= &select->file; else tempfile= table->sort.io_cache; - if (tempfile && my_b_inited(tempfile)) // Test if ref-records was used + if (tempfile && my_b_inited(tempfile) && + !(select && select->quick)) { DBUG_PRINT("info",("using rr_from_tempfile")); info->read_record= (table->sort.addon_field ? diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 54f0c83c48a..a89e0457fa4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6630,6 +6630,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) if (tmp_cond) { JOIN_TAB *cond_tab= tab < first_inner_tab ? first_inner_tab : tab; + Item **sel_cond_ref= tab < first_inner_tab ? + &first_inner_tab->on_precond : + &tab->select_cond; /* First add the guards for match variables of all embedding outer join operations. @@ -6652,14 +6655,14 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) tmp_cond->quick_fix_field(); /* Add the predicate to other pushed down predicates */ DBUG_PRINT("info", ("Item_cond_and")); - cond_tab->select_cond= !cond_tab->select_cond ? tmp_cond : - new Item_cond_and(cond_tab->select_cond, - tmp_cond); + *sel_cond_ref= !(*sel_cond_ref) ? + tmp_cond : + new Item_cond_and(*sel_cond_ref, tmp_cond); DBUG_PRINT("info", ("Item_cond_and 0x%lx", - (ulong)cond_tab->select_cond)); - if (!cond_tab->select_cond) - DBUG_RETURN(1); - cond_tab->select_cond->quick_fix_field(); + (ulong)(*sel_cond_ref))); + if (!(*sel_cond_ref)) + DBUG_RETURN(1); + (*sel_cond_ref)->quick_fix_field(); } } first_inner_tab= first_inner_tab->first_upper; @@ -11650,7 +11653,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) return (*join_tab->next_select)(join,join_tab+1,end_of_records); int error; - enum_nested_loop_state rc; + enum_nested_loop_state rc= NESTED_LOOP_OK; READ_RECORD *info= &join_tab->read_record; if (join->resume_nested_loop) @@ -11678,11 +11681,16 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) /* Set first_unmatched for the last inner table of this group */ join_tab->last_inner->first_unmatched= join_tab; + if (join_tab->on_precond && !join_tab->on_precond->val_int()) + rc= NESTED_LOOP_NO_MORE_ROWS; } join->thd->row_count= 0; - error= (*join_tab->read_first_record)(join_tab); - rc= evaluate_join_record(join, join_tab, error); + if (rc != NESTED_LOOP_NO_MORE_ROWS) + { + error= (*join_tab->read_first_record)(join_tab); + rc= evaluate_join_record(join, join_tab, error); + } } while (rc == NESTED_LOOP_OK) diff --git a/sql/sql_select.h b/sql/sql_select.h index fe3cc1af400..b3938fbbbb6 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -154,7 +154,9 @@ typedef struct st_join_table { TABLE *table; KEYUSE *keyuse; /**< pointer to first used key */ SQL_SELECT *select; - COND *select_cond; + COND *select_cond; + COND *on_precond; /**< part of on condition to check before + accessing the first inner table */ QUICK_SELECT_I *quick; Item **on_expr_ref; /**< pointer to the associated on expression */ COND_EQUAL *cond_equal; /**< multiple equalities for the on expression */ |