Skip to content

Commit f7cf609

Browse files
committed
Merge remote-tracking branch 'origin/10.2' into 10.3
2 parents ef65c39 + 4dc690d commit f7cf609

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

mysql-test/main/func_math.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,24 @@ SELECT -9223372036854775808 MOD -9223372036854775808;
10151015
-9223372036854775808 MOD -9223372036854775808
10161016
0
10171017
#
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+
#
10181036
# MDEV-22503 MDB limits DECIMAL column precision to 16 doing CTAS with floor/ceil over DECIMAL(X,Y) where X > 16
10191037
#
10201038
CREATE TABLE t44 (d1 decimal(38,0) DEFAULT NULL);

mysql-test/main/func_math.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,18 @@ SELECT 9223372036854775808 MOD -9223372036854775808;
715715
SELECT -9223372036854775808 MOD 9223372036854775808;
716716
SELECT -9223372036854775808 MOD -9223372036854775808;
717717

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+
718730

719731
--echo #
720732
--echo # MDEV-22503 MDB limits DECIMAL column precision to 16 doing CTAS with floor/ceil over DECIMAL(X,Y) where X > 16

sql/item_func.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,6 +2433,8 @@ void Item_func_round::fix_length_and_dec_decimal(uint decimals_to_set)
24332433
set_handler(&type_handler_newdecimal);
24342434
unsigned_flag= args[0]->unsigned_flag;
24352435
decimals= decimals_to_set;
2436+
if (!precision)
2437+
precision= 1; // DECIMAL(0,0) -> DECIMAL(1,0)
24362438
max_length= my_decimal_precision_to_length_no_truncation(precision,
24372439
decimals,
24382440
unsigned_flag);

0 commit comments

Comments
 (0)