diff options
author | Michael Widenius <monty@askmonty.org> | 2013-07-02 22:11:12 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2013-07-02 22:11:12 +0300 |
commit | 82a0b8ae30bc7c9ad9b27bf00ec608954f2262e0 (patch) | |
tree | 519597ce7da4038e1fc6f68908c272b0946030b0 | |
parent | 99aae21ed25b42ee3cf62815ecfc8204de8b6fd0 (diff) | |
download | mariadb-git-82a0b8ae30bc7c9ad9b27bf00ec608954f2262e0.tar.gz |
strict.test now works.
-rw-r--r-- | mysql-test/r/bootstrap.result | 2 | ||||
-rw-r--r-- | mysql-test/r/strict.result | 31 | ||||
-rw-r--r-- | mysql-test/t/strict.test | 20 | ||||
-rw-r--r-- | sql/item.cc | 4 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 6 | ||||
-rw-r--r-- | sql/sql_class.h | 2 |
6 files changed, 56 insertions, 9 deletions
diff --git a/mysql-test/r/bootstrap.result b/mysql-test/r/bootstrap.result index 8bef6f90ab4..2e2082441f8 100644 --- a/mysql-test/r/bootstrap.result +++ b/mysql-test/r/bootstrap.result @@ -1,7 +1,7 @@ drop table if exists t1; drop table t1; drop table t1; -ERROR 42S02: Unknown table 't1' +ERROR 42S02: Unknown table 'test.t1' set @my_max_allowed_packet= @@max_allowed_packet; set global max_allowed_packet=100*@@max_allowed_packet; set global max_allowed_packet=@my_max_allowed_packet; diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index b1e4cb669ed..3861f12d5ed 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -793,7 +793,7 @@ INSERT INTO t1 (col1) VALUES ('1a'); ERROR 22007: Incorrect decimal value: '1a' for column 'col1' at row 1 INSERT IGNORE INTO t1 (col1) VALUES ('2a'); Warnings: -Note 1265 Data truncated for column 'col1' at row 1 +Warning 1265 Data truncated for column 'col1' at row 1 INSERT IGNORE INTO t1 values (1/0); Warnings: Warning 1365 Division by 0 @@ -1190,8 +1190,6 @@ select'a'; insert into t1 values (200); end;| call t1(); a a -Warnings: -Error 1264 Out of range value for column 'col1' at row 1 select * from t1; col1 drop procedure t1; @@ -1501,3 +1499,30 @@ count(*) 0 drop table t1; End of 5.0 tests +# +# Start of 5.6 tests +# +# +# WL#946 TIME/TIMESTAMP/DATETIME with fractional seconds: CAST to DATETIME +# +# +# STR_TO_DATE with NO_ZERO_DATE did not return NULL (with warning) +# in get_date(). Only did in val_str() and val_int(). +SET sql_mode='NO_ZERO_DATE'; +SELECT STR_TO_DATE('2001','%Y'),CONCAT(STR_TO_DATE('2001','%Y')), STR_TO_DATE('2001','%Y')+1, STR_TO_DATE('0','%Y')+1, STR_TO_DATE('0000','%Y')+1; +STR_TO_DATE('2001','%Y') CONCAT(STR_TO_DATE('2001','%Y')) STR_TO_DATE('2001','%Y')+1 STR_TO_DATE('0','%Y')+1 STR_TO_DATE('0000','%Y')+1 +2001-00-00 2001-00-00 20010001 20000001 NULL +Warnings: +Warning 1411 Incorrect datetime value: '0000' for function str_to_date +SET sql_mode='NO_ZERO_IN_DATE'; +SELECT STR_TO_DATE('2001','%Y'),CONCAT(STR_TO_DATE('2001','%Y')), STR_TO_DATE('2001','%Y')+1, STR_TO_DATE('0000','%Y')+1; +STR_TO_DATE('2001','%Y') CONCAT(STR_TO_DATE('2001','%Y')) STR_TO_DATE('2001','%Y')+1 STR_TO_DATE('0000','%Y')+1 +NULL NULL NULL NULL +Warnings: +Warning 1411 Incorrect datetime value: '2001' for function str_to_date +Warning 1411 Incorrect datetime value: '2001' for function str_to_date +Warning 1411 Incorrect datetime value: '2001' for function str_to_date +Warning 1411 Incorrect datetime value: '0000' for function str_to_date +# +# End of 5.6 tests +# diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index f6080de6c2c..375b8fbac28 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -1350,3 +1350,23 @@ select count(*) from t1 where a is null; drop table t1; --echo End of 5.0 tests + +--echo # +--echo # Start of 5.6 tests +--echo # + +--echo # +--echo # WL#946 TIME/TIMESTAMP/DATETIME with fractional seconds: CAST to DATETIME +--echo # + +--echo # +--echo # STR_TO_DATE with NO_ZERO_DATE did not return NULL (with warning) +--echo # in get_date(). Only did in val_str() and val_int(). +SET sql_mode='NO_ZERO_DATE'; +SELECT STR_TO_DATE('2001','%Y'),CONCAT(STR_TO_DATE('2001','%Y')), STR_TO_DATE('2001','%Y')+1, STR_TO_DATE('0','%Y')+1, STR_TO_DATE('0000','%Y')+1; +SET sql_mode='NO_ZERO_IN_DATE'; +SELECT STR_TO_DATE('2001','%Y'),CONCAT(STR_TO_DATE('2001','%Y')), STR_TO_DATE('2001','%Y')+1, STR_TO_DATE('0000','%Y')+1; + +--echo # +--echo # End of 5.6 tests +--echo # diff --git a/sql/item.cc b/sql/item.cc index 035f017464c..f004f25b18c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -297,7 +297,7 @@ String *Item::val_string_from_decimal(String *str) String *Item::val_string_from_date(String *str) { MYSQL_TIME ltime; - if (get_date(<ime, TIME_FUZZY_DATE) || + if (get_date(<ime, TIME_FUZZY_DATE | sql_mode_for_dates()) || str->alloc(MAX_DATE_STRING_REP_LENGTH)) { null_value= 1; @@ -354,7 +354,7 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - if (get_date(<ime, TIME_FUZZY_DATE)) + if (get_date(<ime, TIME_FUZZY_DATE | sql_mode_for_dates())) { my_decimal_set_zero(decimal_value); null_value= 1; // set NULL, stop processing diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 117904d8b82..8177a019386 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -415,8 +415,10 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, l_time->minute > 59 || l_time->second > 59) goto err; - if ((fuzzy_date & TIME_NO_ZERO_DATE) && - (l_time->year == 0 || l_time->month == 0 || l_time->day == 0)) + if (((fuzzy_date & TIME_NO_ZERO_IN_DATE) && + (l_time->year == 0 || l_time->month == 0 || l_time->day == 0)) || + (fuzzy_date & TIME_NO_ZERO_DATE) && + (l_time->year == 0 && l_time->month == 0 && l_time->day == 0)) goto err; if (val != val_end) diff --git a/sql/sql_class.h b/sql/sql_class.h index e8e3c9da515..48799a62bb2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3417,7 +3417,7 @@ my_eof(THD *thd) checking for all date handling. */ -const my_bool strict_date_checking= 0; +const my_bool strict_date_checking= 1; inline sql_mode_t sql_mode_for_dates(THD *thd) { |