Commit 3e897bc3 authored by unknown's avatar unknown

Fix for bug #666 (Nice number, yeah?)


sql/item_strfunc.cc:
  Item_func_elt::valXXX() functions don't expect NULL argument if it is 
  not the first one.
parent 332334e8
...@@ -1539,37 +1539,46 @@ void Item_func_elt::update_used_tables() ...@@ -1539,37 +1539,46 @@ void Item_func_elt::update_used_tables()
double Item_func_elt::val() double Item_func_elt::val()
{ {
uint tmp; uint tmp;
if ((tmp=(uint) item->val_int()) == 0 || tmp > arg_count)
{
null_value=1; null_value=1;
if ((tmp=(uint) item->val_int()) == 0 || tmp > arg_count)
return 0.0; return 0.0;
}
double result= args[tmp-1]->val();
if (args[tmp-1]->is_null())
return 0.0;
null_value=0; null_value=0;
return args[tmp-1]->val(); return result;
} }
longlong Item_func_elt::val_int() longlong Item_func_elt::val_int()
{ {
uint tmp; uint tmp;
if ((tmp=(uint) item->val_int()) == 0 || tmp > arg_count)
{
null_value=1; null_value=1;
if ((tmp=(uint) item->val_int()) == 0 || tmp > arg_count)
return 0; return 0;
}
int result= args[tmp-1]->val_int();
if (args[tmp-1]->is_null())
return 0;
null_value=0; null_value=0;
return args[tmp-1]->val_int(); return result;
} }
String *Item_func_elt::val_str(String *str) String *Item_func_elt::val_str(String *str)
{ {
uint tmp; uint tmp;
if ((tmp=(uint) item->val_int()) == 0 || tmp > arg_count)
{
null_value=1; null_value=1;
if ((tmp=(uint) item->val_int()) == 0 || tmp > arg_count)
return NULL; return NULL;
}
String *result= args[tmp-1]->val_str(str);
if (args[tmp-1]->is_null())
return NULL;
null_value=0; null_value=0;
return args[tmp-1]->val_str(str); return result;
} }
......
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