mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fix bug #14093 Query takes a lot of time when date format is not valid
Invalid date like 2000-02-32 wasn't converted to int, which lead to not using index and comparison with field as astring, which results in slow query execution. convert_constatn_item() and get_mm_leaf() now forces MODE_INVALID_DATES to allow such conversion.
This commit is contained in:
@ -186,13 +186,18 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
|
||||
{
|
||||
if ((*item)->const_item())
|
||||
{
|
||||
/* For comparison purposes allow invalid dates like 2000-01-32 */
|
||||
ulong orig_sql_mode= field->table->in_use->variables.sql_mode;
|
||||
field->table->in_use->variables.sql_mode|= MODE_INVALID_DATES;
|
||||
if (!(*item)->save_in_field(field, 1) && !((*item)->null_value))
|
||||
{
|
||||
Item *tmp=new Item_int_with_ref(field->val_int(), *item);
|
||||
field->table->in_use->variables.sql_mode= orig_sql_mode;
|
||||
if (tmp)
|
||||
thd->change_item_tree(item, tmp);
|
||||
return 1; // Item was replaced
|
||||
}
|
||||
field->table->in_use->variables.sql_mode= orig_sql_mode;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user