diff options
-rw-r--r-- | mysql-test/r/ctype_latin1.result | 2 | ||||
-rw-r--r-- | mysql-test/r/ctype_sjis.result | 2 | ||||
-rw-r--r-- | mysql-test/r/ctype_ucs.result | 2 | ||||
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 2 | ||||
-rw-r--r-- | mysql-test/r/date_formats.result | 122 | ||||
-rw-r--r-- | mysql-test/r/func_time.result | 68 | ||||
-rw-r--r-- | mysql-test/r/type_date.result | 2 | ||||
-rw-r--r-- | mysql-test/t/func_time.test | 46 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 2 | ||||
-rw-r--r-- | sql/item_timefunc.h | 2 | ||||
-rw-r--r-- | storage/tokudb/mysql-test/tokudb/r/type_date.result | 2 |
11 files changed, 183 insertions, 69 deletions
diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index b1507a3222b..b29e66b0a3f 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -370,7 +370,7 @@ pattern varchar(64) NO INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d'); SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1; HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern) -32303031F73031F73031 2559F7256DF72564 2001-01-01 00:00:00 +32303031F73031F73031 2559F7256DF72564 2001-01-01 00:00:00.000000 DROP TABLE t1; SET collation_connection='latin1_bin'; create table t1 select repeat('a',4000) a; diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result index 994a16261f5..0b9e893c9e8 100644 --- a/mysql-test/r/ctype_sjis.result +++ b/mysql-test/r/ctype_sjis.result @@ -172,7 +172,7 @@ pattern varchar(64) NO INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d'); SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1; HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern) -323030318180303181803031 25598180256D81802564 2001-01-01 00:00:00 +323030318180303181803031 25598180256D81802564 2001-01-01 00:00:00.000000 DROP TABLE t1; SET collation_connection='sjis_bin'; create table t1 select repeat('a',4000) a; diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 6e5ea46fde1..ae3798e38fb 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -929,7 +929,7 @@ pattern varchar(64) NO INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d'); SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1; HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern) -003200300030003100F70030003100F700300031 0025005900F70025006D00F700250064 2001-01-01 00:00:00 +003200300030003100F70030003100F700300031 0025005900F70025006D00F700250064 2001-01-01 00:00:00.000000 DROP TABLE t1; SET NAMES latin1; SET collation_connection='ucs2_bin'; diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index ba96712653d..bb3a9365793 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1114,7 +1114,7 @@ pattern varchar(64) NO INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d'); SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1; HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern) -32303031C3B73031C3B73031 2559C3B7256DC3B72564 2001-01-01 00:00:00 +32303031C3B73031C3B73031 2559C3B7256DC3B72564 2001-01-01 00:00:00.000000 DROP TABLE t1; SET collation_connection='utf8_bin'; create table t1 select repeat('a',4000) a; diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index ff3f4038447..8439c40fbf9 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -60,70 +60,70 @@ insert into t1 values ('15-2001-1', '%d-%Y-%c'); select date,format,str_to_date(date, format) as str_to_date from t1; date format str_to_date -2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12 -03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 -0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02 -03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 -2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 +2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12.000000 +03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02.000000 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02.000000 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02.000000 +2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12.000000 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450 -2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12 -10:20:10 %H:%i:%s 0000-00-00 10:20:10 -10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10 -10:20:10 %T 0000-00-00 10:20:10 -10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10 -10:20:10AM %r 0000-00-00 10:20:10 +2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12.000000 +10:20:10 %H:%i:%s 0000-00-00 10:20:10.000000 +10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10.000000 +10:20:10 %T 0000-00-00 10:20:10.000000 +10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10.000000 +10:20:10AM %r 0000-00-00 10:20:10.000000 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000 -15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 -15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 -15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 -15th May 2001 %D %b %Y 2001-05-15 00:00:00 -Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 -Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 -Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00 -Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00 -Sunday 01 2001 %W %v %x 2001-01-07 00:00:00 -Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00 -060 2004 %j %Y 2004-02-29 00:00:00 -4 53 1998 %w %u %Y 1998-12-31 00:00:00 -15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00 -15-01-20 %d-%m-%y 2020-01-15 00:00:00 -15-2001-1 %d-%Y-%c 2001-01-15 00:00:00 +15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58.000000 +15 September 2001 %d %M %Y 2001-09-15 00:00:00.000000 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00.000000 +15 MAY 2001 %d %b %Y 2001-05-15 00:00:00.000000 +15th May 2001 %D %b %Y 2001-05-15 00:00:00.000000 +Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00.000000 +Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00.000000 +Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00.000000 +Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00.000000 +Sunday 01 2001 %W %v %x 2001-01-07 00:00:00.000000 +Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00.000000 +060 2004 %j %Y 2004-02-29 00:00:00.000000 +4 53 1998 %w %u %Y 1998-12-31 00:00:00.000000 +15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00.000000 +15-01-20 %d-%m-%y 2020-01-15 00:00:00.000000 +15-2001-1 %d-%Y-%c 2001-01-15 00:00:00.000000 select date,format,concat('',str_to_date(date, format)) as con from t1; date format con -2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12 -03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 -0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02 -03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02 -2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 +2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12.000000 +03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02.000000 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02.000000 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02.000000 +2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12.000000 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450 -2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12 -10:20:10 %H:%i:%s 0000-00-00 10:20:10 -10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10 -10:20:10 %T 0000-00-00 10:20:10 -10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10 -10:20:10AM %r 0000-00-00 10:20:10 +2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12.000000 +10:20:10 %H:%i:%s 0000-00-00 10:20:10.000000 +10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10.000000 +10:20:10 %T 0000-00-00 10:20:10.000000 +10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10.000000 +10:20:10AM %r 0000-00-00 10:20:10.000000 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000 -15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 -15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 -15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 -15th May 2001 %D %b %Y 2001-05-15 00:00:00 -Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 -Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 -Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00 -Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00 -Sunday 01 2001 %W %v %x 2001-01-07 00:00:00 -Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00 -060 2004 %j %Y 2004-02-29 00:00:00 -4 53 1998 %w %u %Y 1998-12-31 00:00:00 -15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00 -15-01-20 %d-%m-%y 2020-01-15 00:00:00 -15-2001-1 %d-%Y-%c 2001-01-15 00:00:00 +15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58.000000 +15 September 2001 %d %M %Y 2001-09-15 00:00:00.000000 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00.000000 +15 MAY 2001 %d %b %Y 2001-05-15 00:00:00.000000 +15th May 2001 %D %b %Y 2001-05-15 00:00:00.000000 +Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00.000000 +Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00.000000 +Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00.000000 +Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00.000000 +Sunday 01 2001 %W %v %x 2001-01-07 00:00:00.000000 +Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00.000000 +060 2004 %j %Y 2004-02-29 00:00:00.000000 +4 53 1998 %w %u %Y 1998-12-31 00:00:00.000000 +15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00.000000 +15-01-20 %d-%m-%y 2020-01-15 00:00:00.000000 +15-2001-1 %d-%Y-%c 2001-01-15 00:00:00.000000 select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1; date format datetime 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12 @@ -352,16 +352,16 @@ insert into t1 values ('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'); select date,format,str_to_date(date, format) as str_to_date from t1; date format str_to_date -10:20:10AM %h:%i:%s 0000-00-00 10:20:10 -2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12 -03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 +10:20:10AM %h:%i:%s 0000-00-00 10:20:10.000000 +2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12.000000 +03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12.000000 Warnings: Warning 1292 Truncated incorrect datetime value: '10:20:10AM' select date,format,concat(str_to_date(date, format),'') as con from t1; date format con -10:20:10AM %h:%i:%s 0000-00-00 10:20:10 -2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12 -03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12 +10:20:10AM %h:%i:%s 0000-00-00 10:20:10.000000 +2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12.000000 +03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12.000000 Warnings: Warning 1292 Truncated incorrect datetime value: '10:20:10AM' drop table t1; @@ -418,7 +418,7 @@ drop table t1; create table t1 select "02 10" as a, "%d %H" as b; select str_to_date(a,b) from t1; str_to_date(a,b) -0000-00-02 10:00:00 +0000-00-02 10:00:00.000000 create table t2 select str_to_date(a,b) from t1; describe t2; Field Type Null Key Default Extra diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 400e3fdc544..cebba082ea4 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1945,6 +1945,74 @@ SELECT 1 FROM DUAL WHERE MINUTE(TIMEDIFF(NULL, '12:12:12')); SELECT 1 FROM DUAL WHERE SECOND(TIMEDIFF(NULL, '12:12:12')); 1 # +# MDEV-4511 Assertion `scale <= precision' fails on GROUP BY TIMEDIFF with incorrect types +# +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT a FROM t1 GROUP BY TIMEDIFF('2004-06-12',a) * 1; +a +2005-05-04 +Warnings: +Warning 1292 Truncated incorrect time value: '2004-06-12' +Warning 1292 Truncated incorrect time value: '2004-06-12' +DROP TABLE t1; +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1; +a +2000-02-23 +2005-05-04 +DROP TABLE t1; +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1; +a +2000-02-23 +2005-05-04 +DROP TABLE t1; +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1; +a +2005-05-04 +2000-02-23 +DROP TABLE t1; +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1; +a +2000-02-23 +2005-05-04 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +STR_TO_DATE('2001-01-01', '%Y-%m-%d') AS date_only, +STR_TO_DATE('10:10:10', '%H:%i:%s') AS time_only, +STR_TO_DATE('10:10:10.123', '%H:%i:%s.%f') AS time_microsecond, +STR_TO_DATE('2001-01-01 10:10:10', '%Y-%m-%d %H:%i:%s') AS date_time, +STR_TO_DATE('2001-01-01 10:10:10.123', '%Y-%m-%d %H:%i:%s.%f') AS date_time_microsecond; +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +date_only date YES NULL +time_only time YES NULL +time_microsecond time(6) YES NULL +date_time datetime YES NULL +date_time_microsecond datetime(6) YES NULL +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +SEC_TO_TIME(1)+0.1, +SEC_TO_TIME(1.1)+0.1, +SEC_TO_TIME(1.12)+0.1, +SEC_TO_TIME(1.123456)+0.1, +SEC_TO_TIME(1.1234567)+0.1; +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +SEC_TO_TIME(1)+0.1 decimal(12,1) YES NULL +SEC_TO_TIME(1.1)+0.1 decimal(13,1) YES NULL +SEC_TO_TIME(1.12)+0.1 decimal(14,2) YES NULL +SEC_TO_TIME(1.123456)+0.1 decimal(18,6) YES NULL +SEC_TO_TIME(1.1234567)+0.1 decimal(18,6) YES NULL +DROP TABLE t1; +# # MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y')) # SET TIME_ZONE='+02:00'; diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index 03b942be3f6..e23c8640dfc 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -161,7 +161,7 @@ INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (NULL); SELECT str_to_date( '', a ) FROM t1; str_to_date( '', a ) -0000-00-00 00:00:00 +0000-00-00 00:00:00.000000 NULL DROP TABLE t1; CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 9270b30c042..b65e634ea61 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1191,6 +1191,52 @@ SELECT 1 FROM DUAL WHERE SECOND(TIMEDIFF(NULL, '12:12:12')); --echo # +--echo # MDEV-4511 Assertion `scale <= precision' fails on GROUP BY TIMEDIFF with incorrect types +--echo # +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT a FROM t1 GROUP BY TIMEDIFF('2004-06-12',a) * 1; +DROP TABLE t1; + +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1; +DROP TABLE t1; + +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1; +DROP TABLE t1; + +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1; +DROP TABLE t1; + +CREATE TABLE t1 (a DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1; +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT + STR_TO_DATE('2001-01-01', '%Y-%m-%d') AS date_only, + STR_TO_DATE('10:10:10', '%H:%i:%s') AS time_only, + STR_TO_DATE('10:10:10.123', '%H:%i:%s.%f') AS time_microsecond, + STR_TO_DATE('2001-01-01 10:10:10', '%Y-%m-%d %H:%i:%s') AS date_time, + STR_TO_DATE('2001-01-01 10:10:10.123', '%Y-%m-%d %H:%i:%s.%f') AS date_time_microsecond; +SHOW COLUMNS FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT + SEC_TO_TIME(1)+0.1, + SEC_TO_TIME(1.1)+0.1, + SEC_TO_TIME(1.12)+0.1, + SEC_TO_TIME(1.123456)+0.1, + SEC_TO_TIME(1.1234567)+0.1; +SHOW COLUMNS FROM t1; +DROP TABLE t1; + +--echo # --echo # MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y')) --echo # SET TIME_ZONE='+02:00'; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 4d261e7a7d9..f2f5b7b1b63 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -3144,7 +3144,7 @@ void Item_func_str_to_date::fix_length_and_dec() } cached_field_type= MYSQL_TYPE_DATETIME; - decimals= NOT_FIXED_DEC; + decimals= TIME_SECOND_PART_DIGITS; if ((const_item= args[1]->const_item())) { char format_buff[64]; diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 8f881487e21..29badddad8e 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -809,7 +809,7 @@ public: bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); void fix_length_and_dec() { - decimals= args[0]->decimals; + decimals= MY_MIN(args[0]->decimals, TIME_SECOND_PART_DIGITS); Item_timefunc::fix_length_and_dec(); } const char *func_name() const { return "sec_to_time"; } diff --git a/storage/tokudb/mysql-test/tokudb/r/type_date.result b/storage/tokudb/mysql-test/tokudb/r/type_date.result index f34dc07130f..047dc6dc777 100644 --- a/storage/tokudb/mysql-test/tokudb/r/type_date.result +++ b/storage/tokudb/mysql-test/tokudb/r/type_date.result @@ -153,7 +153,7 @@ INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (NULL); SELECT str_to_date( '', a ) FROM t1; str_to_date( '', a ) -0000-00-00 00:00:00 +0000-00-00 00:00:00.000000 NULL DROP TABLE t1; CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b)); |