summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 910a4faa24d..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
@@ -6388,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
@@ -6485,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
*/