[Commits] Rev 3398: BUG#922254: Assertion `0' failed at item_cmpfunc.cc:5899: Item* Item_equal::get_first(JOIN_TAB*, Item*) in file:///home/psergey/dev2/5.3-look50/

Sergey Petrunya psergey at askmonty.org
Fri Jan 27 15:35:30 EET 2012


At file:///home/psergey/dev2/5.3-look50/

------------------------------------------------------------
revno: 3398
revision-id: psergey at askmonty.org-20120127133526-szu1irzw5nzrbgae
parent: psergey at askmonty.org-20120126102034-tp33uzyuqnyk30mn
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.3-look50
timestamp: Fri 2012-01-27 17:35:26 +0400
message:
  BUG#922254: Assertion `0' failed at item_cmpfunc.cc:5899: Item* Item_equal::get_first(JOIN_TAB*, Item*)
  Fixed Item* Item_equal::get_first(JOIN_TAB *context, Item *field_item) to work correctly in the case where:
  - context!= NO_PARTICULAR_TAB, it points to a table within SJ-Materialization nest
  - field_item points to an item_equal that has a constant Item_field but does not have any fields
    from tables that are within semi-join nests.
=== modified file 'mysql-test/r/subselect_mat.result'
--- a/mysql-test/r/subselect_mat.result	2011-12-19 21:05:44 +0000
+++ b/mysql-test/r/subselect_mat.result	2012-01-27 13:35:26 +0000
@@ -1811,6 +1811,26 @@
 4	4	2
 4	4	4
 DROP TABLE t1,t2;
+#
+# BUG#922254: Assertion `0' failed at item_cmpfunc.cc:5899: Item* Item_equal::get_first(JOIN_TAB*, Item*)
+#
+CREATE TABLE t1 ( a VARCHAR(3) );
+CREATE TABLE t2 ( b VARCHAR(3), c VARCHAR(8), KEY(c) );
+INSERT INTO t2 VALUES ('USA','Abilene'),('USA','Akron');
+EXPLAIN
+SELECT * FROM
+( SELECT * FROM t1 ) AS alias1,
+t2 AS alias2
+WHERE b = a AND a IN (
+SELECT alias3.c
+FROM t2 AS alias3, t2 AS alias4
+WHERE alias4.c = alias3.b
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+3	MATERIALIZED	alias3	ALL	NULL	NULL	NULL	NULL	2	
+3	MATERIALIZED	alias4	index	c	c	11	NULL	2	Using where; Using index; Using join buffer (flat, BNL join)
+DROP TABLE t1,t2;
 # This must be at the end:
 set optimizer_switch=@subselect_sj_mat_tmp;
 set join_cache_level=@save_join_cache_level;

=== modified file 'mysql-test/r/subselect_sj_mat.result'
--- a/mysql-test/r/subselect_sj_mat.result	2011-12-19 21:05:44 +0000
+++ b/mysql-test/r/subselect_sj_mat.result	2012-01-27 13:35:26 +0000
@@ -1849,6 +1849,24 @@
 4	4	2
 4	4	4
 DROP TABLE t1,t2;
+#
+# BUG#922254: Assertion `0' failed at item_cmpfunc.cc:5899: Item* Item_equal::get_first(JOIN_TAB*, Item*)
+#
+CREATE TABLE t1 ( a VARCHAR(3) );
+CREATE TABLE t2 ( b VARCHAR(3), c VARCHAR(8), KEY(c) );
+INSERT INTO t2 VALUES ('USA','Abilene'),('USA','Akron');
+EXPLAIN
+SELECT * FROM
+( SELECT * FROM t1 ) AS alias1,
+t2 AS alias2
+WHERE b = a AND a IN (
+SELECT alias3.c
+FROM t2 AS alias3, t2 AS alias4
+WHERE alias4.c = alias3.b
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+DROP TABLE t1,t2;
 # This must be at the end:
 set optimizer_switch=@subselect_sj_mat_tmp;
 set join_cache_level=@save_join_cache_level;

=== modified file 'mysql-test/t/subselect_sj_mat.test'
--- a/mysql-test/t/subselect_sj_mat.test	2011-12-19 21:05:44 +0000
+++ b/mysql-test/t/subselect_sj_mat.test	2012-01-27 13:35:26 +0000
@@ -1510,6 +1510,25 @@
 
 DROP TABLE t1,t2;
 
+--echo #
+--echo # BUG#922254: Assertion `0' failed at item_cmpfunc.cc:5899: Item* Item_equal::get_first(JOIN_TAB*, Item*)
+--echo #
+CREATE TABLE t1 ( a VARCHAR(3) );
+CREATE TABLE t2 ( b VARCHAR(3), c VARCHAR(8), KEY(c) );
+INSERT INTO t2 VALUES ('USA','Abilene'),('USA','Akron');
+
+EXPLAIN
+SELECT * FROM
+  ( SELECT * FROM t1 ) AS alias1,
+  t2 AS alias2
+WHERE b = a AND a IN (
+  SELECT alias3.c
+  FROM t2 AS alias3, t2 AS alias4
+  WHERE alias4.c = alias3.b
+);
+
+DROP TABLE t1,t2;
+
 --echo # This must be at the end:
 set optimizer_switch=@subselect_sj_mat_tmp;
 set join_cache_level=@save_join_cache_level;

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2012-01-19 22:11:53 +0000
+++ b/sql/item_cmpfunc.cc	2012-01-27 13:35:26 +0000
@@ -5853,13 +5853,15 @@
   if (emb_nest && emb_nest->sj_mat_info && emb_nest->sj_mat_info->is_used)
   {
     /*
-      It's a field from an materialized semi-join. We can substitute it only
-      for a field from the same semi-join. Find the first of such items.
+      It's a field from an materialized semi-join. We can substitute it for
+       - a constant item 
+       - a field from the same semi-join
+       Find the first of such items:
     */
-
     while ((item= it++))
     {
-      if (it.get_curr_field()->table->pos_in_table_list->embedding == emb_nest)
+      if (item->const_item() || 
+          it.get_curr_field()->table->pos_in_table_list->embedding == emb_nest)
       {
         /*
           If we found given field then return NULL to avoid unnecessary



More information about the commits mailing list