mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-457 Inconsistent data truncation on datetime values with fractional seconds represented as strings with no delimiters
New implementation for str_to_datetime. Fix MDEV-457 and related issues.
This commit is contained in:
@@ -1023,11 +1023,11 @@ MAKETIME(CAST(-1 AS UNSIGNED), 0, 0)
|
||||
Warnings:
|
||||
Note 1105 Cast to unsigned converted negative integer to it's positive complement
|
||||
Warning 1292 Truncated incorrect time value: '18446744073709551615:00:00'
|
||||
SELECT EXTRACT(HOUR FROM '100000:02:03');
|
||||
EXTRACT(HOUR FROM '100000:02:03')
|
||||
SELECT EXTRACT(HOUR FROM '10000:02:03');
|
||||
EXTRACT(HOUR FROM '10000:02:03')
|
||||
838
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '100000:02:03'
|
||||
Warning 1292 Truncated incorrect time value: '10000:02:03'
|
||||
CREATE TABLE t1(f1 TIME);
|
||||
INSERT INTO t1 VALUES('916:00:00 a');
|
||||
Warnings:
|
||||
|
@@ -5,8 +5,8 @@ Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
Warning 1265 Data truncated for column 'c' at row 1
|
||||
Warning 1265 Data truncated for column 'd' at row 1
|
||||
Warning 1264 Out of range value for column 'a' at row 2
|
||||
Warning 1264 Out of range value for column 'b' at row 2
|
||||
Warning 1265 Data truncated for column 'a' at row 2
|
||||
Warning 1265 Data truncated for column 'b' at row 2
|
||||
Warning 1265 Data truncated for column 'd' at row 2
|
||||
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
|
||||
SELECT * from t1;
|
||||
@@ -20,7 +20,7 @@ load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'c' at row 1
|
||||
Warning 1265 Data truncated for column 'd' at row 1
|
||||
Warning 1264 Out of range value for column 'b' at row 2
|
||||
Warning 1265 Data truncated for column 'b' at row 2
|
||||
Warning 1265 Data truncated for column 'd' at row 2
|
||||
SELECT * from t1;
|
||||
a b c d
|
||||
|
51
mysql-test/r/str_to_datetime_457.result
Normal file
51
mysql-test/r/str_to_datetime_457.result
Normal file
@@ -0,0 +1,51 @@
|
||||
select cast('01:02:03 ' as time), cast('01:02:03 ' as time);
|
||||
cast('01:02:03 ' as time) cast('01:02:03 ' as time)
|
||||
01:02:03 00:00:00
|
||||
select cast('2002-011-012' as date), cast('2002.11.12' as date), cast('2002.011.012' as date);
|
||||
cast('2002-011-012' as date) cast('2002.11.12' as date) cast('2002.011.012' as date)
|
||||
2002-11-12 2002-11-12 2002-11-12
|
||||
select cast('2012103123595912' as datetime(6)), cast('20121031235959123' as datetime(6));
|
||||
cast('2012103123595912' as datetime(6)) cast('20121031235959123' as datetime(6))
|
||||
2012-10-31 23:59:59.000000 2012-10-31 23:59:59.000000
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '2012103123595912'
|
||||
Warning 1292 Truncated incorrect datetime value: '20121031235959123'
|
||||
select cast(0 as date), cast('0000-00-00' as date), cast('0' as date);
|
||||
cast(0 as date) cast('0000-00-00' as date) cast('0' as date)
|
||||
0000-00-00 0000-00-00 NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '0'
|
||||
select extract(hour from '100000:02:03'), extract(hour from '100000:02:03 ');
|
||||
extract(hour from '100000:02:03') extract(hour from '100000:02:03 ')
|
||||
NULL NULL
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '100000:02:03'
|
||||
Warning 1292 Truncated incorrect time value: '100000:02:03 '
|
||||
#
|
||||
# backward compatibility craziness
|
||||
#
|
||||
select cast('12:00:00.12.34.56' as time);
|
||||
cast('12:00:00.12.34.56' as time)
|
||||
12:00:00
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '12:00:00.12.34.56'
|
||||
select cast('12:00:00 12.34.56' as time);
|
||||
cast('12:00:00 12.34.56' as time)
|
||||
12:34:56
|
||||
select cast('12:00:00-12.34.56' as time);
|
||||
cast('12:00:00-12.34.56' as time)
|
||||
12:00:00
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '12:00:00-12.34.56'
|
||||
select cast('12:00:00.12.34.56' as datetime);
|
||||
cast('12:00:00.12.34.56' as datetime)
|
||||
2012-00-00 12:34:56
|
||||
select cast('12:00:00-12.34.56' as datetime);
|
||||
cast('12:00:00-12.34.56' as datetime)
|
||||
2012-00-00 12:34:56
|
||||
select cast('12:00:00 12.34.56' as datetime);
|
||||
cast('12:00:00 12.34.56' as datetime)
|
||||
2012-00-00 12:34:56
|
||||
select cast('12:00:00.123456' as time);
|
||||
cast('12:00:00.123456' as time)
|
||||
12:00:00
|
@@ -3801,7 +3801,7 @@ NULL NULL 1
|
||||
00:00:00 2
|
||||
00:00:00 <--------30 characters-------> 3
|
||||
-00:00:00 ---äÖüß@µ*$-- 4
|
||||
NULL -1 5
|
||||
-00:00:01 -1 5
|
||||
41:58:00 1 17:58 22
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||
@@ -3820,7 +3820,7 @@ NULL NULL 1
|
||||
00:00:00 |