[Commits] Rev 3484: fix of MDEV-3881: The problem was in unwrapping view/subquery-in-the-FROM-clase fields in substitution. in file:///home/bell/maria/bzr/work-maria-10.0-exists2in/

sanja at montyprogram.com sanja at montyprogram.com
Thu Nov 29 12:04:37 EET 2012


At file:///home/bell/maria/bzr/work-maria-10.0-exists2in/

------------------------------------------------------------
revno: 3484
revision-id: sanja at montyprogram.com-20121129100434-4cvzueaobqhlgk16
parent: sanja at montyprogram.com-20121127121216-23x72tjff11skij3
committer: sanja at montyprogram.com
branch nick: work-maria-10.0-exists2in
timestamp: Thu 2012-11-29 12:04:34 +0200
message:
  fix of MDEV-3881: The problem was in unwrapping view/subquery-in-the-FROM-clase fields in substitution.
-------------- next part --------------
=== modified file 'mysql-test/r/subselect_exists2in.result'
--- a/mysql-test/r/subselect_exists2in.result	2012-11-27 12:12:16 +0000
+++ b/mysql-test/r/subselect_exists2in.result	2012-11-29 10:04:34 +0000
@@ -742,4 +742,30 @@ WHERE NOT EXISTS ( SELECT * FROM t2 WHER
 a1	b1
 6	w
 drop table t1, t2;
+#
+# MDEV-3881: Endless loop and crash in Item_ref::real_item with
+# exists_to_in=on, NOT EXISTS subquery, merge view or from subquery,
+# constant table
+#
+SET optimizer_switch = 'exists_to_in=on';
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(7);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (8);
+CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t2;
+CREATE TABLE t3 (c INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (4),(6);
+SELECT * FROM t1, v1 WHERE NOT EXISTS ( SELECT * FROM t3 WHERE c = b ) AND a = b;
+a	b
+drop view v1;
+drop table t1, t2, t3;
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(7);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (8);
+CREATE TABLE t3 (c INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (4),(6);
+SELECT * FROM t1, ( SELECT * FROM t2 ) alias WHERE NOT EXISTS ( SELECT * FROM t3 WHERE c = b ) AND a = b;
+a	b
+drop table t1, t2, t3;
 set optimizer_switch=default;

=== modified file 'mysql-test/t/subselect_exists2in.test'
--- a/mysql-test/t/subselect_exists2in.test	2012-11-27 12:12:16 +0000
+++ b/mysql-test/t/subselect_exists2in.test	2012-11-29 10:04:34 +0000
@@ -585,6 +585,42 @@ WHERE NOT EXISTS ( SELECT * FROM t2 WHER
 
 drop table t1, t2;
 
+--echo #
+--echo # MDEV-3881: Endless loop and crash in Item_ref::real_item with
+--echo # exists_to_in=on, NOT EXISTS subquery, merge view or from subquery,
+--echo # constant table
+--echo #
+SET optimizer_switch = 'exists_to_in=on';
+
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(7);
+
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (8);
+CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t2;
+
+CREATE TABLE t3 (c INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (4),(6);
+
+SELECT * FROM t1, v1 WHERE NOT EXISTS ( SELECT * FROM t3 WHERE c = b ) AND a = b;
+
+drop view v1;
+drop table t1, t2, t3;
+
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(7);
+
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (8);
+
+CREATE TABLE t3 (c INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (4),(6);
+
+SELECT * FROM t1, ( SELECT * FROM t2 ) alias WHERE NOT EXISTS ( SELECT * FROM t3 WHERE c = b ) AND a = b;
+
+drop table t1, t2, t3;
+
+
 
 #restore defaults
 set optimizer_switch=default;

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2012-11-27 12:12:16 +0000
+++ b/sql/item_subselect.cc	2012-11-29 10:04:34 +0000
@@ -2571,16 +2571,16 @@ static bool check_equality_for_exist2in(
       args[0]->all_used_tables() != OUTER_REF_TABLE_BIT &&
       args[1]->all_used_tables() == OUTER_REF_TABLE_BIT)
   {
-    *local_field= (Item_field *)args[0]->real_item();
-    *outer_exp= args[1]->real_item();
+    *local_field= (Item_field *)args[0];//->real_item();
+    *outer_exp= args[1];//->real_item();
     return TRUE;
   }
   else if (args[1]->real_type() == Item::FIELD_ITEM &&
            args[1]->all_used_tables() != OUTER_REF_TABLE_BIT &&
            args[0]->all_used_tables() == OUTER_REF_TABLE_BIT)
   {
-    *local_field= (Item_field *)args[1]->real_item();
-    *outer_exp= args[0]->real_item();
+    *local_field= (Item_field *)args[1];//->real_item();
+    *outer_exp= args[0];//->real_item();
     return TRUE;
   }
 



More information about the commits mailing list