summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@deer.(none)>2006-11-17 18:27:28 +0400
committerunknown <holyfoot/hf@deer.(none)>2006-11-17 18:27:28 +0400
commitc8146c2f798845f36375ce843a36213e278e6969 (patch)
tree0ecd129af044571daccf4e04e8f69e21aeaa1830 /sql/item_subselect.cc
parent666ca5c9ea0a20da908e5df3f316dace686c20b1 (diff)
parent28c97d6a1e0f2a027d06841d6b09492d083e3731 (diff)
downloadmariadb-git-c8146c2f798845f36375ce843a36213e278e6969.tar.gz
Merge mysql.com:/home/hf/work/mysql-5.0-mrg
into mysql.com:/home/hf/work/mysql-5.1-mrg Makefile.am: Auto merged client/mysqltest.c: Auto merged include/mysql.h: Auto merged BitKeeper/deleted/.del-bdb-deadlock.test: Auto merged libmysql/libmysql.c: Auto merged libmysqld/lib_sql.cc: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/t/lock_multi.test: Auto merged mysql-test/t/rename.test: Auto merged mysql-test/t/show_check.test: Auto merged mysql-test/t/status.test: Auto merged mysql-test/t/subselect.test: Auto merged sql/item_subselect.cc: Auto merged sql/item_subselect.h: Auto merged sql/protocol.cc: Auto merged sql-common/client.c: Auto merged sql/protocol.h: Auto merged sql/sql_class.h: Auto merged mysql-test/include/deadlock.inc: SCCS merged mysql-test/t/disabled.def: merging sql/item.cc: merging
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc35
1 files changed, 26 insertions, 9 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 4e6c67cba60..e7419e1a7c6 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -434,6 +434,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)
@@ -710,6 +719,7 @@ double Item_in_subselect::val_real()
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
+ null_value= 0;
if (exec())
{
reset();
@@ -730,6 +740,7 @@ longlong Item_in_subselect::val_int()
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
+ null_value= 0;
if (exec())
{
reset();
@@ -750,6 +761,7 @@ String *Item_in_subselect::val_str(String *str)
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
+ null_value= 0;
if (exec())
{
reset();
@@ -1542,32 +1554,36 @@ int subselect_uniquesubquery_engine::prepare()
return 1;
}
-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;
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;
@@ -1579,13 +1595,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;
}
}