mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
cleanup: remove get_datetime_value()
this is a 10.3 version of 27d94b7e03
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.
This commit is contained in:
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user