diff options
author | Michael Widenius <monty@askmonty.org> | 2012-09-01 00:54:54 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2012-09-01 00:54:54 +0300 |
commit | 1999be8d4e9d721243c51b04c76ba11ad1e9fa56 (patch) | |
tree | cd287f49c709f844d10d774643feb5843acf99a6 /sql/item_subselect.cc | |
parent | 5a86a61219826aadf8d08cbc447fe438f2bf50c3 (diff) | |
parent | b45c551ee32d0d5260f4958abf93efab1a4614a2 (diff) | |
download | mariadb-git-1999be8d4e9d721243c51b04c76ba11ad1e9fa56.tar.gz |
Automatic merge with 5.5
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index c7a3ca445d6..c10b75c154b 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -287,7 +287,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref) else goto end; - if ((uncacheable= engine->uncacheable())) + if ((uncacheable= engine->uncacheable() & ~UNCACHEABLE_EXPLAIN)) { const_item_cache= 0; if (uncacheable & UNCACHEABLE_RAND) @@ -819,7 +819,9 @@ table_map Item_subselect::used_tables() const bool Item_subselect::const_item() const { - return thd->lex->context_analysis_only ? FALSE : const_item_cache; + return (thd->lex->context_analysis_only ? + FALSE : + forced_const || const_item_cache); } Item *Item_subselect::get_tmp_table_item(THD *thd_arg) @@ -1272,7 +1274,7 @@ bool Item_singlerow_subselect::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) else { reset(); - return 0; + return 1; } } @@ -1538,6 +1540,10 @@ double Item_in_subselect::val_real() */ DBUG_ASSERT(0); DBUG_ASSERT(fixed == 1); + if (forced_const) + return value; + DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) || + ! engine->is_executed()); null_value= was_null= FALSE; if (exec()) { @@ -1558,6 +1564,10 @@ longlong Item_in_subselect::val_int() */ DBUG_ASSERT(0); DBUG_ASSERT(fixed == 1); + if (forced_const) + return value; + DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) || + ! engine->is_executed()); null_value= was_null= FALSE; if (exec()) { @@ -1578,6 +1588,10 @@ String *Item_in_subselect::val_str(String *str) */ DBUG_ASSERT(0); DBUG_ASSERT(fixed == 1); + if (forced_const) + goto value_is_ready; + DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) || + ! engine->is_executed()); null_value= was_null= FALSE; if (exec()) { @@ -1589,6 +1603,7 @@ String *Item_in_subselect::val_str(String *str) null_value= TRUE; return 0; } +value_is_ready: str->set((ulonglong)value, &my_charset_bin); return str; } @@ -1599,6 +1614,8 @@ bool Item_in_subselect::val_bool() DBUG_ASSERT(fixed == 1); if (forced_const) return value; + DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) || + ! engine->is_executed()); null_value= was_null= FALSE; if (exec()) { @@ -1617,6 +1634,10 @@ my_decimal *Item_in_subselect::val_decimal(my_decimal *decimal_value) method should not be used */ DBUG_ASSERT(0); + if (forced_const) + goto value_is_ready; + DBUG_ASSERT((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN) || + ! engine->is_executed()); null_value= was_null= FALSE; DBUG_ASSERT(fixed == 1); if (exec()) @@ -1626,6 +1647,7 @@ my_decimal *Item_in_subselect::val_decimal(my_decimal *decimal_value) } if (was_null && !value) null_value= TRUE; +value_is_ready: int2my_decimal(E_DEC_FATAL_ERROR, value, 0, decimal_value); return decimal_value; } @@ -3176,6 +3198,8 @@ int subselect_single_select_engine::exec() tab->read_record.read_record= tab->save_read_record; } executed= 1; + if (!(uncacheable() & ~UNCACHEABLE_EXPLAIN)) + item->make_const(); thd->where= save_where; thd->lex->current_select= save_select; DBUG_RETURN(join->error || thd->is_fatal_error || thd->is_error()); @@ -5168,10 +5192,20 @@ Ordered_key::cmp_keys_by_row_data(ha_rows a, ha_rows b) rowid_a= row_num_to_rowid + a * rowid_length; rowid_b= row_num_to_rowid + b * rowid_length; /* Fetch the rows for comparison. */ - error= tbl->file->ha_rnd_pos(tbl->record[0], rowid_a); - DBUG_ASSERT(!error); - error= tbl->file->ha_rnd_pos(tbl->record[1], rowid_b); - DBUG_ASSERT(!error); + if ((error= tbl->file->ha_rnd_pos(tbl->record[0], rowid_a))) + { + /* purecov: begin inspected */ + tbl->file->print_error(error, MYF(ME_FATALERROR)); // Sets fatal_error + return 0; + /* purecov: end */ + } + if ((error= tbl->file->ha_rnd_pos(tbl->record[1], rowid_b))) + { + /* purecov: begin inspected */ + tbl->file->print_error(error, MYF(ME_FATALERROR)); // Sets fatal_error + return 0; + /* purecov: end */ + } /* Compare the two rows by the corresponding values of the indexed columns. @@ -5247,8 +5281,13 @@ int Ordered_key::cmp_key_with_search_key(rownum_t row_num) int __attribute__((unused)) error; int cmp_res; - error= tbl->file->ha_rnd_pos(tbl->record[0], cur_rowid); - DBUG_ASSERT(!error); + if ((error= tbl->file->ha_rnd_pos(tbl->record[0], cur_rowid))) + { + /* purecov: begin inspected */ + tbl->file->print_error(error, MYF(ME_FATALERROR)); // Sets fatal_error + return 0; + /* purecov: end */ + } for (uint i= 0; i < key_column_count; i++) { |