Commit 23d4c95b authored by Alexander Barkov's avatar Alexander Barkov

MDEV-8896 Dead code in stored_field_cmp_to_item()

parent 93371739
......@@ -8618,26 +8618,6 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
if (item->null_value)
return 0;
String *field_result= field->val_str(&field_tmp);
enum_field_types field_type= field->type();
if (field_type == MYSQL_TYPE_DATE || field_type == MYSQL_TYPE_DATETIME ||
field_type == MYSQL_TYPE_TIMESTAMP)
{
enum_mysql_timestamp_type type= MYSQL_TIMESTAMP_ERROR;
if (field_type == MYSQL_TYPE_DATE)
type= MYSQL_TIMESTAMP_DATE;
else
type= MYSQL_TIMESTAMP_DATETIME;
const char *field_name= field->field_name;
MYSQL_TIME field_time, item_time;
get_mysql_time_from_str(thd, field_result, type, field_name, &field_time);
get_mysql_time_from_str(thd, item_result, type, field_name, &item_time);
return my_time_compare(&field_time, &item_time);
}
return sortcmp(field_result, item_result, field->charset());
}
if (res_type == INT_RESULT)
......
......@@ -596,64 +596,6 @@ int Arg_comparator::set_compare_func(Item_func_or_sum *item, Item_result type)
return 0;
}
/**
Parse date provided in a string to a MYSQL_TIME.
@param[in] thd Thread handle
@param[in] str A string to convert
@param[in] warn_type Type of the timestamp for issuing the warning
@param[in] warn_name Field name for issuing the warning
@param[out] l_time The MYSQL_TIME objects is initialized.
Parses a date provided in the string str into a MYSQL_TIME object.
The date is used for comparison, that is fuzzy dates are allowed
independently of sql_mode.
If the string contains an incorrect date or doesn't correspond to a date at
all then a warning is issued. The warn_type and the warn_name arguments are
used as the name and the type of the field when issuing the warning. If any
input was discarded (trailing or non-timestamp-y characters), return value
will be TRUE.
@return Status flag
@retval FALSE Success.
@retval True Indicates failure.
*/
bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
const char *warn_name, MYSQL_TIME *l_time)
{
bool value;
MYSQL_TIME_STATUS status;
int flags= TIME_FUZZY_DATES | MODE_INVALID_DATES;
ErrConvString err(str);
DBUG_ASSERT(warn_type != MYSQL_TIMESTAMP_TIME);
if (!str_to_datetime(str->charset(), str->ptr(), str->length(),
l_time, flags, &status))
{
DBUG_ASSERT(l_time->time_type == MYSQL_TIMESTAMP_DATETIME ||
l_time->time_type == MYSQL_TIMESTAMP_DATE);
/*
Do not return yet, we may still want to throw a "trailing garbage"
warning.
*/
value= FALSE;
}
else
{
DBUG_ASSERT(l_time->time_type != MYSQL_TIMESTAMP_TIME);
DBUG_ASSERT(status.warnings != 0); // Must be set by set_to_datetime()
value= TRUE;
}
if (status.warnings > 0)
make_truncated_value_warning(thd, Sql_condition::WARN_LEVEL_WARN,
&err, warn_type, warn_name);
return value;
}
/**
Prepare the comparator (set the comparison function) for comparing
......
......@@ -2393,10 +2393,6 @@ longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
enum_field_types f_type, bool *is_null);
bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
const char *warn_name, MYSQL_TIME *l_time);
class Comp_creator
{
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment