[Commits] Rev 3380: Fixed LP bug #914560. in file:///home/igor/maria/maria-5.3-mwl247-bug914560/

Igor Babaev igor at askmonty.org
Tue Jan 17 13:26:49 EET 2012


At file:///home/igor/maria/maria-5.3-mwl247-bug914560/

------------------------------------------------------------
revno: 3380
revision-id: igor at askmonty.org-20120117112649-ebl7chbvsass72jn
parent: igor at askmonty.org-20120102064211-cdqcnijx16rdgi9d
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.3-mwl247-bug914560
timestamp: Tue 2012-01-17 03:26:49 -0800
message:
  Fixed LP bug #914560.
  The patch for MWL #247 forgot to initialize the TABLE::ext_key_parts and
  TABLE::ext_key_flags of the temporary tables by a query. This could cause
  crashes for queries the execution of which needed creation of temporary
  tables.  
-------------- next part --------------
=== modified file 'mysql-test/r/innodb_ext_key.result'
--- a/mysql-test/r/innodb_ext_key.result	2011-12-31 10:25:57 +0000
+++ b/mysql-test/r/innodb_ext_key.result	2012-01-17 11:26:49 +0000
@@ -561,6 +561,29 @@
 Handler_read_prev	0
 Handler_read_rnd	0
 Handler_read_rnd_next	0
+DROP DATABASE dbt3_s001;
+use test;
+#
+# LP Bug #914560: query containing IN subquery
+#                 + extended_keys = on
+#
+set @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch='materialization=on,semijoin=on';
+SET optimizer_switch='extended_keys=on';
+CREATE TABLE t1 (a int, b int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,1), (2,2);
+SELECT * FROM t1 WHERE 2 IN (SELECT MAX(s1.a) FROM t1 AS s1, t1 AS s2);
+a	b
+1	1
+2	2
+EXPLAIN
+SELECT * FROM t1 WHERE 2 IN (SELECT MAX(s1.a) FROM t1 AS s1, t1 AS s2);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<subquery2>	const	distinct_key	distinct_key	5	const	1	
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (flat, BNL join)
+2	MATERIALIZED	s1	ALL	NULL	NULL	NULL	NULL	2	
+2	MATERIALIZED	s2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (flat, BNL join)
+DROP TABLE t1;
+set optimizer_switch=@save_optimizer_switch;
 set optimizer_switch=@save_ext_key_optimizer_switch;
-DROP DATABASE dbt3_s001;
 SET SESSION STORAGE_ENGINE=DEFAULT;

=== modified file 'mysql-test/t/innodb_ext_key.test'
--- a/mysql-test/t/innodb_ext_key.test	2011-12-31 10:25:57 +0000
+++ b/mysql-test/t/innodb_ext_key.test	2012-01-17 11:26:49 +0000
@@ -287,8 +287,30 @@
         and o_orderkey=l_orderkey and p_partkey=l_partkey;
 show status like 'handler_read%';
 
+DROP DATABASE dbt3_s001;
+
+use test;
+
+--echo #
+--echo # LP Bug #914560: query containing IN subquery
+--echo #                 + extended_keys = on
+--echo #
+
+set @save_optimizer_switch=@@optimizer_switch;
+
+SET optimizer_switch='materialization=on,semijoin=on';
+SET optimizer_switch='extended_keys=on';
+
+CREATE TABLE t1 (a int, b int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,1), (2,2);
+
+SELECT * FROM t1 WHERE 2 IN (SELECT MAX(s1.a) FROM t1 AS s1, t1 AS s2);
+EXPLAIN
+SELECT * FROM t1 WHERE 2 IN (SELECT MAX(s1.a) FROM t1 AS s1, t1 AS s2);
+
+DROP TABLE t1;
+
+set optimizer_switch=@save_optimizer_switch;
+
 set optimizer_switch=@save_ext_key_optimizer_switch;
-
-DROP DATABASE dbt3_s001;
-
 SET SESSION STORAGE_ENGINE=DEFAULT;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2012-01-02 04:47:36 +0000
+++ b/sql/sql_select.cc	2012-01-17 11:26:49 +0000
@@ -13914,7 +13914,9 @@
     share->keys_in_use.set_bit(0);
     keyinfo->key_part=key_part_info;
     keyinfo->flags=HA_NOSAME | HA_BINARY_PACK_KEY | HA_PACK_KEY;
+    keyinfo->ext_key_flags= keyinfo->flags;
     keyinfo->usable_key_parts=keyinfo->key_parts= param->group_parts;
+    keyinfo->ext_key_parts= keyinfo->key_parts;
     keyinfo->key_length=0;
     keyinfo->rec_per_key=0;
     keyinfo->algorithm= HA_KEY_ALG_UNDEF;
@@ -14013,6 +14015,7 @@
     null_pack_length-=hidden_null_pack_length;
     keyinfo->key_parts= ((field_count-param->hidden_field_count)+
 			 (share->uniques ? test(null_pack_length) : 0));
+    keyinfo->ext_key_parts= keyinfo->key_parts;
     table->distinct= 1;
     share->keys= 1;
     if (!(key_part_info= (KEY_PART_INFO*)
@@ -14025,6 +14028,7 @@
     table->key_info= table->s->key_info= keyinfo;
     keyinfo->key_part=key_part_info;
     keyinfo->flags=HA_NOSAME | HA_NULL_ARE_EQUAL | HA_BINARY_PACK_KEY | HA_PACK_KEY;
+    keyinfo->ext_key_flags= keyinfo->flags;
     keyinfo->key_length= 0;  // Will compute the sum of the parts below.
     keyinfo->name= (char*) "distinct_key";
     keyinfo->algorithm= HA_KEY_ALG_UNDEF;

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2012-01-02 06:42:11 +0000
+++ b/sql/table.cc	2012-01-17 11:26:49 +0000
@@ -5478,9 +5478,11 @@
   keyinfo= key_info + key;
   keyinfo->key_part= key_part_info;
   keyinfo->usable_key_parts= keyinfo->key_parts = key_parts;
+  keyinfo->ext_key_parts= keyinfo->key_parts;
   keyinfo->key_length=0;
   keyinfo->algorithm= HA_KEY_ALG_UNDEF;
   keyinfo->flags= HA_GENERATED_KEY;
+  keyinfo->ext_key_flags= keyinfo->flags;
   if (unique)
     keyinfo->flags|= HA_NOSAME;
   sprintf(buf, "key%i", key);



More information about the commits mailing list