From 31f34b20f3295db7e99877dcfe61b5798a6cfe95 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 14 May 2020 11:41:27 +0400 Subject: MDEV-22502 MDB crashes in CREATE TABLE AS SELECT when the precision of returning type = 0. TRUNCATE(decimal_5_5) erroneously tried to create a DECIMAL(0,0) column. Creating a DECIMAL(1,0) column instead. --- sql/item_func.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/item_func.cc') diff --git a/sql/item_func.cc b/sql/item_func.cc index f76f6515365..c41d7809bf9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2523,6 +2523,8 @@ void Item_func_round::fix_length_and_dec() precision-= decimals_delta - length_increase; decimals= MY_MIN(decimals_to_set, DECIMAL_MAX_SCALE); + if (!precision) + precision= 1; // DECIMAL(0,0) -> DECIMAL(1,0) max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, unsigned_flag); -- cgit v1.2.1