diff options
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index ee2367a87b0..7c235a450e3 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2730,6 +2730,36 @@ my_decimal *Item_func_min_max::val_decimal_native(my_decimal *dec) } +bool Item_func_min_max::val_native(THD *thd, Native *native) +{ + DBUG_ASSERT(fixed == 1); + const Type_handler *handler= Item_hybrid_func::type_handler(); + /* + For now we don't use val_native() with traditional data types other + than TIMESTAMP. If we ever start to use, we'll possibly need new methods: + Type_handler::Item_func_min_max_val_native() + Item::val_native_from_{int|decimal|real|str|date}() + It may happen to be cheaper to do the operation in e.g. INT format and then + convert INT to native (instead of doing the operation in native format). + */ + NativeBuffer<STRING_BUFFER_USUAL_SIZE> cur; + for (uint i= 0; i < arg_count; i++) + { + if (val_native_with_conversion_from_item(thd, args[i], + i == 0 ? native : &cur, + handler)) + return true; + if (i > 0) + { + int cmp= handler->cmp_native(*native, cur); + if ((cmp_sign < 0 ? cmp : -cmp) < 0 && native->copy(cur)) + return null_value= true; + } + } + return null_value= false; +} + + longlong Item_func_bit_length::val_int() { DBUG_ASSERT(fixed == 1); @@ -6453,6 +6483,14 @@ String *Item_func_last_value::val_str(String *str) return tmp; } + +bool Item_func_last_value::val_native(THD *thd, Native *to) +{ + evaluate_sideeffects(); + return val_native_from_item(thd, last_value, to); +} + + longlong Item_func_last_value::val_int() { longlong tmp; |