File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -994,6 +994,24 @@ SELECT -9223372036854775808 MOD -9223372036854775808;
994994-9223372036854775808 MOD -9223372036854775808
9959950
996996#
997+ # MDEV-22502 MDB crashes in CREATE TABLE AS SELECT when the precision of returning type = 0
998+ #
999+ CREATE TABLE t1 (d decimal(5,5));
1000+ INSERT INTO t1 VALUES (0.55555);
1001+ SELECT TRUNCATE(d,0) FROM t1;
1002+ TRUNCATE(d,0)
1003+ 0
1004+ CREATE TABLE t2 AS SELECT TRUNCATE(d,0) FROM t1;
1005+ SELECT * FROM t2;
1006+ TRUNCATE(d,0)
1007+ 0
1008+ SHOW CREATE TABLE t2;
1009+ Table Create Table
1010+ t2 CREATE TABLE `t2` (
1011+ `TRUNCATE(d,0)` decimal(1,0) DEFAULT NULL
1012+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1
1013+ DROP TABLE t1, t2;
1014+ #
9971015# MDEV-22503 MDB limits DECIMAL column precision to 16 doing CTAS with floor/ceil over DECIMAL(X,Y) where X > 16
9981016#
9991017CREATE TABLE t44 (d1 decimal(38,0) DEFAULT NULL);
Original file line number Diff line number Diff line change @@ -719,6 +719,18 @@ SELECT 9223372036854775808 MOD -9223372036854775808;
719719SELECT -9223372036854775808 MOD 9223372036854775808;
720720SELECT -9223372036854775808 MOD -9223372036854775808;
721721
722+ --echo #
723+ --echo # MDEV-22502 MDB crashes in CREATE TABLE AS SELECT when the precision of returning type = 0
724+ --echo #
725+
726+ CREATE TABLE t1 (d decimal(5,5));
727+ INSERT INTO t1 VALUES (0.55555);
728+ SELECT TRUNCATE(d,0) FROM t1;
729+ CREATE TABLE t2 AS SELECT TRUNCATE(d,0) FROM t1;
730+ SELECT * FROM t2;
731+ SHOW CREATE TABLE t2;
732+ DROP TABLE t1, t2;
733+
722734
723735--echo #
724736--echo # MDEV-22503 MDB limits DECIMAL column precision to 16 doing CTAS with floor/ceil over DECIMAL(X,Y) where X > 16
Original file line number Diff line number Diff line change @@ -2523,6 +2523,8 @@ void Item_func_round::fix_length_and_dec()
25232523
25242524 precision-= decimals_delta - length_increase;
25252525 decimals= MY_MIN (decimals_to_set, DECIMAL_MAX_SCALE);
2526+ if (!precision)
2527+ precision= 1 ; // DECIMAL(0,0) -> DECIMAL(1,0)
25262528 max_length= my_decimal_precision_to_length_no_truncation (precision,
25272529 decimals,
25282530 unsigned_flag);
You can’t perform that action at this time.
0 commit comments