Commit 113333d4 authored by unknown's avatar unknown

MDEV-6046: MySQL Bug#11766684 59851: UNINITIALISED VALUE IN...

MDEV-6046: MySQL Bug#11766684 59851: UNINITIALISED VALUE IN ITEM_FUNC_LIKE::SELECT_OPTIMIZE WITH SUBQUERY AND
parent 67bf16a4
...@@ -2658,6 +2658,17 @@ group_concat( i ) field ...@@ -2658,6 +2658,17 @@ group_concat( i ) field
NULL NULL NULL NULL
8 8
drop table t1; drop table t1;
#
# Bug#11766684 59851: UNINITIALISED VALUE IN ITEM_FUNC_LIKE::SELECT_OPTIMIZE WITH SUBQUERY AND
#
CREATE TABLE t2(a INT, KEY(a));
INSERT INTO t2 VALUES (1),(2);
CREATE TABLE t1(b INT, PRIMARY KEY(b));
INSERT INTO t1 VALUES (0),(254);
SELECT 1 FROM t2 WHERE a LIKE
(SELECT EXPORT_SET(1, b, b, b, b) FROM t1 LIMIT 1);
1
DROP TABLE t1, t2;
End of 5.1 tests End of 5.1 tests
# #
# Start of 5.3 tests # Start of 5.3 tests
......
...@@ -1407,6 +1407,18 @@ insert into t1 values (null),(8); ...@@ -1407,6 +1407,18 @@ insert into t1 values (null),(8);
select group_concat( i ), make_set( i, 'a', 'b' ) field from t1 group by field; select group_concat( i ), make_set( i, 'a', 'b' ) field from t1 group by field;
drop table t1; drop table t1;
--echo #
--echo # Bug#11766684 59851: UNINITIALISED VALUE IN ITEM_FUNC_LIKE::SELECT_OPTIMIZE WITH SUBQUERY AND
--echo #
CREATE TABLE t2(a INT, KEY(a));
INSERT INTO t2 VALUES (1),(2);
CREATE TABLE t1(b INT, PRIMARY KEY(b));
INSERT INTO t1 VALUES (0),(254);
SELECT 1 FROM t2 WHERE a LIKE
(SELECT EXPORT_SET(1, b, b, b, b) FROM t1 LIMIT 1);
DROP TABLE t1, t2;
--echo End of 5.1 tests --echo End of 5.1 tests
--echo # --echo #
......
...@@ -4896,21 +4896,20 @@ longlong Item_func_like::val_int() ...@@ -4896,21 +4896,20 @@ longlong Item_func_like::val_int()
Item_func::optimize_type Item_func_like::select_optimize() const Item_func::optimize_type Item_func_like::select_optimize() const
{ {
if (args[1]->const_item() && !args[1]->is_expensive()) if (!args[1]->const_item() || args[1]->is_expensive())
{ return OPTIMIZE_NONE;
String* res2= args[1]->val_str((String *)&cmp.value2);
const char *ptr2;
if (!res2 || !(ptr2= res2->ptr())) String* res2= args[1]->val_str((String *)&cmp.value2);
return OPTIMIZE_NONE; if (!res2)
return OPTIMIZE_NONE;
if (*ptr2 != wild_many) if (!res2->length()) // Can optimize empty wildcard: column LIKE ''
{ return OPTIMIZE_OP;
if (args[0]->result_type() != STRING_RESULT || *ptr2 != wild_one)
return OPTIMIZE_OP; DBUG_ASSERT(res2->ptr());
} char first= res2->ptr()[0];
} return (first == wild_many || first == wild_one) ?
return OPTIMIZE_NONE; OPTIMIZE_NONE : OPTIMIZE_OP;
} }
......
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