summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-05-18 17:30:02 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-05-18 17:30:02 +0300
commit23047d3ed42eacb5eaa5475a8fa4161550d01c52 (patch)
treee723067fea7cfb663ef7e4777e29ffd7dcd2905d /sql/item_func.cc
parentf86d97c3fee0127d83c009e448f419ac857c72c7 (diff)
parentfaf6d0ef3f9323c6d24f8cdb6533ed23d1a6bb40 (diff)
downloadmariadb-git-23047d3ed42eacb5eaa5475a8fa4161550d01c52.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 52eeaf10cd5..da185f9878b 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2184,6 +2184,12 @@ longlong Item_func_bit_neg::val_int()
void Item_func_int_val::fix_length_and_dec_int_or_decimal()
{
+ /*
+ The INT branch of this code should be revised.
+ It creates too large data types, e.g.
+ CREATE OR REPLACE TABLE t2 AS SELECT FLOOR(9999999.999) AS fa;
+ results in a BININT(10) column, while INT(7) should probably be enough.
+ */
ulonglong tmp_max_length= (ulonglong ) args[0]->max_length -
(args[0]->decimals ? args[0]->decimals + 1 : 0) + 2;
max_length= tmp_max_length > (ulonglong) UINT_MAX32 ?
@@ -2198,6 +2204,9 @@ void Item_func_int_val::fix_length_and_dec_int_or_decimal()
*/
if (args[0]->max_length - args[0]->decimals >= DECIMAL_LONGLONG_DIGITS - 2)
{
+ fix_char_length(
+ my_decimal_precision_to_length_no_truncation(
+ args[0]->decimal_int_part(), 0, false));
set_handler(&type_handler_newdecimal);
}
else
@@ -2314,6 +2323,8 @@ void Item_func_round::fix_length_and_dec_decimal(uint decimals_to_set)
set_handler(&type_handler_newdecimal);
unsigned_flag= args[0]->unsigned_flag;
decimals= decimals_to_set;
+ if (!precision)
+ precision= 1; // DECIMAL(0,0) -> DECIMAL(1,0)
max_length= my_decimal_precision_to_length_no_truncation(precision,
decimals,
unsigned_flag);