Commit 9d884fd3 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-8599 "WHERE varchar_field LIKE temporal_const" does not use range optimizer

parent 6e091dc7
......@@ -227,5 +227,30 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 10.0) and (`test`.`t1`.`a` like 10.00))
DROP TABLE t1;
#
# MDEV-8599 "WHERE varchar_field LIKE temporal_const" does not use range optimizer
#
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1, KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('00:00:00');
INSERT INTO t1 VALUES ('00:00:01');
INSERT INTO t1 VALUES ('00:00:02');
INSERT INTO t1 VALUES ('00:00:03');
INSERT INTO t1 VALUES ('00:00:04');
INSERT INTO t1 VALUES ('00:00:05');
INSERT INTO t1 VALUES ('00:00:06');
INSERT INTO t1 VALUES ('00:00:07');
EXPLAIN SELECT * FROM t1 WHERE a LIKE '00:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 13 NULL 1 Using where; Using index
EXPLAIN SELECT * FROM t1 WHERE a LIKE TIME'00:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 13 NULL 1 Using where; Using index
SELECT * FROM t1 WHERE a LIKE '00:00:00';
a
00:00:00
SELECT * FROM t1 WHERE a LIKE TIME'00:00:00';
a
00:00:00
DROP TABLE t1;
#
# End of 10.1 tests
#
......@@ -163,6 +163,25 @@ SELECT * FROM t1 WHERE a=10.0 AND a LIKE 10.00;
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=10.0 AND a LIKE 10.00;
DROP TABLE t1;
--echo #
--echo # MDEV-8599 "WHERE varchar_field LIKE temporal_const" does not use range optimizer
--echo #
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1, KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('00:00:00');
INSERT INTO t1 VALUES ('00:00:01');
INSERT INTO t1 VALUES ('00:00:02');
INSERT INTO t1 VALUES ('00:00:03');
INSERT INTO t1 VALUES ('00:00:04');
INSERT INTO t1 VALUES ('00:00:05');
INSERT INTO t1 VALUES ('00:00:06');
INSERT INTO t1 VALUES ('00:00:07');
EXPLAIN SELECT * FROM t1 WHERE a LIKE '00:00:00';
EXPLAIN SELECT * FROM t1 WHERE a LIKE TIME'00:00:00';
SELECT * FROM t1 WHERE a LIKE '00:00:00';
SELECT * FROM t1 WHERE a LIKE TIME'00:00:00';
DROP TABLE t1;
--echo #
--echo # End of 10.1 tests
--echo #
......@@ -120,6 +120,10 @@ public:
friend class Item_func;
};
class SEL_ARG;
struct KEY_PART;
class Item_bool_func :public Item_int_func
{
protected:
......@@ -147,6 +151,9 @@ protected:
SEL_TREE *get_ne_mm_tree(RANGE_OPT_PARAM *param,
Field *field, Item *lt_value, Item *gt_value,
Item_result cmp_type);
virtual SEL_ARG *get_mm_leaf(RANGE_OPT_PARAM *param, Field *field,
KEY_PART *key_part,
Item_func::Functype type, Item *value);
public:
Item_bool_func() :Item_int_func() {}
Item_bool_func(Item *a) :Item_int_func(a) {}
......@@ -1437,6 +1444,9 @@ protected:
DBUG_ENTER("Item_func_null_predicate::get_func_mm_tree");
DBUG_RETURN(get_mm_parts(param, field, functype(), value, cmp_type));
}
SEL_ARG *get_mm_leaf(RANGE_OPT_PARAM *param, Field *field,
KEY_PART *key_part,
Item_func::Functype type, Item *value);
public:
Item_func_null_predicate(Item *a) :Item_bool_func(a) { }
void add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
......@@ -1552,6 +1562,10 @@ class Item_func_like :public Item_bool_func2
DTCollation cmp_collation;
String cmp_value1, cmp_value2;
bool with_sargable_pattern() const;
protected:
SEL_ARG *get_mm_leaf(RANGE_OPT_PARAM *param, Field *field,
KEY_PART *key_part,
Item_func::Functype type, Item *value);
public:
int escape;
......
This diff is collapsed.
......@@ -38,7 +38,7 @@
class JOIN;
class Item_sum;
typedef struct st_key_part {
struct KEY_PART {
uint16 key,part;
/* See KEY_PART_INFO for meaning of the next two: */
uint16 store_length, length;
......@@ -50,7 +50,7 @@ typedef struct st_key_part {
uint8 flag;
Field *field;
Field::imagetype image_type;
} KEY_PART;
};
class Explain_quick_select;
/*
......
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