diff options
author | Alexander Barkov <bar@mariadb.org> | 2013-07-08 16:49:42 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2013-07-08 16:49:42 +0400 |
commit | 1f3ec9800c6c186949302ba27f0137dfe7c0f5f5 (patch) | |
tree | e0e46189e0c73712d39954f0280c63830fd5332e | |
parent | 874bb251372d60243d44e2ba74f0237bc88ec8c2 (diff) | |
parent | 78cc6db44a9f1344dd5c00cf4f3cdde158fe108e (diff) | |
download | mariadb-git-1f3ec9800c6c186949302ba27f0137dfe7c0f5f5.tar.gz |
Merging from 5.3
modified:
include/my_time.h
libmysql/libmysql.c
mysql-test/r/adddate_454.result
mysql-test/r/cast.result
mysql-test/r/date_formats.result
mysql-test/r/func_sapdb.result
mysql-test/r/func_time.result
mysql-test/r/mdev316.result
mysql-test/r/parser.result
mysql-test/r/partition_datatype.result
mysql-test/r/partition_pruning.result
mysql-test/r/type_date.result
mysql-test/r/type_datetime.result
mysql-test/suite/vcol/r/vcol_misc.result
mysql-test/t/cast.test
sql-common/my_time.c
sql/field.cc
sql/field_conv.cc
sql/filesort.cc
sql/item.cc
sql/item.h
sql/item_cmpfunc.cc
sql/item_func.cc
sql/item_strfunc.cc
sql/item_timefunc.cc
sql/sql_time.cc
pending merges:
Sergei Golubchik 2013-07-03 MDEV-4667 DATE('string') incompability betwe...
-rw-r--r-- | include/my_time.h | 15 | ||||
-rw-r--r-- | libmysql/libmysql.c | 8 | ||||
-rw-r--r-- | mysql-test/r/adddate_454.result | 2 | ||||
-rw-r--r-- | mysql-test/r/cast.result | 28 | ||||
-rw-r--r-- | mysql-test/r/date_formats.result | 2 | ||||
-rw-r--r-- | mysql-test/r/func_sapdb.result | 6 | ||||
-rw-r--r-- | mysql-test/r/func_time.result | 22 | ||||
-rw-r--r-- | mysql-test/r/mdev316.result | 2 | ||||
-rw-r--r-- | mysql-test/r/parser.result | 8 | ||||
-rw-r--r-- | mysql-test/r/partition_datatype.result | 9 | ||||
-rw-r--r-- | mysql-test/r/partition_pruning.result | 3 | ||||
-rw-r--r-- | mysql-test/r/type_date.result | 2 | ||||
-rw-r--r-- | mysql-test/r/type_datetime.result | 4 | ||||
-rw-r--r-- | mysql-test/suite/vcol/r/vcol_misc.result | 4 | ||||
-rw-r--r-- | mysql-test/t/cast.test | 3 | ||||
-rw-r--r-- | sql-common/my_time.c | 13 | ||||
-rw-r--r-- | sql/field.cc | 44 | ||||
-rw-r--r-- | sql/field_conv.cc | 4 | ||||
-rw-r--r-- | sql/filesort.cc | 2 | ||||
-rw-r--r-- | sql/item.cc | 21 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 4 | ||||
-rw-r--r-- | sql/item_func.cc | 6 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 4 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 39 | ||||
-rw-r--r-- | sql/sql_time.cc | 5 |
26 files changed, 140 insertions, 122 deletions
diff --git a/include/my_time.h b/include/my_time.h index 9bd545bb850..f9893fa2d01 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -65,14 +65,17 @@ typedef long my_time_t; #endif /* Flags to str_to_datetime */ -#define TIME_FUZZY_DATE 1 + +/* + TIME_FUZZY_DATES is used for the result will only be used for comparison + purposes. Conversion is as relaxed as possible. +*/ +#define TIME_FUZZY_DATES 1 #define TIME_DATETIME_ONLY 2 #define TIME_TIME_ONLY 4 -/* Must be same as MODE_NO_ZERO_IN_DATE */ -#define TIME_NO_ZERO_IN_DATE (65536L*2*2*2*2*2*2*2) -/* Must be same as MODE_NO_ZERO_DATE */ -#define TIME_NO_ZERO_DATE (TIME_NO_ZERO_IN_DATE*2) -#define TIME_INVALID_DATES (TIME_NO_ZERO_DATE*2) +#define TIME_NO_ZERO_IN_DATE (1UL << 23) /* == MODE_NO_ZERO_IN_DATE */ +#define TIME_NO_ZERO_DATE (1UL << 24) /* == MODE_NO_ZERO_DATE */ +#define TIME_INVALID_DATES (1UL << 25) /* == MODE_INVALID_DATES */ #define MYSQL_TIME_WARN_TRUNCATED 1 #define MYSQL_TIME_WARN_OUT_OF_RANGE 2 diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 6d2582ad9a4..a6b7d2d6c8a 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3200,7 +3200,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value, case MYSQL_TYPE_TIME: { MYSQL_TIME *tm= (MYSQL_TIME *)buffer; - str_to_time(value, length, tm, TIME_FUZZY_DATE, &err); + str_to_time(value, length, tm, 0, &err); *param->error= test(err); break; } @@ -3209,7 +3209,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value, case MYSQL_TYPE_TIMESTAMP: { MYSQL_TIME *tm= (MYSQL_TIME *)buffer; - (void) str_to_datetime(value, length, tm, TIME_FUZZY_DATE, &err); + (void) str_to_datetime(value, length, tm, 0, &err); *param->error= test(err) && (param->buffer_type == MYSQL_TYPE_DATE && tm->time_type != MYSQL_TIMESTAMP_DATE); break; @@ -3332,9 +3332,7 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, case MYSQL_TYPE_DATETIME: { int error; - value= number_to_datetime(value, 0, - (MYSQL_TIME *) buffer, TIME_FUZZY_DATE, - &error); + value= number_to_datetime(value, 0, (MYSQL_TIME *) buffer, 0, &error); *param->error= test(error); break; } diff --git a/mysql-test/r/adddate_454.result b/mysql-test/r/adddate_454.result index 0993cdce32c..8b7c17cd47e 100644 --- a/mysql-test/r/adddate_454.result +++ b/mysql-test/r/adddate_454.result @@ -4,6 +4,8 @@ select * from t1; d 2012-00-00 update t1 set d = adddate(d, interval 1 day); +Warnings: +Warning 1292 Incorrect datetime value: '2012-00-00' select * from t1; d NULL diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 625791a7c4b..6f6dde1e172 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -268,37 +268,37 @@ cast(010203101112.121314 as datetime) 0001-02-03 10:11:12 select cast(120010203101112.121314 as datetime); cast(120010203101112.121314 as datetime) -0000-00-00 00:00:00 +NULL Warnings: Warning 1292 Incorrect datetime value: '120010203101112.121314' select cast(cast(1.1 as decimal) as datetime); cast(cast(1.1 as decimal) as datetime) -0000-00-00 00:00:00 +NULL Warnings: Warning 1292 Incorrect datetime value: '1' select cast(cast(-1.1 as decimal) as datetime); cast(cast(-1.1 as decimal) as datetime) -0000-00-00 00:00:00 +NULL Warnings: Warning 1292 Incorrect datetime value: '-1' select cast('0' as date); cast('0' as date) -0000-00-00 +NULL Warnings: Warning 1292 Incorrect datetime value: '0' select cast('' as date); cast('' as date) -0000-00-00 +NULL Warnings: Warning 1292 Incorrect datetime value: '' select cast('0' as datetime); cast('0' as datetime) -0000-00-00 00:00:00 +NULL Warnings: Warning 1292 Incorrect datetime value: '0' select cast('' as datetime); cast('' as datetime) -0000-00-00 00:00:00 +NULL Warnings: Warning 1292 Incorrect datetime value: '' select cast('0' as time); @@ -306,7 +306,7 @@ cast('0' as time) 00:00:00 select cast('' as time); cast('' as time) -00:00:00 +NULL Warnings: Warning 1292 Truncated incorrect time value: '' select cast(NULL as DATE); @@ -323,13 +323,13 @@ cast(NULL as BINARY) NULL select cast(cast(120010203101112.121314 as double) as datetime); cast(cast(120010203101112.121314 as double) as datetime) -0000-00-00 00:00:00 +NULL select cast(cast(1.1 as double) as datetime); cast(cast(1.1 as double) as datetime) 0000-00-00 00:00:01 select cast(cast(-1.1 as double) as datetime); cast(cast(-1.1 as double) as datetime) -0000-00-00 00:00:00 +NULL explain extended select cast(10 as double(5,2)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used @@ -786,4 +786,10 @@ SELECT CAST(TIME('10:20:30') AS DATE) + INTERVAL 1 DAY; CAST(TIME('10:20:30') AS DATE) + INTERVAL 1 DAY NULL Warnings: -Warning 1292 Truncated incorrect date value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00' +SET SQL_MODE=ALLOW_INVALID_DATES; +SELECT DATE("foo"); +DATE("foo") +NULL +Warnings: +Warning 1292 Incorrect datetime value: 'foo' diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 3bbd25cbbcc..7f69fd1a5a4 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -521,7 +521,7 @@ TIME_FORMAT("25:00:00", '%l %p') 1 AM SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896); DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896) -1151414896 +NULL Warnings: Warning 1292 Incorrect datetime value: '%Y-%m-%d %H:%i:%s' select str_to_date('04 /30/2004', '%m /%d/%Y'); diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result index 1f20ddc6cbb..72c7a5a128f 100644 --- a/mysql-test/r/func_sapdb.result +++ b/mysql-test/r/func_sapdb.result @@ -168,7 +168,7 @@ date("1997-12-31 23:59:59.000001") 1997-12-31 select date("1997-13-31 23:59:59.000001"); date("1997-13-31 23:59:59.000001") -0000-00-00 +NULL Warnings: Warning 1292 Incorrect datetime value: '1997-13-31 23:59:59.000001' select time("1997-12-31 23:59:59.000001"); @@ -176,7 +176,7 @@ time("1997-12-31 23:59:59.000001") 23:59:59.000001 select time("1997-12-31 25:59:59.000001"); time("1997-12-31 25:59:59.000001") -00:00:00 +NULL Warnings: Warning 1292 Truncated incorrect time value: '1997-12-31 25:59:59.000001' select microsecond("1997-12-31 23:59:59.000001"); @@ -250,8 +250,6 @@ a select microsecond(19971231235959.01) as a; a 10000 -Warnings: -Warning 1292 Truncated incorrect time value: '19971231235959.01' select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a; a 1997-12-31 00:00:10.090000 diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 67844eddef2..05058bdb060 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1222,14 +1222,13 @@ DROP TABLE t1,t2; set time_zone= @@global.time_zone; select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE -NULL -Warnings: -Warning 1411 Incorrect datetime value: '10:00 PM' for function str_to_date +22:10:00 select str_to_date("1997-00-04 22:23:00","%Y-%m-%D") + interval 10 minute; str_to_date("1997-00-04 22:23:00","%Y-%m-%D") + interval 10 minute NULL Warnings: -Warning 1411 Incorrect datetime value: '1997-00-04 22:23:00' for function str_to_date +Warning 1292 Truncated incorrect date value: '1997-00-04 22:23:00' +Warning 1292 Incorrect datetime value: '1997-00-04' create table t1 (field DATE); insert into t1 values ('2006-11-06'); select * from t1 where field < '2006-11-06 04:08:36.0'; @@ -1423,13 +1422,15 @@ MAKEDATE(11111111,1) NULL SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1); WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1) -0 +NULL +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' # # Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0, # DO WEEK((DATE_ADD((CAST(0 AS DATE)), INTERVAL 1 YEAR_MONTH)), 5); Warnings: -Warning 1292 Incorrect datetime value: '0' +Warning 1292 Incorrect datetime value: '0000-00-00' # # BUG#13458237 INCONSISTENT HANDLING OF INVALIDE DATES WITH ZERO DAY # SIMILAR TO '2009-10-00' @@ -1713,6 +1714,7 @@ min(timestampadd(month, 1>'', from_days('%Z'))) NULL Warnings: Warning 1292 Truncated incorrect INTEGER value: '%Z' +Warning 1292 Incorrect datetime value: '0000-00-00' create table t1(a time); insert into t1 values ('00:00:00'),('00:01:00'); select 1 from t1 where 1 < some (select cast(a as datetime) from t1); @@ -1781,7 +1783,7 @@ Warnings: Warning 1441 Datetime function: time field overflow select cast('131415.123e0' as time); cast('131415.123e0' as time) -00:00:00 +NULL Warnings: Warning 1292 Truncated incorrect time value: '131415.123e0' select cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04'; @@ -1801,12 +1803,12 @@ unix_timestamp(null) NULL select truncate(date('2010-40-10'), 6); truncate(date('2010-40-10'), 6) -0.000000 +NULL Warnings: Warning 1292 Incorrect datetime value: '2010-40-10' select extract(month from '2010-40-50'); extract(month from '2010-40-50') -0 +NULL Warnings: Warning 1292 Incorrect datetime value: '2010-40-50' select subtime('0000-00-10 10:10:10', '30 10:00:00'); @@ -1884,6 +1886,8 @@ insert into t1 values ('0000-00-00'); select timestampadd(week, 1, f1) from t1; timestampadd(week, 1, f1) NULL +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' select timestampadd(week, 1, date("0000-00-00")); timestampadd(week, 1, date("0000-00-00")) NULL diff --git a/mysql-test/r/mdev316.result b/mysql-test/r/mdev316.result index 78272549e81..43082769872 100644 --- a/mysql-test/r/mdev316.result +++ b/mysql-test/r/mdev316.result @@ -16,7 +16,7 @@ cast(convert(0x0030 using ucs2) as decimal(5.2)) cast(concat(convert(0x0030 usin 0 0 select cast(convert(_ucs2 0x0030 using latin1) as date), cast(concat(convert(_ucs2 0x0030 using latin1)) as date); cast(convert(_ucs2 0x0030 using latin1) as date) cast(concat(convert(_ucs2 0x0030 using latin1)) as date) -0000-00-00 0000-00-00 +NULL NULL Warnings: Warning 1292 Incorrect datetime value: '0' Warning 1292 Incorrect datetime value: '0' diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result index 10700d0ba73..a4dfab4bf81 100644 --- a/mysql-test/r/parser.result +++ b/mysql-test/r/parser.result @@ -555,14 +555,10 @@ ERROR 42000: Incorrect parameters in the call to native function 'atan' DROP TABLE IF EXISTS t1; SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE -NULL -Warnings: -Warning 1411 Incorrect datetime value: '10:00 PM' for function str_to_date +22:10:00 SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE; STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE -NULL -Warnings: -Warning 1411 Incorrect datetime value: '10:00 PM' for function str_to_date +22:01:00 SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND; "1997-12-31 23:59:59" + INTERVAL 1 SECOND 1998-01-01 00:00:00 diff --git a/mysql-test/r/partition_datatype.result b/mysql-test/r/partition_datatype.result index e0658f71612..1151a1cb1fe 100644 --- a/mysql-test/r/partition_datatype.result +++ b/mysql-test/r/partition_datatype.result @@ -699,6 +699,7 @@ a tz 2038-01-19 03:14:06 Moscow UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a); Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' Warning 1264 Out of range value for column 'a' at row 34 Warning 1264 Out of range value for column 'a' at row 35 SELECT MIN(a), MAX(a) FROM t2; @@ -780,6 +781,10 @@ a tz 2038-01-19 03:14:07 UTC 2011-10-30 00:00:02 Moscow UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a); +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00' SELECT MIN(a), MAX(a) FROM t2; MIN(a) MAX(a) 1970-01-01 00:00:01 2038-01-19 03:14:06 @@ -1174,6 +1179,7 @@ a tz 2038-01-19 06:14:06 Moscow UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a); Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' Warning 1299 Invalid TIMESTAMP value in column 'a' at row 8 Warning 1299 Invalid TIMESTAMP value in column 'a' at row 9 Warning 1264 Out of range value for column 'a' at row 34 @@ -1258,6 +1264,9 @@ a tz 2011-10-30 03:00:02 Moscow UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a); Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00' +Warning 1292 Incorrect datetime value: '0000-00-00' Warning 1299 Invalid TIMESTAMP value in column 'a' at row 18 Warning 1299 Invalid TIMESTAMP value in column 'a' at row 19 SELECT MIN(a), MAX(a) FROM t2; diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index f4d473c00d5..ec7fd798d4c 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -2235,10 +2235,9 @@ INSERT INTO t1 VALUES (1, '2009-01-01'), (2, NULL); # test with an invalid date, which lead to item->null_value is set. EXPLAIN PARTITIONS SELECT * FROM t1 WHERE b < CAST('2009-04-99' AS DATETIME); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE t1 p20090401 ALL NULL NULL NULL NULL 2 Using where +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Warning 1292 Incorrect datetime value: '2009-04-99' -Warning 1292 Incorrect datetime value: '2009-04-99' DROP TABLE t1; CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index e5e28be8f71..af747dca562 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -136,7 +136,7 @@ select @d:=1311; 1311 select year(@d), month(@d), day(@d), cast(@d as date); year(@d) month(@d) day(@d) cast(@d as date) -0 0 0 0000-00-00 +NULL NULL NULL NULL Warnings: Warning 1292 Incorrect datetime value: '1311' Warning 1292 Incorrect datetime value: '1311' diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index e20164dde57..1b53f92f82a 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -657,8 +657,8 @@ create table t1 (d date, t time) engine=myisam; insert into t1 values ('2000-12-03','22:55:23'),('2008-05-03','10:19:31'); select case when d = '2012-12-12' then d else t end as cond, group_concat( d ) from t1 group by cond; cond group_concat( d ) -0000-00-00 00:00:00 2000-12-03 -0000-00-00 00:00:00 2008-05-03 +NULL 2000-12-03 +NULL 2008-05-03 Warnings: Warning 1292 Incorrect datetime value: '22:55:23' Warning 1292 Incorrect datetime value: '10:19:31' diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result index 14467b2d630..4929eabb2e9 100644 --- a/mysql-test/suite/vcol/r/vcol_misc.result +++ b/mysql-test/suite/vcol/r/vcol_misc.result @@ -187,7 +187,11 @@ ts TIMESTAMP, tsv TIMESTAMP AS (ADDDATE(ts, INTERVAL 1 DAY)) VIRTUAL ) ENGINE=MyISAM; INSERT INTO t1 (tsv) VALUES (DEFAULT); +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' INSERT DELAYED INTO t1 (tsv) VALUES (DEFAULT); +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00' FLUSH TABLES; SELECT COUNT(*) FROM t1; COUNT(*) diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 64e8225530b..b7630348c93 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -450,3 +450,6 @@ drop table t1; # SELECT CAST(TIME('10:20:30') AS DATE) + INTERVAL 1 DAY; +SET SQL_MODE=ALLOW_INVALID_DATES; +SELECT DATE("foo"); + diff --git a/sql-common/my_time.c b/sql-common/my_time.c index df75bb49c89..69cd9458135 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -82,7 +82,7 @@ my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, { if (not_zero_date) { - if ((((flags & TIME_NO_ZERO_IN_DATE) || !(flags & TIME_FUZZY_DATE)) && + if (((flags & TIME_NO_ZERO_IN_DATE) && (ltime->month == 0 || ltime->day == 0)) || ltime->neg || (!(flags & TIME_INVALID_DATES) && ltime->month && ltime->day > days_in_month[ltime->month-1] && @@ -114,7 +114,7 @@ my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, length Length of string l_time Date is stored here flags Bitmap of following items - TIME_FUZZY_DATE Set if we should allow partial dates + TIME_FUZZY_DATE TIME_DATETIME_ONLY Set if we only allow full datetimes. TIME_NO_ZERO_IN_DATE Don't allow partial dates TIME_NO_ZERO_DATE Don't allow 0000-00-00 date @@ -1242,12 +1242,7 @@ longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res, nr= (nr+19000000L)*1000000L; /* YYMMDD, year: 1970-1999 */ goto ok; } - /* - Though officially we support DATE values from 1000-01-01 only, one can - easily insert a value like 1-1-1. So, for consistency reasons such dates - are allowed when TIME_FUZZY_DATE is set. - */ - if (nr < 10000101L && !(flags & TIME_FUZZY_DATE)) + if (nr < 10000101L) goto err; if (nr <= 99991231L) { @@ -1326,7 +1321,7 @@ int number_to_time(my_bool neg, longlong nr, ulong sec_part, if (nr > 9999999 && neg == 0) { if (number_to_datetime(nr, sec_part, ltime, - TIME_FUZZY_DATE | TIME_INVALID_DATES, was_cut) < 0) + TIME_INVALID_DATES, was_cut) < 0) return -1; ltime->year= ltime->month= ltime->day= 0; diff --git a/sql/field.cc b/sql/field.cc index 7da46d6b383..0aeb311d65a 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5012,10 +5012,9 @@ int Field_temporal::store(const char *from,uint len,CHARSET_INFO *cs) ErrConvString str(from, len, cs); func_res= str_to_datetime(cs, from, len, <ime, - (TIME_FUZZY_DATE | (thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES))), + MODE_INVALID_DATES)), &error); return store_TIME_with_warning(<ime, &str, error, func_res > MYSQL_TIMESTAMP_ERROR); } @@ -5029,11 +5028,10 @@ int Field_temporal::store(double nr) ErrConvDouble str(nr); longlong tmp= double_to_datetime(nr, <ime, - (TIME_FUZZY_DATE | - (thd->variables.sql_mode & + (thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES))), &error); + MODE_INVALID_DATES)), &error); return store_TIME_with_warning(<ime, &str, error, tmp != -1); } @@ -5046,11 +5044,10 @@ int Field_temporal::store(longlong nr, bool unsigned_val) THD *thd= table->in_use; ErrConvInteger str(nr); - tmp= number_to_datetime(nr, 0, <ime, (TIME_FUZZY_DATE | - (thd->variables.sql_mode & + tmp= number_to_datetime(nr, 0, <ime, (thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES))), &error); + MODE_INVALID_DATES)), &error); return store_TIME_with_warning(<ime, &str, error, tmp != -1); } @@ -5066,17 +5063,16 @@ int Field_temporal::store_time_dec(MYSQL_TIME *ltime, uint dec) structure always fit into DATETIME range. */ have_smth_to_conv= !check_date(&l_time, pack_time(&l_time) != 0, - (TIME_FUZZY_DATE | - (current_thd->variables.sql_mode & + (current_thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES))), &error); + MODE_INVALID_DATES)), &error); return store_TIME_with_warning(&l_time, &str, error, have_smth_to_conv); } my_decimal *Field_temporal::val_decimal(my_decimal *d) { MYSQL_TIME ltime; - if (get_date(<ime, TIME_FUZZY_DATE)) + if (get_date(<ime, 0)) { bzero(<ime, sizeof(ltime)); ltime.time_type= mysql_type_to_time_type(type()); @@ -5215,7 +5211,8 @@ String *Field_time::val_str(String *val_buffer, bool Field_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) { THD *thd= table->in_use; - if (!(fuzzydate & (TIME_FUZZY_DATE|TIME_TIME_ONLY))) + if (!(fuzzydate & TIME_TIME_ONLY) && + (fuzzydate & TIME_NO_ZERO_IN_DATE)) { push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, @@ -5345,7 +5342,7 @@ bool Field_time_hires::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) ltime->time_type= MYSQL_TIMESTAMP_TIME; ltime->hour+= (ltime->month*32+ltime->day)*24; ltime->month= ltime->day= 0; - return fuzzydate & (TIME_FUZZY_DATE | TIME_TIME_ONLY) ? 0 : 1; + return !(fuzzydate & TIME_TIME_ONLY) && (fuzzydate & TIME_NO_ZERO_IN_DATE); } @@ -5736,7 +5733,7 @@ void Field_datetime::store_TIME(MYSQL_TIME *ltime) bool Field_datetime::send_binary(Protocol *protocol) { MYSQL_TIME tm; - Field_datetime::get_date(&tm, TIME_FUZZY_DATE); + Field_datetime::get_date(&tm, 0); return protocol->store(&tm, 0); } @@ -5820,7 +5817,7 @@ bool Field_datetime::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) if (!tmp) return fuzzydate & TIME_NO_ZERO_DATE; if (!ltime->month || !ltime->day) - return !(fuzzydate & TIME_FUZZY_DATE); + return fuzzydate & TIME_NO_ZERO_IN_DATE; return 0; } @@ -5873,11 +5870,10 @@ int Field_datetime_hires::store_decimal(const my_decimal *d) error= 2; } else - tmp= number_to_datetime(nr, sec_part, <ime, (TIME_FUZZY_DATE | - (thd->variables.sql_mode & + tmp= number_to_datetime(nr, sec_part, <ime, (thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES))), &error); + MODE_INVALID_DATES)), &error); return store_TIME_with_warning(<ime, &str, error, tmp != -1); } @@ -5885,7 +5881,7 @@ int Field_datetime_hires::store_decimal(const my_decimal *d) bool Field_datetime_hires::send_binary(Protocol *protocol) { MYSQL_TIME ltime; - Field_datetime_hires::get_date(<ime, TIME_FUZZY_DATE); + Field_datetime_hires::get_date(<ime, 0); return protocol->store(<ime, dec); } @@ -5893,14 +5889,14 @@ bool Field_datetime_hires::send_binary(Protocol *protocol) double Field_datetime_hires::val_real(void) { MYSQL_TIME ltime; - Field_datetime_hires::get_date(<ime, TIME_FUZZY_DATE); + Field_datetime_hires::get_date(<ime, 0); return TIME_to_double(<ime); } longlong Field_datetime_hires::val_int(void) { MYSQL_TIME ltime; - Field_datetime_hires::get_date(<ime, TIME_FUZZY_DATE); + Field_datetime_hires::get_date(<ime, 0); return TIME_to_ulonglong_datetime(<ime); } @@ -5909,7 +5905,7 @@ String *Field_datetime_hires::val_str(String *str, String *unused __attribute__((unused))) { MYSQL_TIME ltime; - Field_datetime_hires::get_date(<ime, TIME_FUZZY_DATE); + Field_datetime_hires::get_date(<ime, 0); str->alloc(field_length+1); str->length(field_length); my_datetime_to_str(<ime, (char*) str->ptr(), dec); @@ -5924,7 +5920,7 @@ bool Field_datetime_hires::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) if (!packed) return fuzzydate & TIME_NO_ZERO_DATE; if (!ltime->month || !ltime->day) - return !(fuzzydate & TIME_FUZZY_DATE); + return fuzzydate & TIME_NO_ZERO_IN_DATE; return 0; } diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 6685b334d06..6c3fcc0d355 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -419,7 +419,7 @@ static void do_field_decimal(Copy_field *copy) static void do_field_temporal(Copy_field *copy) { MYSQL_TIME ltime; - copy->from_field->get_date(<ime, TIME_FUZZY_DATE); + copy->from_field->get_date(<ime, 0); copy->to_field->store_time_dec(<ime, copy->from_field->decimals()); } @@ -890,7 +890,7 @@ int field_conv(Field *to,Field *from) if (from->cmp_type() == TIME_RESULT) { MYSQL_TIME ltime; - if (from->get_date(<ime, TIME_FUZZY_DATE)) + if (from->get_date(<ime, 0)) return to->reset(); else return to->store_time_dec(<ime, from->decimals()); diff --git a/sql/filesort.cc b/sql/filesort.cc index 21b2f213a99..be350037adc 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -874,7 +874,7 @@ static void make_sortkey(register SORTPARAM *param, else { MYSQL_TIME buf; - if (item->get_date_result(&buf, TIME_FUZZY_DATE | TIME_INVALID_DATES)) + if (item->get_date_result(&buf, TIME_INVALID_DATES)) { DBUG_ASSERT(maybe_null); DBUG_ASSERT(item->null_value); diff --git a/sql/item.cc b/sql/item.cc index c251e3d6df3..dc0c977acdd 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, 0) || 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, 0)) { my_decimal_set_zero(decimal_value); null_value= 1; // set NULL, stop processing @@ -413,10 +413,9 @@ int Item::save_time_in_field(Field *field) int Item::save_date_in_field(Field *field) { MYSQL_TIME ltime; - if (get_date(<ime, TIME_FUZZY_DATE | - (current_thd->variables.sql_mode & - (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES)))) + if (get_date(<ime, (current_thd->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | + MODE_INVALID_DATES)))) return set_field_to_null_with_conversions(field, 0); field->set_notnull(); return field->store_time_dec(<ime, decimals); @@ -1280,7 +1279,7 @@ err: if allowed, otherwise - null. */ bzero((char*) ltime,sizeof(*ltime)); - return null_value|= (fuzzydate & (TIME_NO_ZERO_DATE|TIME_NO_ZERO_IN_DATE)); + return null_value|= !(fuzzydate & TIME_FUZZY_DATES); } bool Item::get_seconds(ulonglong *sec, ulong *sec_part) @@ -6385,7 +6384,7 @@ bool Item::send(Protocol *protocol, String *buffer) case MYSQL_TYPE_TIMESTAMP: { MYSQL_TIME tm; - get_date(&tm, TIME_FUZZY_DATE | sql_mode_for_dates()); + get_date(&tm, sql_mode_for_dates()); if (!null_value) { if (f_type == MYSQL_TYPE_DATE) @@ -8610,8 +8609,8 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) } else { - field->get_date(&field_time, TIME_FUZZY_DATE | TIME_INVALID_DATES); - item->get_date(&item_time, TIME_FUZZY_DATE | TIME_INVALID_DATES); + field->get_date(&field_time, TIME_INVALID_DATES); + item->get_date(&item_time, TIME_INVALID_DATES); } return my_time_compare(&field_time, &item_time); } @@ -8793,7 +8792,7 @@ bool Item_cache_temporal::cache_value() value_cached= true; MYSQL_TIME ltime; - if (example->get_date_result(<ime, TIME_FUZZY_DATE)) + if (example->get_date_result(<ime, 0)) value=0; else value= pack_time(<ime); diff --git a/sql/item.h b/sql/item.h index 2b0456bd30c..b04e879ed4f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1047,7 +1047,7 @@ public: Item **ref, bool skip_registered); virtual bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); bool get_time(MYSQL_TIME *ltime) - { return get_date(ltime, TIME_TIME_ONLY | TIME_FUZZY_DATE); } + { return get_date(ltime, TIME_TIME_ONLY); } bool get_seconds(ulonglong *sec, ulong *sec_part); virtual bool get_date_result(MYSQL_TIME *ltime, ulonglong fuzzydate) { return get_date(ltime,fuzzydate); } diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index dfd60316039..5b0a2520fbc 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -723,7 +723,7 @@ bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type, bool value; int error; enum_mysql_timestamp_type timestamp_type; - int flags= TIME_FUZZY_DATE | MODE_INVALID_DATES; + int flags= TIME_FUZZY_DATES | MODE_INVALID_DATES; ErrConvString err(str); if (warn_type == MYSQL_TIMESTAMP_TIME) @@ -896,7 +896,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, else { MYSQL_TIME ltime; - uint fuzzydate= TIME_FUZZY_DATE | TIME_INVALID_DATES; + uint fuzzydate= TIME_FUZZY_DATES | TIME_INVALID_DATES; if (f_type == MYSQL_TYPE_TIME) fuzzydate|= TIME_TIME_ONLY; if (item->get_date(<ime, fuzzydate)) diff --git a/sql/item_func.cc b/sql/item_func.cc index a5a1eb2987a..b047258818b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2849,7 +2849,7 @@ double Item_func_min_max::val_real() if (compare_as_dates) { MYSQL_TIME ltime; - if (get_date(<ime, TIME_FUZZY_DATE)) + if (get_date(<ime, 0)) return 0; return TIME_to_double(<ime); @@ -2878,7 +2878,7 @@ longlong Item_func_min_max::val_int() if (compare_as_dates) { MYSQL_TIME ltime; - if (get_date(<ime, TIME_FUZZY_DATE)) + if (get_date(<ime, 0)) return 0; return TIME_to_ulonglong(<ime); @@ -2908,7 +2908,7 @@ my_decimal *Item_func_min_max::val_decimal(my_decimal *dec) if (compare_as_dates) { MYSQL_TIME ltime; - if (get_date(<ime, TIME_FUZZY_DATE)) + if (get_date(<ime, 0)) return 0; return date2my_decimal(<ime, dec); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index a18ded2de80..c6ca7eb2c3c 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -3873,10 +3873,10 @@ void Item_func_dyncol_create::prepare_arguments() } break; case DYN_COL_DATETIME: - args[valpos]->get_date(&vals[i].x.time_value, TIME_FUZZY_DATE); + args[valpos]->get_date(&vals[i].x.time_value, 0); break; case DYN_COL_DATE: - args[valpos]->get_date(&vals[i].x.time_value, TIME_FUZZY_DATE); + args[valpos]->get_date(&vals[i].x.time_value, 0); break; case DYN_COL_TIME: args[valpos]->get_time(&vals[i].x.time_value); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 82379fd24e1..7bf0e25e848 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -780,7 +780,7 @@ longlong Item_func_to_seconds::val_int_endpoint(bool left_endp, longlong seconds; longlong days; int dummy; /* unused */ - if (get_arg0_date(<ime, TIME_FUZZY_DATE)) + if (get_arg0_date(<ime, TIME_FUZZY_DATES)) { /* got NULL, leave the incl_endp intact */ return LONGLONG_MIN; @@ -858,7 +858,7 @@ longlong Item_func_to_days::val_int_endpoint(bool left_endp, bool *incl_endp) MYSQL_TIME ltime; longlong res; int dummy; /* unused */ - if (get_arg0_date(<ime, TIME_FUZZY_DATE)) + if (get_arg0_date(<ime, 0)) { /* got NULL, leave the incl_endp intact */ return LONGLONG_MIN; @@ -922,14 +922,14 @@ longlong Item_func_dayofmonth::val_int() { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - return get_arg0_date(<ime, TIME_FUZZY_DATE) ? 0 : (longlong) ltime.day; + return get_arg0_date(<ime, 0) ? 0 : (longlong) ltime.day; } longlong Item_func_month::val_int() { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - return get_arg0_date(<ime, TIME_FUZZY_DATE) ? 0 : (longlong) ltime.month; + return get_arg0_date(<ime, 0) ? 0 : (longlong) ltime.month; } @@ -953,7 +953,7 @@ String* Item_func_monthname::val_str(String* str) uint err; MYSQL_TIME ltime; - if ((null_value= (get_arg0_date(<ime, TIME_FUZZY_DATE) || !ltime.month))) + if ((null_value= (get_arg0_date(<ime, 0) || !ltime.month))) return (String *) 0; month_name= locale->month_names->type_names[ltime.month - 1]; @@ -971,7 +971,7 @@ longlong Item_func_quarter::val_int() { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - if (get_arg0_date(<ime, TIME_FUZZY_DATE)) + if (get_arg0_date(<ime, 0)) return 0; return (longlong) ((ltime.month+2)/3); } @@ -1045,7 +1045,7 @@ longlong Item_func_week::val_int() DBUG_ASSERT(fixed == 1); uint year; MYSQL_TIME ltime; - if (get_arg0_date(<ime, TIME_NO_ZERO_DATE)) + if (get_arg0_date(<ime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE)) return 0; return (longlong) calc_week(<ime, week_mode((uint) args[1]->val_int()), @@ -1058,7 +1058,7 @@ longlong Item_func_yearweek::val_int() DBUG_ASSERT(fixed == 1); uint year,week; MYSQL_TIME ltime; - if (get_arg0_date(<ime, TIME_NO_ZERO_DATE)) + if (get_arg0_date(<ime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE)) return 0; week= calc_week(<ime, (week_mode((uint) args[1]->val_int()) | WEEK_YEAR), @@ -1072,7 +1072,7 @@ longlong Item_func_weekday::val_int() DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - if (get_arg0_date(<ime, TIME_NO_ZERO_DATE)) + if (get_arg0_date(<ime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE)) return 0; return (longlong) calc_weekday(calc_daynr(ltime.year, ltime.month, @@ -1114,7 +1114,7 @@ longlong Item_func_year::val_int() { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - return get_arg0_date(<ime, TIME_FUZZY_DATE) ? 0 : (longlong) ltime.year; + return get_arg0_date(<ime, 0) ? 0 : (longlong) ltime.year; } @@ -1146,7 +1146,7 @@ longlong Item_func_year::val_int_endpoint(bool left_endp, bool *incl_endp) { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - if (get_arg0_date(<ime, TIME_FUZZY_DATE)) + if (get_arg0_date(<ime, 0)) { /* got NULL, leave the incl_endp intact */ return LONGLONG_MIN; @@ -1467,7 +1467,7 @@ longlong Item_temporal_func::val_int() { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - if (get_date(<ime, TIME_FUZZY_DATE | sql_mode)) + if (get_date(<ime, sql_mode)) return 0; longlong v= TIME_to_ulonglong(<ime); return ltime.neg ? -v : v; @@ -1478,7 +1478,7 @@ double Item_temporal_func::val_real() { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - if (get_date(<ime, TIME_FUZZY_DATE | sql_mode)) + if (get_date(<ime, sql_mode)) return 0; return TIME_to_double(<ime); } @@ -1858,7 +1858,7 @@ String *Item_func_date_format::val_str(String *str) int is_time_flag = is_time_format ? TIME_TIME_ONLY : 0; DBUG_ASSERT(fixed == 1); - if (get_arg0_date(&l_time, TIME_FUZZY_DATE | is_time_flag)) + if (get_arg0_date(&l_time, is_time_flag)) return 0; if (!(format = args[1]->val_str(str)) || !format->length()) @@ -2032,10 +2032,15 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) { INTERVAL interval; - if (args[0]->get_date(ltime, TIME_NO_ZERO_DATE | TIME_FUZZY_DATE | TIME_NO_ZERO_IN_DATE) || + if (args[0]->get_date(ltime, 0) || get_interval_value(args[1], int_type, &interval)) return (null_value=1); + if (ltime->time_type != MYSQL_TIMESTAMP_TIME && + check_date_with_warn(ltime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE, + MYSQL_TIMESTAMP_ERROR)) + return (null_value=1); + if (date_sub_interval) interval.neg = !interval.neg; @@ -2128,7 +2133,7 @@ longlong Item_extract::val_int() long neg; int is_time_flag = date_value ? 0 : TIME_TIME_ONLY; - if (get_arg0_date(<ime, TIME_FUZZY_DATE | is_time_flag)) + if (get_arg0_date(<ime, is_time_flag)) return 0; neg= ltime.neg ? -1 : 1; @@ -2553,7 +2558,7 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) if (is_date) // TIMESTAMP function { - if (get_arg0_date(&l_time1, TIME_FUZZY_DATE) || + if (get_arg0_date(&l_time1, 0) || args[1]->get_time(&l_time2) || l_time1.time_type == MYSQL_TIMESTAMP_TIME || l_time2.time_type != MYSQL_TIMESTAMP_TIME) diff --git a/sql/sql_time.cc b/sql/sql_time.cc index 82e8898657d..dab8a907678 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -332,7 +332,7 @@ str_to_datetime_with_warn(CHARSET_INFO *cs, @param nr integer part of the number to convert @param sec_part microsecond part of the number @param ltime converted value will be written here - @param fuzzydate conversion flags (TIME_FUZZY_DATE, etc) + @param fuzzydate conversion flags (TIME_INVALID_DATE, etc) @param str original number, as an ErrConv. For the warning @param field_name field name or NULL if not a field. For the warning @@ -349,6 +349,7 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part, if (fuzzydate & TIME_TIME_ONLY) { + fuzzydate= TIME_TIME_ONLY; // clear other flags f_type= MYSQL_TYPE_TIME; res= number_to_time(neg, nr, sec_part, ltime, &was_cut); } @@ -358,7 +359,7 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part, res= neg ? -1 : number_to_datetime(nr, sec_part, ltime, fuzzydate, &was_cut); } - if (res < 0 || (was_cut && !(fuzzydate & TIME_FUZZY_DATE))) + if (res < 0 || (was_cut && (fuzzydate & TIME_NO_ZERO_IN_DATE))) { make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, str, |