#At file:///data0/martin/bzr/bug54568/5.1bt-commit/ based on revid:sergey.glukhov@stripped
3455 Martin Hansson 2010-06-30
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 view preparation. Unfortunately
the LIKE predicate pre-evaluates constant right-hand side arguments even
during name resolution within view preparation. 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-06-30 15:27:20 +0000
@@ -59,3 +59,23 @@ 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 ) );
+DROP VIEW v1;
+#
+# 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-06-30 15:27:20 +0000
@@ -62,3 +62,17 @@ 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 ) );
+DROP VIEW v1;
+
+--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-06-30 15:27:20 +0000
@@ -4660,9 +4660,14 @@ bool Item_func_like::fix_fields(THD *thd
/*
We could also do boyer-more for non-const items, but as we would have to
recompute the tables for each row it's not worth it.
+
+ We don't pre-evaluate constant items during view preparation as the Item
+ tree may not be ready to execute at this point. Item_in_subselect's have
+ not yet been wrapped inside Item_in_optimizer objects.
*/
if (args[1]->const_item() && !use_strnxfrm(collation.collation) &&
- !(specialflag & SPECIAL_NO_NEW_FUNC))
+ !(specialflag & SPECIAL_NO_NEW_FUNC) &&
+ !thd->lex->view_prepare_mode)
{
String* res2 = args[1]->val_str(&cmp.value2);
if (!res2)
Attachment: [text/bzr-bundle] bzr/martin.hansson@oracle.com-20100630152720-3bh1u8bvcly01al1.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (martin.hansson:3455) Bug#54568 | Martin Hansson | 30 Jun |