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 @@ -1015,6 +1015,24 @@ SELECT -9223372036854775808 MOD -9223372036854775808;
1015
1015
-9223372036854775808 MOD -9223372036854775808
1016
1016
0
1017
1017
#
1018
+ # MDEV-22502 MDB crashes in CREATE TABLE AS SELECT when the precision of returning type = 0
1019
+ #
1020
+ CREATE TABLE t1 (d decimal(5,5));
1021
+ INSERT INTO t1 VALUES (0.55555);
1022
+ SELECT TRUNCATE(d,0) FROM t1;
1023
+ TRUNCATE(d,0)
1024
+ 0
1025
+ CREATE TABLE t2 AS SELECT TRUNCATE(d,0) FROM t1;
1026
+ SELECT * FROM t2;
1027
+ TRUNCATE(d,0)
1028
+ 0
1029
+ SHOW CREATE TABLE t2;
1030
+ Table Create Table
1031
+ t2 CREATE TABLE `t2` (
1032
+ `TRUNCATE(d,0)` decimal(1,0) DEFAULT NULL
1033
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1
1034
+ DROP TABLE t1, t2;
1035
+ #
1018
1036
# MDEV-22503 MDB limits DECIMAL column precision to 16 doing CTAS with floor/ceil over DECIMAL(X,Y) where X > 16
1019
1037
#
1020
1038
CREATE TABLE t44 (d1 decimal(38,0) DEFAULT NULL);
Original file line number Diff line number Diff line change @@ -715,6 +715,18 @@ SELECT 9223372036854775808 MOD -9223372036854775808;
715
715
SELECT -9223372036854775808 MOD 9223372036854775808;
716
716
SELECT -9223372036854775808 MOD -9223372036854775808;
717
717
718
+ --echo #
719
+ --echo # MDEV-22502 MDB crashes in CREATE TABLE AS SELECT when the precision of returning type = 0
720
+ --echo #
721
+
722
+ CREATE TABLE t1 (d decimal(5,5));
723
+ INSERT INTO t1 VALUES (0.55555);
724
+ SELECT TRUNCATE(d,0) FROM t1;
725
+ CREATE TABLE t2 AS SELECT TRUNCATE(d,0) FROM t1;
726
+ SELECT * FROM t2;
727
+ SHOW CREATE TABLE t2;
728
+ DROP TABLE t1, t2;
729
+
718
730
719
731
--echo #
720
732
--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 @@ -2433,6 +2433,8 @@ void Item_func_round::fix_length_and_dec_decimal(uint decimals_to_set)
2433
2433
set_handler (&type_handler_newdecimal);
2434
2434
unsigned_flag= args[0 ]->unsigned_flag ;
2435
2435
decimals= decimals_to_set;
2436
+ if (!precision)
2437
+ precision= 1 ; // DECIMAL(0,0) -> DECIMAL(1,0)
2436
2438
max_length= my_decimal_precision_to_length_no_truncation (precision,
2437
2439
decimals,
2438
2440
unsigned_flag);
You can’t perform that action at this time.
0 commit comments