diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-12-13 13:00:38 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-12-13 13:00:38 +0100 |
commit | e68bccc743ddd5ee9b0e47ff73b57d088f015f17 (patch) | |
tree | f524c15c650c94dd8bab87899b04ae767544b5a2 /sql | |
parent | ca083a764f14233dfd7f97436629020901bd23a6 (diff) | |
parent | 3ec4296ec413e866c3efabc8dfa94172ad5f7c04 (diff) | |
download | mariadb-git-e68bccc743ddd5ee9b0e47ff73b57d088f015f17.tar.gz |
5.3 merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 7 | ||||
-rw-r--r-- | sql/item_func.h | 3 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 | ||||
-rw-r--r-- | sql/sql_lex.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 5 | ||||
-rw-r--r-- | sql/sql_union.cc | 18 | ||||
-rw-r--r-- | sql/table.cc | 6 |
7 files changed, 29 insertions, 16 deletions
diff --git a/sql/item.h b/sql/item.h index 8074f11da6b..c4fe24bf482 100644 --- a/sql/item.h +++ b/sql/item.h @@ -3269,13 +3269,16 @@ class Item_direct_view_ref :public Item_direct_ref TABLE_LIST *view; TABLE *null_ref_table; +#define NO_NULL_TABLE (reinterpret_cast<TABLE *>(0x1)) + bool check_null_ref() { if (null_ref_table == NULL) { - null_ref_table= view->get_real_join_table(); + if (!(null_ref_table= view->get_real_join_table())) + null_ref_table= NO_NULL_TABLE; } - if (null_ref_table->null_row) + if (null_ref_table != NO_NULL_TABLE && null_ref_table->null_row) { null_value= 1; return TRUE; diff --git a/sql/item_func.h b/sql/item_func.h index bbf7643eaa0..f1dbbb09305 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -160,7 +160,8 @@ public: inline bool get_arg0_time(MYSQL_TIME *ltime) { null_value= args[0]->get_time(ltime); - DBUG_ASSERT(ltime->time_type != MYSQL_TIMESTAMP_TIME || ltime->day == 0); + DBUG_ASSERT(null_value || + ltime->time_type != MYSQL_TIMESTAMP_TIME || ltime->day == 0); return null_value; } bool is_null() { diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d54cb54dec6..f689d96b4cf 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6701,9 +6701,9 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, else { if (thd->mark_used_columns == MARK_COLUMNS_READ) - it->walk(&Item::register_field_in_read_map, 1, (uchar *) 0); + it->walk(&Item::register_field_in_read_map, 0, (uchar *) 0); else - it->walk(&Item::register_field_in_write_map, 1, (uchar *) 0); + it->walk(&Item::register_field_in_write_map, 0, (uchar *) 0); } } else diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 3c3cb87e9e3..4af06eec658 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -702,7 +702,7 @@ public: void print(String *str, enum_query_type query_type); bool add_fake_select_lex(THD *thd); - void init_prepare_fake_select_lex(THD *thd); + void init_prepare_fake_select_lex(THD *thd, bool first_execution); inline bool is_prepared() { return prepared; } bool change_result(select_result_interceptor *result, select_result_interceptor *old_result); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0f570a491fc..cd475b28783 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10813,17 +10813,18 @@ void JOIN::cleanup(bool full) tabs_kind= WALK_EXECUTION_TABS; if (table_count) { - for (tab= first_breadth_first_tab(this, tabs_kind); tab; + for (tab= first_breadth_first_tab(this, tabs_kind); tab; tab= next_breadth_first_tab(this, tabs_kind, tab)) { tab->cleanup(); } } cleaned= true; + } else { - for (tab= first_linear_tab(this, WITH_CONST_TABLES); tab; + for (tab= first_linear_tab(this, WITH_CONST_TABLES); tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS)) { if (tab->table) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 22b5e5727e8..72f1df2f4ae 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -193,13 +193,15 @@ void select_union::cleanup() SYNOPSIS st_select_lex_unit::init_prepare_fake_select_lex() thd - thread handler + first_execution - TRUE at the first execution of the union RETURN options of SELECT */ void -st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg) +st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg, + bool first_execution) { thd_arg->lex->current_select= fake_select_lex; fake_select_lex->table_list.link_in_list(&result_table_list, @@ -207,7 +209,13 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg) fake_select_lex->context.table_list= fake_select_lex->context.first_name_resolution_table= fake_select_lex->get_table_list(); - if (!fake_select_lex->first_execution) + /* + The flag fake_select_lex->first_execution indicates whether this is + called at the first execution of the statement, while first_execution + shows whether this is called at the first execution of the union that + may form just a subselect. + */ + if (!fake_select_lex->first_execution && first_execution) { for (ORDER *order= global_parameters->order_list.first; order; @@ -481,7 +489,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, { /* Validate the global parameters of this union */ - init_prepare_fake_select_lex(thd); + init_prepare_fake_select_lex(thd, TRUE); /* Should be done only once (the only item_list per statement) */ DBUG_ASSERT(fake_select_lex->join == 0); if (!(fake_select_lex->join= new JOIN(thd, item_list, thd->variables.option_bits, @@ -622,6 +630,7 @@ bool st_select_lex_unit::exec() SELECT_LEX *select_cursor=first_select(); ulonglong add_rows=0; ha_rows examined_rows= 0; + bool first_execution= !executed; DBUG_ENTER("st_select_lex_unit::exec"); if (executed && !uncacheable && !describe) @@ -638,6 +647,7 @@ bool st_select_lex_unit::exec() { ha_rows records_at_start= 0; thd->lex->current_select= sl; + fake_select_lex->uncacheable|= sl->uncacheable; { set_limit(sl); @@ -742,7 +752,7 @@ bool st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { set_limit(global_parameters); - init_prepare_fake_select_lex(thd); + init_prepare_fake_select_lex(thd, first_execution); JOIN *join= fake_select_lex->join; if (!join) { diff --git a/sql/table.cc b/sql/table.cc index 15fbe867c15..c949112e7ee 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5022,10 +5022,8 @@ TABLE *TABLE_LIST::get_real_join_table() */ 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) + return NULL; // view/derived with no tables if (!tbl->nested_join) break; /* go deeper if we've found nested join */ |