Commit 5f980d93 authored by unknown's avatar unknown

Made Item_splocal printable.


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