Commit 9dba5a70 authored by ram@gw.mysql.r18.ru's avatar ram@gw.mysql.r18.ru

Fix for the bug #2198: SELECT INTO OUTFILE (with Sub-Select) Problem.

Proper Item_cache::setup() method.
Code cleanup.
(discussed with sanja)
parent 73a36f19
...@@ -1867,7 +1867,6 @@ void Item_cache_int::store(Item *item) ...@@ -1867,7 +1867,6 @@ void Item_cache_int::store(Item *item)
{ {
value= item->val_int_result(); value= item->val_int_result();
null_value= item->null_value; null_value= item->null_value;
collation.set(item->collation);
} }
...@@ -1875,7 +1874,6 @@ void Item_cache_real::store(Item *item) ...@@ -1875,7 +1874,6 @@ void Item_cache_real::store(Item *item)
{ {
value= item->val_result(); value= item->val_result();
null_value= item->null_value; null_value= item->null_value;
collation.set(item->collation);
} }
...@@ -1898,7 +1896,6 @@ void Item_cache_str::store(Item *item) ...@@ -1898,7 +1896,6 @@ void Item_cache_str::store(Item *item)
value_buff.copy(*value); value_buff.copy(*value);
value= &value_buff; value= &value_buff;
} }
collation.set(item->collation);
} }
......
...@@ -878,13 +878,15 @@ class Item_cache: public Item ...@@ -878,13 +878,15 @@ class Item_cache: public Item
void set_used_tables(table_map map) { used_table_map= map; } void set_used_tables(table_map map) { used_table_map= map; }
virtual bool allocate(uint i) { return 0; }; virtual bool allocate(uint i) { return 0; };
virtual bool setup(Item *item) { example= item; return 0; }; virtual bool setup(Item *item)
virtual void store(Item *)= 0;
void set_len_n_dec(uint32 max_len, uint8 dec)
{ {
max_length= max_len; example= item;
decimals= dec; max_length= item->max_length;
} decimals= item->decimals;
collation.set(item->collation);
return 0;
};
virtual void store(Item *)= 0;
enum Type type() const { return CACHE_ITEM; } enum Type type() const { return CACHE_ITEM; }
static Item_cache* get_cache(Item_result type); static Item_cache* get_cache(Item_result type);
table_map used_tables() const { return used_table_map; } table_map used_tables() const { return used_table_map; }
......
...@@ -301,8 +301,6 @@ void Item_singlerow_subselect::fix_length_and_dec() ...@@ -301,8 +301,6 @@ void Item_singlerow_subselect::fix_length_and_dec()
if ((max_columns= engine->cols()) == 1) if ((max_columns= engine->cols()) == 1)
{ {
engine->fix_length_and_dec(row= &value); engine->fix_length_and_dec(row= &value);
if (!(value= Item_cache::get_cache(engine->type())))
return;
} }
else else
{ {
...@@ -955,13 +953,9 @@ static Item_result set_row(List<Item> &item_list, Item *item, ...@@ -955,13 +953,9 @@ static Item_result set_row(List<Item> &item_list, Item *item,
res_type= sel_item->result_type(); res_type= sel_item->result_type();
item->decimals= sel_item->decimals; item->decimals= sel_item->decimals;
*maybe_null= sel_item->maybe_null; *maybe_null= sel_item->maybe_null;
if (row)
{
if (!(row[i]= Item_cache::get_cache(res_type))) if (!(row[i]= Item_cache::get_cache(res_type)))
return STRING_RESULT; // we should return something return STRING_RESULT; // we should return something
row[i]->set_len_n_dec(sel_item->max_length, sel_item->decimals); row[i]->setup(sel_item);
row[i]->collation.set(sel_item->collation);
}
} }
if (item_list.elements > 1) if (item_list.elements > 1)
res_type= ROW_RESULT; res_type= ROW_RESULT;
...@@ -982,7 +976,10 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row) ...@@ -982,7 +976,10 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row)
DBUG_ASSERT(row || unit->first_select()->item_list.elements==1); DBUG_ASSERT(row || unit->first_select()->item_list.elements==1);
if (unit->first_select()->item_list.elements == 1) if (unit->first_select()->item_list.elements == 1)
{
res_type= set_row(unit->types, item, row, &maybe_null); res_type= set_row(unit->types, item, row, &maybe_null);
item->collation.set(row[0]->collation);
}
else else
{ {
bool fake= 0; bool fake= 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment