summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-09-24 10:46:18 +0400
committerAlexander Barkov <bar@mariadb.com>2019-09-24 10:46:18 +0400
commit67b0faa29e59387b74ae8547c96cf0f31fc3d9d1 (patch)
treec5ba41a19cf75f79b452a5d0bfa3ff60a6964f6f /sql/item_func.cc
parentfd3ad41eed70e201dc6fef4d302d9e748e478358 (diff)
downloadmariadb-git-67b0faa29e59387b74ae8547c96cf0f31fc3d9d1.tar.gz
MDEV-20495 Assertion `precision > 0' failed in decimal_bin_size upon CREATE .. SELECT with zerofilled decimal
Also fixes: MDEV-20560 Assertion `precision > 0' failed in decimal_bin_size upon SELECT with MOD short unsigned decimal Changing the way how Item_func_mod calculates its max_length. It now uses decimal_precision(), decimal_scale() and unsigned_flag of its arguments, like all other Item_num_op descendants do.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index dad4b89b3bc..f079e5c83db 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2056,8 +2056,11 @@ my_decimal *Item_func_mod::decimal_op(my_decimal *decimal_value)
void Item_func_mod::result_precision()
{
+ unsigned_flag= args[0]->unsigned_flag;
decimals= max(args[0]->decimal_scale(), args[1]->decimal_scale());
- max_length= max(args[0]->max_length, args[1]->max_length);
+ uint prec= max(args[0]->decimal_precision(), args[1]->decimal_precision());
+ fix_char_length(my_decimal_precision_to_length_no_truncation(prec, decimals,
+ unsigned_flag));
}
@@ -2065,6 +2068,10 @@ void Item_func_mod::fix_length_and_dec()
{
Item_num_op::fix_length_and_dec();
maybe_null= 1;
+ /*
+ result_precision() sets unsigned_flag for INT_RESULT and DECIMAL_RESULT.
+ Here we need to set it in case of REAL_RESULT.
+ */
unsigned_flag= args[0]->unsigned_flag;
}