mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 03:47:17 +02:00
Bug#56271: Wrong comparison result with STR_TO_DATE function
The Item_func_str_to_date class wasn't providing correct integer DATETIME representation as expected. This led to wrong comparison result and didn't allowed the STR_TO_DATE function to be used with indexes. Also, STR_TO_DATE function was inconsisted on throwing warnings/errors. Fixed now. val_int and result_as_longlong methods were added to the Item_func_str_to_date class. mysql-test/r/func_time.result: Test case result adjusted after fixing bug#56271. mysql-test/r/parser.result: Test case result adjusted after fixing bug#56271. mysql-test/r/select.result: A test case result adjusted after fixing bug#56271. mysql-test/r/strict.result: Test case result adjusted after fixing bug#56271. mysql-test/r/type_datetime.result: Added a test case for the bug#56271. mysql-test/t/strict.test: Test case adjusted after fixing bug#56271. mysql-test/t/type_datetime.test: Added a test case for the bug#56271. sql/item_timefunc.cc: Bug#56271: Wrong comparison result with STR_TO_DATE function val_int and result_as_longlong methods were added to the Item_func_str_to_date class. Item_func_str_to_date::get_date now throws the ER_WRONG_VALUE_FOR_TYPE warning on incorrect value. sql/item_timefunc.h: Bug#56271: Wrong comparison result with STR_TO_DATE function val_int and result_as_longlong methods were added to the Item_func_str_to_date class.
This commit is contained in:
parent
99c7536c5c
commit
e435df8e09
9 changed files with 124 additions and 31 deletions
|
|
@ -206,12 +206,11 @@ INSERT INTO t1 (col1) VALUES (STR_TO_DATE('15.10.2004','%d.%m.%Y'));
|
|||
INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
|
||||
INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
|
||||
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'col1' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '31.10.0000 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '31.0.2004 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect date value: '2004-10-00 15:30:00' for column 'col1' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '0.10.2004 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect date value: '2004-09-31 15:30:00' for column 'col1' at row 1
|
||||
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
|
|
@ -221,12 +220,13 @@ ERROR 22007: Incorrect date value: '2003-02-29 15:30:00' for column 'col1' at ro
|
|||
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
|
||||
ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '00.00.0000' for function str_to_date
|
||||
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR HY000: Incorrect datetime value: '31.10.0000 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect datetime value: '2004-00-31 15:30:00' for column 'col2' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '31.0.2004 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '0.10.2004 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect datetime value: '2004-09-31 15:30:00' for column 'col2' at row 1
|
||||
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
|
|
@ -236,13 +236,13 @@ ERROR 22007: Incorrect datetime value: '2003-02-29 15:30:00' for column 'col2' a
|
|||
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
|
||||
ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col2' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '00.00.0000' for function str_to_date
|
||||
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '31.10.0000 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect datetime value: '2004-00-31 15:30:00' for column 'col3' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '31.0.2004 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '0.10.2004 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR 22007: Incorrect datetime value: '2004-09-31 15:30:00' for column 'col3' at row 1
|
||||
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
|
|
@ -252,7 +252,7 @@ ERROR 22007: Incorrect datetime value: '2003-02-29 15:30:00' for column 'col3' a
|
|||
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
|
||||
ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_date
|
||||
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
|
||||
ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col3' at row 1
|
||||
ERROR HY000: Incorrect datetime value: '00.00.0000' for function str_to_date
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
|
||||
INSERT INTO t1 (col1) VALUES (CAST('2004-10-15' AS DATE));
|
||||
|
|
@ -1108,6 +1108,9 @@ Warnings:
|
|||
Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
|
||||
drop table t1;
|
||||
create table t1 (col1 char(3), col2 integer);
|
||||
insert into t1 (col1) values (cast(1000 as char(3)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue