From 8f607aae127439e132dae00b2750727162f4d564 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 18 Mar 2013 08:44:24 +0100 Subject: MDEV-4283 Assertion `scale <= precision' fails in strings/decimal.c with decimals=NOT_FIXED_DEC it is possible to have 'decimals' larger than 'max_length', it's not an error for temporal functions. But when Item_func_numhybrid converts the value to DECIMAL_RESULT, it must limit 'decimals' to be a valid scale of a decimal number. --- sql/item_func.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sql/item_func.h') diff --git a/sql/item_func.h b/sql/item_func.h index 2db8ab76ffe..6cd036920f8 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -348,6 +348,13 @@ public: void fix_num_length_and_dec(); virtual void find_num_type()= 0; /* To be called from fix_length_and_dec */ + inline void fix_decimals() + { + DBUG_ASSERT(result_type() == DECIMAL_RESULT); + if (decimals == NOT_FIXED_DEC) + set_if_smaller(decimals, max_length - 1); + } + double val_real(); longlong val_int(); my_decimal *val_decimal(my_decimal *); -- cgit v1.2.1