summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-03-29 09:05:24 +0200
committerSergei Golubchik <serg@mariadb.org>2018-03-30 09:45:05 +0200
commit17bbab5fb0ef9c55f2cec9f5ba79bb75dda4631a (patch)
tree8247885ad6120542a2538852cd9a3c3b1deb71ef
parentc43a0e0a77246585fd99961110fbd9570acebf9b (diff)
downloadmariadb-git-17bbab5fb0ef9c55f2cec9f5ba79bb75dda4631a.tar.gz
cleanup: remove get_datetime_value()
this is a 10.3 version of 27d94b7e032 It disables caching of the first argument of IN, if it's of a temporal type. Because other types are not cached in this context.
-rw-r--r--mysql-test/main/case.result4
-rw-r--r--sql/item_cmpfunc.cc64
-rw-r--r--sql/item_cmpfunc.h9
3 files changed, 8 insertions, 69 deletions
diff --git a/mysql-test/main/case.result b/mysql-test/main/case.result
index f385a3b20c7..1fd1ad86a8e 100644
--- a/mysql-test/main/case.result
+++ b/mysql-test/main/case.result
@@ -422,6 +422,8 @@ ok
ok
Warnings:
Warning 1292 Truncated incorrect time value: 'foo'
+Warning 1292 Truncated incorrect time value: 'foo'
+Warning 1292 Truncated incorrect time value: 'foo'
select 'foo' in (a,'0') from t1;
'foo' in (a,'0')
0
@@ -429,6 +431,8 @@ select 'foo' in (a,'0') from t1;
0
Warnings:
Warning 1292 Truncated incorrect time value: 'foo'
+Warning 1292 Truncated incorrect time value: 'foo'
+Warning 1292 Truncated incorrect time value: 'foo'
drop table t1;
select case '20:10:05' when date'2020-10-10' then 'never' when time'20:10:5' then 'ok' else 'bug' end;
case '20:10:05' when date'2020-10-10' then 'never' when time'20:10:5' then 'ok' else 'bug' end
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 9bc40bd429f..ba503f18855 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -707,62 +707,6 @@ Item** Arg_comparator::cache_converted_constant(THD *thd_arg, Item **value,
}
-/**
- Retrieves correct DATETIME value from given item.
-
- @param[in] thd thread handle
- @param[in,out] item_arg item to retrieve DATETIME value from
- @param[in,out] cache_arg pointer to place to store the caching item to
- @param[in] warn_item item for issuing the conversion warning
- @param[out] is_null TRUE <=> the item_arg is null
-
- @details
- Retrieves the correct DATETIME value from given item for comparison by the
- compare_datetime() function.
-
- If the value should be compared as time (TIME_RESULT), it's retrieved as
- MYSQL_TIME. Otherwise it's read as a number/string and converted to time.
- Constant items are cached, so the convertion is only done once for them.
-
- Note the f_type behavior: if the item can be compared as time, then
- f_type is this item's field_type(). Otherwise it's field_type() of
- warn_item (which is the other operand of the comparison operator).
- This logic provides correct string/number to date/time conversion
- depending on the other operand (when comparing a string with a date, it's
- parsed as a date, when comparing a string with a time it's parsed as a time)
-
- If the item is a constant it is replaced by the Item_cache_int, that
- holds the packed datetime value.
-
- @return
- MYSQL_TIME value, packed in a longlong, suitable for comparison.
-*/
-
-longlong
-get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
- enum_field_types f_type, bool *is_null)
-{
- longlong UNINIT_VAR(value);
- Item *item= **item_arg;
- value= item->val_temporal_packed(f_type);
- if ((*is_null= item->null_value))
- return ~(ulonglong) 0;
- if (cache_arg && item->const_item() &&
- !(item->type() == Item::CACHE_ITEM && item->cmp_type() == TIME_RESULT))
- {
- if (!thd)
- thd= current_thd;
- const Type_handler *h= Type_handler::get_handler_by_field_type(f_type);
- Item_cache *tmp_cache= h->Item_get_cache(thd, item);
- Item_cache_temporal *cache= static_cast<Item_cache_temporal*>(tmp_cache);
- cache->store_packed(value, item);
- *cache_arg= cache;
- *item_arg= cache_arg;
- }
- return value;
-}
-
-
int Arg_comparator::compare_time()
{
longlong val1= (*a)->val_time_packed();
@@ -3710,9 +3654,7 @@ void in_time::set(uint pos,Item *item)
uchar *in_temporal::get_value_internal(Item *item, enum_field_types f_type)
{
- bool is_null;
- Item **tmp_item= lval_cache ? &lval_cache : &item;
- tmp.val= get_datetime_value(0, &tmp_item, &lval_cache, f_type, &is_null);
+ tmp.val= item->val_temporal_packed(f_type);
if (item->null_value)
return 0;
tmp.unsigned_flag= 1L;
@@ -4071,9 +4013,7 @@ cmp_item* cmp_item_decimal::make_same()
void cmp_item_temporal::store_value_internal(Item *item,
enum_field_types f_type)
{
- bool is_null;
- Item **tmp_item= lval_cache ? &lval_cache : &item;
- value= get_datetime_value(0, &tmp_item, &lval_cache, f_type, &is_null);
+ value= item->val_temporal_packed(f_type);
m_null_value= item->null_value;
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index d10bac0fced..30d682f05aa 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1404,10 +1404,9 @@ protected:
uchar *get_value_internal(Item *item, enum_field_types f_type);
public:
/* Cache for the left item. */
- Item *lval_cache;
in_temporal(THD *thd, uint elements)
- :in_longlong(thd, elements), lval_cache(0) {};
+ :in_longlong(thd, elements) {};
Item *create_item(THD *thd);
void value_to_item(uint pos, Item *item)
{
@@ -1615,11 +1614,7 @@ protected:
longlong value;
void store_value_internal(Item *item, enum_field_types type);
public:
- /* Cache for the left item. */
- Item *lval_cache;
-
- cmp_item_temporal()
- :lval_cache(0) {}
+ cmp_item_temporal() {}
int compare(cmp_item *ci);
};