Commit 86039a34 authored by pem@mysql.comhem.se's avatar pem@mysql.comhem.se

Made Item_splocal printable.

parent 5e46a059
......@@ -230,11 +230,12 @@ class Item_splocal : public Item
private:
uint m_offset;
LEX_STRING m_name;
public:
Item_splocal(uint offset)
: m_offset(offset)
Item_splocal(LEX_STRING name, uint offset)
: m_offset(offset), m_name(name)
{
Item::maybe_null= TRUE;
}
......@@ -305,6 +306,11 @@ public:
{
return this_item()->save_in_field(field, no_conversions);
}
inline void print(String *str)
{
str->append(m_name.str, m_name.length);
}
};
......
......@@ -70,22 +70,32 @@ sp_eval_func_item(THD *thd, Item *it, enum enum_field_types type)
{
longlong i= it->val_int();
DBUG_PRINT("info", ("INT_RESULT: %d", i));
if (it->null_value)
{
DBUG_PRINT("info", ("INT_RESULT: null"));
it= new Item_null();
}
else
{
DBUG_PRINT("info", ("INT_RESULT: %d", i));
it= new Item_int(it->val_int());
}
break;
}
case REAL_RESULT:
{
double d= it->val();
DBUG_PRINT("info", ("REAL_RESULT: %g", d));
if (it->null_value)
{
DBUG_PRINT("info", ("REAL_RESULT: null"));
it= new Item_null();
}
else
{
DBUG_PRINT("info", ("REAL_RESULT: %g", d));
it= new Item_real(it->val());
}
break;
}
default:
......@@ -94,12 +104,17 @@ sp_eval_func_item(THD *thd, Item *it, enum enum_field_types type)
String tmp(buffer, sizeof(buffer), it->collation.collation);
String *s= it->val_str(&tmp);
DBUG_PRINT("info",("default result: %*s",s->length(),s->c_ptr_quick()));
if (it->null_value)
{
DBUG_PRINT("info", ("default result: null"));
it= new Item_null();
}
else
{
DBUG_PRINT("info",("default result: %*s",s->length(),s->c_ptr_quick()));
it= new Item_string(thd->strmake(s->c_ptr_quick(), s->length()),
s->length(), it->collation.collation);
}
break;
}
}
......
......@@ -1205,7 +1205,7 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
{
my_var *mv= gl++;
if (mv->local)
(void)local_vars.push_back(new Item_splocal(mv->offset));
(void)local_vars.push_back(new Item_splocal(mv->s, mv->offset));
else
{
Item_func_set_user_var *xx = new Item_func_set_user_var(mv->s, item);
......
......@@ -1775,7 +1775,12 @@ sp_case:
i= new sp_instr_jump_if_not(ip, $1);
else
{ /* Simple case: <caseval> = <whenval> */
Item *var= (Item*) new Item_splocal(ctx->current_framesize()-1);
LEX_STRING ivar;
ivar.str= "_tmp_";
ivar.length= 5;
Item *var= (Item*) new Item_splocal(ivar,
ctx->current_framesize()-1);
Item *expr= new Item_func_eq(var, $1);
i= new sp_instr_jump_if_not(ip, expr);
......@@ -5507,7 +5512,7 @@ simple_ident:
YYABORT;
}
else
$$ = (Item*) new Item_splocal(spv->offset);
$$ = (Item*) new Item_splocal($1, spv->offset);
}
else
{
......
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