summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc24
1 files changed, 23 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index f0ed8110b79..c4eb6cdc2aa 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2289,7 +2289,7 @@ void Item_func_min_max::fix_length_and_dec()
stored to the value pointer, if latter is provided.
RETURN
- 0 If one of arguments is NULL
+ 0 If one of arguments is NULL or there was a execution error
# index of the least/greatest argument
*/
@@ -2303,6 +2303,14 @@ uint Item_func_min_max::cmp_datetimes(ulonglong *value)
Item **arg= args + i;
bool is_null;
longlong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null);
+
+ /* Check if we need to stop (because of error or KILL) and stop the loop */
+ if (thd->is_error())
+ {
+ null_value= 1;
+ return 0;
+ }
+
if ((null_value= args[i]->null_value))
return 0;
if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
@@ -2331,6 +2339,12 @@ String *Item_func_min_max::val_str(String *str)
if (null_value)
return 0;
str_res= args[min_max_idx]->val_str(str);
+ if (args[min_max_idx]->null_value)
+ {
+ // check if the call to val_str() above returns a NULL value
+ null_value= 1;
+ return NULL;
+ }
str_res->set_charset(collation.collation);
return str_res;
}
@@ -4331,6 +4345,14 @@ longlong Item_func_set_user_var::val_int_result()
return entry->val_int(&null_value);
}
+bool Item_func_set_user_var::val_bool_result()
+{
+ DBUG_ASSERT(fixed == 1);
+ check(TRUE);
+ update(); // Store expression
+ return entry->val_int(&null_value) != 0;
+}
+
String *Item_func_set_user_var::str_result(String *str)
{
DBUG_ASSERT(fixed == 1);