Commit fee78df3 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-4651 Crash in my_decimal2decimal in a ORDER BY query

modified:
  mysql-test/r/ps_2myisam.result
  mysql-test/r/ps_3innodb.result
  mysql-test/r/ps_4heap.result
  mysql-test/r/ps_5merge.result
  mysql-test/r/type_datetime_hires.result
  mysql-test/suite/maria/r/ps_maria.result
  mysql-test/t/type_datetime_hires.test
  sql/item_timefunc.h
parent ad947563
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......@@ -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
......
......@@ -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;
......@@ -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; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment