#At file:///data0/martin/bzr/bug54568/5.1bt-commit/ based on revid:alexey.kopytov@stripped
3456 Martin Hansson 2010-07-02
Bug#54568: create view cause Assertion failed: 0,
file .\item_subselect.cc, line 836
IN quantified predicates are never executed directly. They are rather wrapped
inside nodes called IN Optimizers (Item_in_optimizer) which take care of the
execution. However, this is not done during query preparation. Unfortunately
the LIKE predicate pre-evaluates constant right-hand side arguments even
during name resolution. Likely this is meant as an optimization.
Fixed by not pre-evaluating LIKE arguments in view prepare mode.
modified:
mysql-test/r/subselect4.result
mysql-test/t/subselect4.test
sql/item_cmpfunc.cc
=== modified file 'mysql-test/r/subselect4.result'
--- a/mysql-test/r/subselect4.result 2009-09-28 13:48:40 +0000
+++ b/mysql-test/r/subselect4.result 2010-07-02 08:59:51 +0000
@@ -59,3 +59,24 @@ FROM t3 WHERE 1 = 0 GROUP BY 1;
(SELECT 1 FROM t1,t2 WHERE t2.b > t3.b)
DROP TABLE t1,t2,t3;
End of 5.0 tests.
+#
+# Bug#54568: create view cause Assertion failed: 0,
+# file .\item_subselect.cc, line 836
+#
+EXPLAIN SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+DESCRIBE SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+# Should not crash
+CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
+CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) );
+DROP VIEW v1, v2;
+#
+# End of 5.1 tests.
+#
=== modified file 'mysql-test/t/subselect4.test'
--- a/mysql-test/t/subselect4.test 2009-09-18 09:34:08 +0000
+++ b/mysql-test/t/subselect4.test 2010-07-02 08:59:51 +0000
@@ -62,3 +62,18 @@ FROM t3 WHERE 1 = 0 GROUP BY 1;
DROP TABLE t1,t2,t3;
--echo End of 5.0 tests.
+
+--echo #
+--echo # Bug#54568: create view cause Assertion failed: 0,
+--echo # file .\item_subselect.cc, line 836
+--echo #
+EXPLAIN SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
+DESCRIBE SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
+--echo # Should not crash
+CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
+CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) );
+DROP VIEW v1, v2;
+
+--echo #
+--echo # End of 5.1 tests.
+--echo #
=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc 2010-06-24 11:26:14 +0000
+++ b/sql/item_cmpfunc.cc 2010-07-02 08:59:51 +0000
@@ -4606,7 +4606,7 @@ bool Item_func_like::fix_fields(THD *thd
return TRUE;
}
- if (escape_item->const_item())
+ if (escape_item->const_item() && !thd->is_context_analysis_only())
{
/* If we are on execution stage */
String *escape_str= escape_item->val_str(&cmp.value1);
@@ -4662,7 +4662,8 @@ bool Item_func_like::fix_fields(THD *thd
recompute the tables for each row it's not worth it.
*/
if (args[1]->const_item() && !use_strnxfrm(collation.collation) &&
- !(specialflag & SPECIAL_NO_NEW_FUNC))
+ !(specialflag & SPECIAL_NO_NEW_FUNC) &&
+ !thd->is_context_analysis_only())
{
String* res2 = args[1]->val_str(&cmp.value2);
if (!res2)
Attachment: [text/bzr-bundle] bzr/martin.hansson@oracle.com-20100702085951-6pegjfx7bnfzip5p.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (martin.hansson:3456) Bug#54568 | Martin Hansson | 2 Jul |