Commit 82a0b8ae authored by Michael Widenius's avatar Michael Widenius

strict.test now works.

parent 99aae21e
drop table if exists t1; drop table if exists t1;
drop table t1; drop table 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 @my_max_allowed_packet= @@max_allowed_packet;
set global max_allowed_packet=100*@@max_allowed_packet; set global max_allowed_packet=100*@@max_allowed_packet;
set global max_allowed_packet=@my_max_allowed_packet; set global max_allowed_packet=@my_max_allowed_packet;
......
...@@ -793,7 +793,7 @@ INSERT INTO t1 (col1) VALUES ('1a'); ...@@ -793,7 +793,7 @@ INSERT INTO t1 (col1) VALUES ('1a');
ERROR 22007: Incorrect decimal value: '1a' for column 'col1' at row 1 ERROR 22007: Incorrect decimal value: '1a' for column 'col1' at row 1
INSERT IGNORE INTO t1 (col1) VALUES ('2a'); INSERT IGNORE INTO t1 (col1) VALUES ('2a');
Warnings: 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); INSERT IGNORE INTO t1 values (1/0);
Warnings: Warnings:
Warning 1365 Division by 0 Warning 1365 Division by 0
...@@ -1190,8 +1190,6 @@ select'a'; insert into t1 values (200); end;| ...@@ -1190,8 +1190,6 @@ select'a'; insert into t1 values (200); end;|
call t1(); call t1();
a a
a a
Warnings:
Error 1264 Out of range value for column 'col1' at row 1
select * from t1; select * from t1;
col1 col1
drop procedure t1; drop procedure t1;
...@@ -1501,3 +1499,30 @@ count(*) ...@@ -1501,3 +1499,30 @@ count(*)
0 0
drop table t1; drop table t1;
End of 5.0 tests 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
#
...@@ -1350,3 +1350,23 @@ select count(*) from t1 where a is null; ...@@ -1350,3 +1350,23 @@ select count(*) from t1 where a is null;
drop table t1; drop table t1;
--echo End of 5.0 tests --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 #
...@@ -297,7 +297,7 @@ String *Item::val_string_from_decimal(String *str) ...@@ -297,7 +297,7 @@ String *Item::val_string_from_decimal(String *str)
String *Item::val_string_from_date(String *str) String *Item::val_string_from_date(String *str)
{ {
MYSQL_TIME ltime; MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE) || if (get_date(&ltime, TIME_FUZZY_DATE | sql_mode_for_dates()) ||
str->alloc(MAX_DATE_STRING_REP_LENGTH)) str->alloc(MAX_DATE_STRING_REP_LENGTH))
{ {
null_value= 1; null_value= 1;
...@@ -354,7 +354,7 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) ...@@ -354,7 +354,7 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime; MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE)) if (get_date(&ltime, TIME_FUZZY_DATE | sql_mode_for_dates()))
{ {
my_decimal_set_zero(decimal_value); my_decimal_set_zero(decimal_value);
null_value= 1; // set NULL, stop processing null_value= 1; // set NULL, stop processing
......
...@@ -415,8 +415,10 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, ...@@ -415,8 +415,10 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
l_time->minute > 59 || l_time->second > 59) l_time->minute > 59 || l_time->second > 59)
goto err; goto err;
if ((fuzzy_date & TIME_NO_ZERO_DATE) && if (((fuzzy_date & TIME_NO_ZERO_IN_DATE) &&
(l_time->year == 0 || l_time->month == 0 || l_time->day == 0)) (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; goto err;
if (val != val_end) if (val != val_end)
......
...@@ -3417,7 +3417,7 @@ my_eof(THD *thd) ...@@ -3417,7 +3417,7 @@ my_eof(THD *thd)
checking for all date handling. 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) inline sql_mode_t sql_mode_for_dates(THD *thd)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment