diff options
author | unknown <gkodinov/kgeorge@macbook.gmz> | 2006-11-07 18:44:37 +0200 |
---|---|---|
committer | unknown <gkodinov/kgeorge@macbook.gmz> | 2006-11-07 18:44:37 +0200 |
commit | 5ad3ed8c190fbd36043bc9b5299439dca66dc764 (patch) | |
tree | 1d89504499c7786fd26b7b8f0881bc789d9996ed /sql/item_subselect.cc | |
parent | c0487fb97057727c9587cc05150df64f118c2d31 (diff) | |
parent | 5af4fd256321748a5ac7c8d4407f8ce977345e04 (diff) | |
download | mariadb-git-5ad3ed8c190fbd36043bc9b5299439dca66dc764.tar.gz |
Merge macbook.gmz:/Users/kgeorge/mysql/work/B11032-4.1-opt
into macbook.gmz:/Users/kgeorge/mysql/work/B11032-5.0-opt
mysql-test/r/subselect.result:
merge fixes
mysql-test/t/subselect.test:
merge fixes
sql/item_subselect.cc:
merge fixes
sql/item_subselect.h:
merge fixes
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 432a8882f5f..551795acd53 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -391,6 +391,15 @@ enum Item_result Item_singlerow_subselect::result_type() const return engine->type(); } +/* + Don't rely on the result type to calculate field type. + Ask the engine instead. +*/ +enum_field_types Item_singlerow_subselect::field_type() const +{ + return engine->field_type(); +} + void Item_singlerow_subselect::fix_length_and_dec() { if ((max_columns= engine->cols()) == 1) @@ -1613,32 +1622,36 @@ bool subselect_single_select_engine::no_rows() } -static Item_result set_row(List<Item> &item_list, Item *item, - Item_cache **row, bool *maybe_null) +/* + makes storage for the output values for the subquery and calcuates + their data and column types and their nullability. +*/ +void subselect_engine::set_row(List<Item> &item_list, Item_cache **row) { - Item_result res_type= STRING_RESULT; Item *sel_item; List_iterator_fast<Item> li(item_list); + res_type= STRING_RESULT; + res_field_type= FIELD_TYPE_VAR_STRING; for (uint i= 0; (sel_item= li++); i++) { item->max_length= sel_item->max_length; res_type= sel_item->result_type(); + res_field_type= sel_item->field_type(); item->decimals= sel_item->decimals; item->unsigned_flag= sel_item->unsigned_flag; - *maybe_null= sel_item->maybe_null; + maybe_null= sel_item->maybe_null; if (!(row[i]= Item_cache::get_cache(res_type))) - return STRING_RESULT; // we should return something + return; row[i]->setup(sel_item); } if (item_list.elements > 1) res_type= ROW_RESULT; - return res_type; } void subselect_single_select_engine::fix_length_and_dec(Item_cache **row) { DBUG_ASSERT(row || select_lex->item_list.elements==1); - res_type= set_row(select_lex->item_list, item, row, &maybe_null); + set_row(select_lex->item_list, row); item->collation.set(row[0]->collation); if (cols() != 1) maybe_null= 0; @@ -1650,13 +1663,14 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row) if (unit->first_select()->item_list.elements == 1) { - res_type= set_row(unit->types, item, row, &maybe_null); + set_row(unit->types, row); item->collation.set(row[0]->collation); } else { - bool fake= 0; - res_type= set_row(unit->types, item, row, &fake); + bool maybe_null_saved= maybe_null; + set_row(unit->types, row); + maybe_null= maybe_null_saved; } } |