diff options
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/sql/item.cc b/sql/item.cc index e47974408f4..7cdb2d2e7e4 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1259,6 +1259,22 @@ err: if allowed, otherwise - null. */ bzero((char*) ltime,sizeof(*ltime)); + if (fuzzydate & TIME_TIME_ONLY) + { + /* + In the following scenario: + - The caller expected to get a TIME value + - Item returned a not NULL string or numeric value + - But then conversion from string or number to TIME failed + we need to change the default time_type from MYSQL_TIMESTAMP_DATE + (which was set in bzero) to MYSQL_TIMESTAMP_TIME and therefore + return TIME'00:00:00' rather than DATE'0000-00-00'. + If we don't do this, methods like Item::get_time_with_conversion() + will erroneously subtract CURRENT_DATE from '0000-00-00 00:00:00' + and return TIME'-838:59:59' instead of TIME'00:00:00' as a result. + */ + ltime->time_type= MYSQL_TIMESTAMP_TIME; + } return null_value|= !(fuzzydate & TIME_FUZZY_DATES); } @@ -4565,7 +4581,7 @@ bool is_outer_table(TABLE_LIST *table, SELECT_LEX *select) @retval 0 column fully fixed and fix_fields() should return FALSE @retval - -1 error occured + -1 error occurred */ int @@ -5437,8 +5453,7 @@ String_copier_for_item::copy_with_warn(CHARSET_INFO *dstcs, String *dst, if (const char *pos= cannot_convert_error_pos()) { char buf[16]; - int mblen= srccs->cset->charlen(srccs, (const uchar *) pos, - (const uchar *) src + src_length); + int mblen= my_charlen(srccs, pos, src + src_length); DBUG_ASSERT(mblen > 0 && mblen * 2 + 1 <= (int) sizeof(buf)); octet2hex(buf, pos, mblen); push_warning_printf(m_thd, Sql_condition::WARN_LEVEL_WARN, @@ -6389,6 +6404,7 @@ bool Item::cache_const_expr_analyzer(uchar **arg) !(basic_const_item() || item->basic_const_item() || item->type() == Item::FIELD_ITEM || item->type() == SUBSELECT_ITEM || + item->type() == CACHE_ITEM || /* Do not cache GET_USER_VAR() function as its const_item() may return TRUE for the current thread but it still may change @@ -6486,7 +6502,7 @@ void Item_field::update_null_value() UPDATE statement. RETURN - 0 if error occured + 0 if error occurred ref if all conditions are met this field otherwise */ |