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)
{
value= item->val_int_result();
null_value= item->null_value;
collation.set(item->collation);
}
......@@ -1875,7 +1874,6 @@ void Item_cache_real::store(Item *item)
{
value= item->val_result();
null_value= item->null_value;
collation.set(item->collation);
}
......@@ -1898,7 +1896,6 @@ void Item_cache_str::store(Item *item)
value_buff.copy(*value);
value= &value_buff;
}
collation.set(item->collation);
}
......
......@@ -878,13 +878,15 @@ public:
void set_used_tables(table_map map) { used_table_map= map; }
virtual bool allocate(uint i) { return 0; };
virtual bool setup(Item *item) { example= item; return 0; };
virtual void store(Item *)= 0;
void set_len_n_dec(uint32 max_len, uint8 dec)
virtual bool setup(Item *item)
{
max_length= max_len;
decimals= dec;
}
example= item;
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; }
static Item_cache* get_cache(Item_result type);
table_map used_tables() const { return used_table_map; }
......
......@@ -301,8 +301,6 @@ void Item_singlerow_subselect::fix_length_and_dec()
if ((max_columns= engine->cols()) == 1)
{
engine->fix_length_and_dec(row= &value);
if (!(value= Item_cache::get_cache(engine->type())))
return;
}
else
{
......@@ -955,13 +953,9 @@ static Item_result set_row(List<Item> &item_list, Item *item,
res_type= sel_item->result_type();
item->decimals= sel_item->decimals;
*maybe_null= sel_item->maybe_null;
if (row)
{
if (!(row[i]= Item_cache::get_cache(res_type)))
return STRING_RESULT; // we should return something
row[i]->set_len_n_dec(sel_item->max_length, sel_item->decimals);
row[i]->collation.set(sel_item->collation);
}
row[i]->setup(sel_item);
}
if (item_list.elements > 1)
res_type= ROW_RESULT;
......@@ -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);
if (unit->first_select()->item_list.elements == 1)
{
res_type= set_row(unit->types, item, row, &maybe_null);
item->collation.set(row[0]->collation);
}
else
{
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