Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
d3d3a4b8
Commit
d3d3a4b8
authored
Apr 24, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-4511 Assertion `scale <= precision' fails on GROUP BY TIMEDIFF with incorrect types
parent
aefddfe3
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
183 additions
and
69 deletions
+183
-69
mysql-test/r/ctype_latin1.result
mysql-test/r/ctype_latin1.result
+1
-1
mysql-test/r/ctype_sjis.result
mysql-test/r/ctype_sjis.result
+1
-1
mysql-test/r/ctype_ucs.result
mysql-test/r/ctype_ucs.result
+1
-1
mysql-test/r/ctype_utf8.result
mysql-test/r/ctype_utf8.result
+1
-1
mysql-test/r/date_formats.result
mysql-test/r/date_formats.result
+61
-61
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+68
-0
mysql-test/r/type_date.result
mysql-test/r/type_date.result
+1
-1
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+46
-0
sql/item_timefunc.cc
sql/item_timefunc.cc
+1
-1
sql/item_timefunc.h
sql/item_timefunc.h
+1
-1
storage/tokudb/mysql-test/tokudb/r/type_date.result
storage/tokudb/mysql-test/tokudb/r/type_date.result
+1
-1
No files found.
mysql-test/r/ctype_latin1.result
View file @
d3d3a4b8
...
@@ -370,7 +370,7 @@ pattern varchar(64) NO
...
@@ -370,7 +370,7 @@ pattern varchar(64) NO
INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d');
INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d');
SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1;
SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1;
HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern)
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;
DROP TABLE t1;
SET collation_connection='latin1_bin';
SET collation_connection='latin1_bin';
create table t1 select repeat('a',4000) a;
create table t1 select repeat('a',4000) a;
...
...
mysql-test/r/ctype_sjis.result
View file @
d3d3a4b8
...
@@ -172,7 +172,7 @@ pattern varchar(64) NO
...
@@ -172,7 +172,7 @@ pattern varchar(64) NO
INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d');
INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d');
SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1;
SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1;
HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern)
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;
DROP TABLE t1;
SET collation_connection='sjis_bin';
SET collation_connection='sjis_bin';
create table t1 select repeat('a',4000) a;
create table t1 select repeat('a',4000) a;
...
...
mysql-test/r/ctype_ucs.result
View file @
d3d3a4b8
...
@@ -929,7 +929,7 @@ pattern varchar(64) NO
...
@@ -929,7 +929,7 @@ pattern varchar(64) NO
INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d');
INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d');
SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1;
SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1;
HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern)
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;
DROP TABLE t1;
SET NAMES latin1;
SET NAMES latin1;
SET collation_connection='ucs2_bin';
SET collation_connection='ucs2_bin';
...
...
mysql-test/r/ctype_utf8.result
View file @
d3d3a4b8
...
@@ -1114,7 +1114,7 @@ pattern varchar(64) NO
...
@@ -1114,7 +1114,7 @@ pattern varchar(64) NO
INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d');
INSERT INTO t1 VALUES (_utf8'2001÷01÷01',_utf8'%Y÷%m÷%d');
SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1;
SELECT HEX(subject),HEX(pattern),STR_TO_DATE(subject, pattern) FROM t1;
HEX(subject) HEX(pattern) STR_TO_DATE(subject, pattern)
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;
DROP TABLE t1;
SET collation_connection='utf8_bin';
SET collation_connection='utf8_bin';
create table t1 select repeat('a',4000) a;
create table t1 select repeat('a',4000) a;
...
...
mysql-test/r/date_formats.result
View file @
d3d3a4b8
...
@@ -60,70 +60,70 @@ insert into t1 values
...
@@ -60,70 +60,70 @@ insert into t1 values
('15-2001-1', '%d-%Y-%c');
('15-2001-1', '%d-%Y-%c');
select date,format,str_to_date(date, format) as str_to_date from t1;
select date,format,str_to_date(date, format) as str_to_date from t1;
date format str_to_date
date format str_to_date
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10: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
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
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
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
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 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 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 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
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
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
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
.000000
10:20:10 %T 0000-00-00 10:20:10
10:20:10 %T 0000-00-00 10:20:10
.000000
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
.000000
10:20:10AM %r 0000-00-00 10:20:10
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
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-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
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
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
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
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
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
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
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
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
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
Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00
.000000
060 2004 %j %Y 2004-02-29 00:00:00
060 2004 %j %Y 2004-02-29 00:00:00
.000000
4 53 1998 %w %u %Y 1998-12-31 00:00:00
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
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
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
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;
select date,format,concat('',str_to_date(date, format)) as con from t1;
date format con
date format con
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10: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
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
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
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
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 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 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 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
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
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
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
.000000
10:20:10 %T 0000-00-00 10:20:10
10:20:10 %T 0000-00-00 10:20:10
.000000
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
.000000
10:20:10AM %r 0000-00-00 10:20:10
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
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-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
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
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
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
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
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
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
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
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
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
Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00
.000000
060 2004 %j %Y 2004-02-29 00:00:00
060 2004 %j %Y 2004-02-29 00:00:00
.000000
4 53 1998 %w %u %Y 1998-12-31 00:00:00
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
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
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
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;
select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1;
date format datetime
date format datetime
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
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
...
@@ -352,16 +352,16 @@ insert into t1 values
('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p');
('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;
select date,format,str_to_date(date, format) as str_to_date from t1;
date format str_to_date
date format str_to_date
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
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
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
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
.000000
Warnings:
Warnings:
Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
select date,format,concat(str_to_date(date, format),'') as con from t1;
select date,format,concat(str_to_date(date, format),'') as con from t1;
date format con
date format con
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
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
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
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
.000000
Warnings:
Warnings:
Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
drop table t1;
drop table t1;
...
@@ -418,7 +418,7 @@ drop table t1;
...
@@ -418,7 +418,7 @@ drop table t1;
create table t1 select "02 10" as a, "%d %H" as b;
create table t1 select "02 10" as a, "%d %H" as b;
select str_to_date(a,b) from t1;
select str_to_date(a,b) from t1;
str_to_date(a,b)
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;
create table t2 select str_to_date(a,b) from t1;
describe t2;
describe t2;
Field Type Null Key Default Extra
Field Type Null Key Default Extra
...
...
mysql-test/r/func_time.result
View file @
d3d3a4b8
...
@@ -1945,6 +1945,74 @@ SELECT 1 FROM DUAL WHERE MINUTE(TIMEDIFF(NULL, '12:12:12'));
...
@@ -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'));
SELECT 1 FROM DUAL WHERE SECOND(TIMEDIFF(NULL, '12:12:12'));
1
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'))
# MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
#
#
SET TIME_ZONE='+02:00';
SET TIME_ZONE='+02:00';
...
...
mysql-test/r/type_date.result
View file @
d3d3a4b8
...
@@ -161,7 +161,7 @@ INSERT INTO t1 VALUES (1);
...
@@ -161,7 +161,7 @@ INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT str_to_date( '', a ) FROM t1;
SELECT str_to_date( '', a ) FROM t1;
str_to_date( '', a )
str_to_date( '', a )
0000-00-00 00:00:00
0000-00-00 00:00:00
.000000
NULL
NULL
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b));
CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b));
...
...
mysql-test/t/func_time.test
View file @
d3d3a4b8
...
@@ -1190,6 +1190,52 @@ SELECT 1 FROM DUAL WHERE MINUTE(TIMEDIFF(NULL, '12:12:12'));
...
@@ -1190,6 +1190,52 @@ SELECT 1 FROM DUAL WHERE MINUTE(TIMEDIFF(NULL, '12:12:12'));
SELECT
1
FROM
DUAL
WHERE
SECOND
(
TIMEDIFF
(
NULL
,
'12:12:12'
));
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
#
--
echo
# MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
--
echo
# MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
--
echo
#
--
echo
#
...
...
sql/item_timefunc.cc
View file @
d3d3a4b8
...
@@ -3144,7 +3144,7 @@ void Item_func_str_to_date::fix_length_and_dec()
...
@@ -3144,7 +3144,7 @@ void Item_func_str_to_date::fix_length_and_dec()
}
}
cached_field_type
=
MYSQL_TYPE_DATETIME
;
cached_field_type
=
MYSQL_TYPE_DATETIME
;
decimals
=
NOT_FIXED_DEC
;
decimals
=
TIME_SECOND_PART_DIGITS
;
if
((
const_item
=
args
[
1
]
->
const_item
()))
if
((
const_item
=
args
[
1
]
->
const_item
()))
{
{
char
format_buff
[
64
];
char
format_buff
[
64
];
...
...
sql/item_timefunc.h
View file @
d3d3a4b8
...
@@ -809,7 +809,7 @@ public:
...
@@ -809,7 +809,7 @@ public:
bool
get_date
(
MYSQL_TIME
*
res
,
ulonglong
fuzzy_date
);
bool
get_date
(
MYSQL_TIME
*
res
,
ulonglong
fuzzy_date
);
void
fix_length_and_dec
()
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
();
Item_timefunc
::
fix_length_and_dec
();
}
}
const
char
*
func_name
()
const
{
return
"sec_to_time"
;
}
const
char
*
func_name
()
const
{
return
"sec_to_time"
;
}
...
...
storage/tokudb/mysql-test/tokudb/r/type_date.result
View file @
d3d3a4b8
...
@@ -153,7 +153,7 @@ INSERT INTO t1 VALUES (1);
...
@@ -153,7 +153,7 @@ INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT str_to_date( '', a ) FROM t1;
SELECT str_to_date( '', a ) FROM t1;
str_to_date( '', a )
str_to_date( '', a )
0000-00-00 00:00:00
0000-00-00 00:00:00
.000000
NULL
NULL
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b));
CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment