summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2003-06-20 20:04:52 +0500
committerunknown <hf@deer.(none)>2003-06-20 20:04:52 +0500
commit3e17c752a721c694f50dbab832dadef0876feeaf (patch)
treeb1bc9a622105d7289e9f09bcf6a420c4e2982567 /sql/item_strfunc.cc
parent6c3a2a107ae223c70206119c34d8b20fa89c243b (diff)
downloadmariadb-git-3e17c752a721c694f50dbab832dadef0876feeaf.tar.gz
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.
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc33
1 files changed, 21 insertions, 12 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 208be1ecd7f..9d4f7641b1d 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1539,37 +1539,46 @@ void Item_func_elt::update_used_tables()
double Item_func_elt::val()
{
uint tmp;
+ null_value=1;
if ((tmp=(uint) item->val_int()) == 0 || tmp > arg_count)
- {
- null_value=1;
return 0.0;
- }
+
+ double result= args[tmp-1]->val();
+ if (args[tmp-1]->is_null())
+ return 0.0;
+
null_value=0;
- return args[tmp-1]->val();
+ return result;
}
longlong Item_func_elt::val_int()
{
uint tmp;
+ null_value=1;
if ((tmp=(uint) item->val_int()) == 0 || tmp > arg_count)
- {
- null_value=1;
return 0;
- }
+
+ int result= args[tmp-1]->val_int();
+ if (args[tmp-1]->is_null())
+ return 0;
+
null_value=0;
- return args[tmp-1]->val_int();
+ return result;
}
String *Item_func_elt::val_str(String *str)
{
uint tmp;
+ null_value=1;
if ((tmp=(uint) item->val_int()) == 0 || tmp > arg_count)
- {
- null_value=1;
return NULL;
- }
+
+ String *result= args[tmp-1]->val_str(str);
+ if (args[tmp-1]->is_null())
+ return NULL;
+
null_value=0;
- return args[tmp-1]->val_str(str);
+ return result;
}