summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-07-31 10:42:44 +0400
committerAlexander Barkov <bar@mariadb.com>2020-07-31 17:45:39 +0400
commitdc513dff911d72eaaf9f752f390fef8d1ef9a4b0 (patch)
tree3af27646a38985babb5e2094aecf4e144060d4bd /sql/item_func.h
parenta773d932678a0b205f43d8a1aaa416d843d66bc8 (diff)
downloadmariadb-git-dc513dff911d72eaaf9f752f390fef8d1ef9a4b0.tar.gz
MDEV-23351 Rounding functions return wrong data types for DATE input
Fixing ROUND(date,0), TRUNCATE(date,x), FLOOR(date), CEILING(date) to return the `int(8) unsigned` data type. Details: 1. Cleanup: moving virtual implementations - Type_handler_temporal_result::Item_func_int_val_fix_length_and_dec() - Type_handler_temporal_result::Item_func_round_fix_length_and_dec() to Type_handler_date_common. Other temporal data type handlers override these methods anyway. So they were only DATE specific. This change makes the code clearer. 2. Backporting DTCollation_numeric from 10.5, to reuse the code easier. 3. Adding the `preferred_attrs` argument to Item_func_round::fix_arg_int(). Now Type_handler_xxx::Item_func_round_val_fix_length_and_dec() work as follows: - The INT-alike and YEAR handlers copy preferred_attrs from args[0]. - The DATE handler passes explicit attributes, to get `int(8) unsigned`. - The hex hybrid handler passes NULL, so fix_arg_int() calculates attributes. 4. Type_handler_date_common::Item_func_int_val_fix_length_and_dec() now sets the type handler and attributes to get `int(8) unsigned`.
Diffstat (limited to 'sql/item_func.h')
-rw-r--r--sql/item_func.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index 549e576dbd3..ecee1a1b83a 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1774,7 +1774,8 @@ public:
return NULL;
}
void fix_arg_decimal();
- void fix_arg_int(const Type_handler *preferred);
+ void fix_arg_int(const Type_handler *preferred,
+ const Type_std_attributes *preferred_attributes);
void fix_arg_double();
void fix_arg_time();
void fix_arg_datetime();