diff options
-rw-r--r-- | mysql-test/r/ps_2myisam.result | 4 | ||||
-rw-r--r-- | mysql-test/r/ps_3innodb.result | 4 | ||||
-rw-r--r-- | mysql-test/r/ps_4heap.result | 4 | ||||
-rw-r--r-- | mysql-test/r/ps_5merge.result | 8 | ||||
-rw-r--r-- | mysql-test/r/type_datetime_hires.result | 12 | ||||
-rw-r--r-- | mysql-test/suite/maria/r/ps_maria.result | 4 | ||||
-rw-r--r-- | mysql-test/t/type_datetime_hires.test | 9 | ||||
-rw-r--r-- | sql/item_timefunc.h | 1 |
8 files changed, 34 insertions, 12 deletions
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 2a9d08a70f4..cce5d6e9e2f 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1793,7 +1793,7 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) NOT NULL DEFAULT '0.000000', + `const10` decimal(22,6) DEFAULT NULL, `param10` decimal(65,30) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, @@ -1823,7 +1823,7 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 N 1 6 63 +def test t5 t5 const10 const10 246 24 16 Y 0 6 63 def test t5 t5 param10 param10 246 67 40 Y 0 30 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 6b7434390af..328df9e5978 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1776,7 +1776,7 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) NOT NULL DEFAULT '0.000000', + `const10` decimal(22,6) DEFAULT NULL, `param10` decimal(65,30) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, @@ -1806,7 +1806,7 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 N 1 6 63 +def test t5 t5 const10 const10 246 24 16 Y 0 6 63 def test t5 t5 param10 param10 246 67 40 Y 0 30 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 58acc19124a..cc4330c57e4 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1777,7 +1777,7 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) NOT NULL DEFAULT '0.000000', + `const10` decimal(22,6) DEFAULT NULL, `param10` decimal(65,30) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, @@ -1807,7 +1807,7 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 N 1 6 63 +def test t5 t5 const10 const10 246 24 16 Y 0 6 63 def test t5 t5 param10 param10 246 67 40 Y 0 30 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 654e641deeb..fe1665fc24e 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1713,7 +1713,7 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) NOT NULL DEFAULT '0.000000', + `const10` decimal(22,6) DEFAULT NULL, `param10` decimal(65,30) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, @@ -1743,7 +1743,7 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 N 1 6 63 +def test t5 t5 const10 const10 246 24 16 Y 0 6 63 def test t5 t5 param10 param10 246 67 40 Y 0 30 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 @@ -5067,7 +5067,7 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) NOT NULL DEFAULT '0.000000', + `const10` decimal(22,6) DEFAULT NULL, `param10` decimal(65,30) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, @@ -5097,7 +5097,7 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 N 1 6 63 +def test t5 t5 const10 const10 246 24 16 Y 0 6 63 def test t5 t5 param10 param10 246 67 40 Y 0 30 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 diff --git a/mysql-test/r/type_datetime_hires.result b/mysql-test/r/type_datetime_hires.result index 583030bf0da..5da6d31acc6 100644 --- a/mysql-test/r/type_datetime_hires.result +++ b/mysql-test/r/type_datetime_hires.result @@ -338,3 +338,15 @@ select * from t1; a b 2010-01-02 03:04:05.000000 2010-01-02 03:04:05 drop table t1; +# +# MDEV-4651 Crash in my_decimal2decimal in a ORDER BY query +# +SET @@time_zone='+00:00'; +CREATE TABLE t1 (a DATETIME(4) NOT NULL); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'),('2000-00-00 00:00:00'); +SELECT UNIX_TIMESTAMP(a) FROM t1 ORDER BY 1; +UNIX_TIMESTAMP(a) +NULL +978307200.0000 +DROP TABLE t1; +SET @@time_zone=DEFAULT; diff --git a/mysql-test/suite/maria/r/ps_maria.result b/mysql-test/suite/maria/r/ps_maria.result index 8ac0fee6f50..3546e78512c 100644 --- a/mysql-test/suite/maria/r/ps_maria.result +++ b/mysql-test/suite/maria/r/ps_maria.result @@ -1793,7 +1793,7 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) NOT NULL DEFAULT '0.000000', + `const10` decimal(22,6) DEFAULT NULL, `param10` decimal(65,30) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, @@ -1823,7 +1823,7 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 N 1 6 63 +def test t5 t5 const10 const10 246 24 16 Y 0 6 63 def test t5 t5 param10 param10 246 67 40 Y 0 30 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 diff --git a/mysql-test/t/type_datetime_hires.test b/mysql-test/t/type_datetime_hires.test index 74f686d4157..a62c227f563 100644 --- a/mysql-test/t/type_datetime_hires.test +++ b/mysql-test/t/type_datetime_hires.test @@ -69,3 +69,12 @@ alter table t1 modify b datetime, modify a datetime(6); select * from t1; drop table t1; +--echo # +--echo # MDEV-4651 Crash in my_decimal2decimal in a ORDER BY query +--echo # +SET @@time_zone='+00:00'; +CREATE TABLE t1 (a DATETIME(4) NOT NULL); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'),('2000-00-00 00:00:00'); +SELECT UNIX_TIMESTAMP(a) FROM t1 ORDER BY 1; +DROP TABLE t1; +SET @@time_zone=DEFAULT; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 25a160d91f6..b17e1c794ee 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -370,6 +370,7 @@ public: decimals= args[0]->decimals; set_if_smaller(decimals, TIME_SECOND_PART_DIGITS); max_length=17 + (decimals ? decimals + 1 : 0); + set_persist_maybe_null(1); } void find_num_type() { hybrid_type= decimals ? DECIMAL_RESULT : INT_RESULT; } double real_op() { DBUG_ASSERT(0); return 0; } |