diff options
author | unknown <gkodinov/kgeorge@magare.gmz> | 2007-10-18 15:19:04 +0300 |
---|---|---|
committer | unknown <gkodinov/kgeorge@magare.gmz> | 2007-10-18 15:19:04 +0300 |
commit | 787a4b487ade01ba487da1c6db0e90f02434ac99 (patch) | |
tree | 9352ef29cde72ad44d19db97027cbdbea40ea30c /sql/field.cc | |
parent | 9bb3c7ebdd1a4b2d2cbe08917402af40b0f998a8 (diff) | |
download | mariadb-git-787a4b487ade01ba487da1c6db0e90f02434ac99.tar.gz |
Bug #31221: Optimizer incorrectly identifies impossible WHERE clause
No warning was generated when a TIMESTAMP with a non-zero time part
was converted to a DATE value. This caused index lookup to assume
that this is a valid conversion and was returning rows that match
a comparison between a TIMESTAMP value and a DATE keypart.
Fixed by generating a warning on such a truncation.
mysql-test/r/derived.result:
Bug #31221: fixed an existing not-precise test case
mysql-test/r/ps_2myisam.result:
Bug #31221: Warnings cased by existing tests
mysql-test/r/ps_3innodb.result:
Bug #31221: Warnings cased by existing tests
mysql-test/r/ps_4heap.result:
Bug #31221: Warnings cased by existing tests
mysql-test/r/ps_5merge.result:
Bug #31221: Warnings cased by existing tests
mysql-test/r/ps_6bdb.result:
Bug #31221: Warnings cased by existing tests
mysql-test/r/ps_7ndb.result:
Bug #31221: Warnings cased by existing tests
mysql-test/r/type_date.result:
Bug #31221: Warnings cased by existing tests
mysql-test/r/type_datetime.result:
Bug #31221: test case
mysql-test/t/derived.test:
Bug #31221: fixed an existing not-precise test case
mysql-test/t/type_date.test:
Bug #31221: test case
sql/field.cc:
Bug #31221:
- Upgraded fix for bug 29729
- issue a warning only if the hh:mm:ss.msec is not zero consistently
for all the Field_newdate::store function
sql/item_timefunc.cc:
Bug #31221: don't ignore the errors when storing data
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/sql/field.cc b/sql/field.cc index e6e4195ba1e..c616f3f8588 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5282,7 +5282,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) { tmp= l_time.day + l_time.month*32 + l_time.year*16*32; if (!error && (ret != MYSQL_TIMESTAMP_DATE) && - thd->count_cuted_fields != CHECK_FIELD_IGNORE) + (l_time.hour || l_time.minute || l_time.second || l_time.second_part)) error= 3; // Datetime was cut (note) } @@ -5329,10 +5329,16 @@ int Field_newdate::store(longlong nr, bool unsigned_val) else tmp= l_time.day + l_time.month*32 + l_time.year*16*32; + if (!error && l_time.time_type != MYSQL_TIMESTAMP_DATE && + (l_time.hour || l_time.minute || l_time.second || l_time.second_part)) + error= 3; + if (error) - set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - error == 2 ? ER_WARN_DATA_OUT_OF_RANGE : - WARN_DATA_TRUNCATED,nr,MYSQL_TIMESTAMP_DATE, 1); + set_datetime_warning(error == 3 ? MYSQL_ERROR::WARN_LEVEL_NOTE : + MYSQL_ERROR::WARN_LEVEL_WARN, + error == 2 ? + ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED, + nr,MYSQL_TIMESTAMP_DATE, 1); int3store(ptr,tmp); return error; @@ -5359,6 +5365,17 @@ int Field_newdate::store_time(MYSQL_TIME *ltime, timestamp_type time_type) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1); } + if (!error && ltime->time_type != MYSQL_TIMESTAMP_DATE && + (ltime->hour || ltime->minute || ltime->second || ltime->second_part)) + { + char buff[MAX_DATE_STRING_REP_LENGTH]; + String str(buff, sizeof(buff), &my_charset_latin1); + make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str); + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, + WARN_DATA_TRUNCATED, + str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1); + error= 3; + } } else { |