[Commits] Rev 3774: Merge in file:///home/psergey/dev2/5.3-push/

Sergey Petrunya psergey at askmonty.org
Tue Mar 18 10:07:04 EET 2014


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

------------------------------------------------------------
revno: 3774 [merge]
revision-id: psergey at askmonty.org-20140318080632-c1pql218bfrx26y2
parent: sergii at pisem.net-20140316200301-s6v5h1t6d9feqwo9
parent: psergey at askmonty.org-20140313112057-c1zhosmui8wchy7v
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.3-push
timestamp: Tue 2014-03-18 12:06:32 +0400
message:
  Merge
modified:
  mysql-test/r/subselect_mat.result subselect_mat.result-20100117143924-r0jv32dj80dg3b5h-1
  mysql-test/r/subselect_sj_mat.result subselect_sj_mat.res-20100524221009-pdj0un54npqbnpcr-1
  mysql-test/t/subselect_sj_mat.test subselect_sj_mat.tes-20100524220952-cy056unehps9s8xw-1
  sql/sql_select.cc              sp1f-sql_select.cc-19700101030959-egb7whpkh76zzvikycs5nsnuviu4fdlb
=== modified file 'mysql-test/r/subselect_mat.result'
--- a/mysql-test/r/subselect_mat.result	2014-01-23 17:26:04 +0000
+++ b/mysql-test/r/subselect_mat.result	2014-03-13 11:20:57 +0000
@@ -2041,6 +2041,20 @@ EXECUTE stmt;
 a
 DROP TABLE t1, t2;
 DROP VIEW v2;
+#
+# MDEV-5811: Server crashes in best_access_path with materialization+semijoin and big_tables=ON
+#
+SET @tmp_mdev5811= @@big_tables;
+SET big_tables = ON;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (3),(4);
+SELECT * FROM t1 AS t1_1, t1 AS t1_2 
+WHERE ( t1_1.a, t1_2.a ) IN ( SELECT MAX(b), MIN(b) FROM t2 );
+a	a
+DROP TABLE t1,t2;
+SET big_tables=@tmp_mdev5811;
 # End of 5.3 tests
 set @subselect_mat_test_optimizer_switch_value=null;
 set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';

=== modified file 'mysql-test/r/subselect_sj_mat.result'
--- a/mysql-test/r/subselect_sj_mat.result	2014-01-23 17:26:04 +0000
+++ b/mysql-test/r/subselect_sj_mat.result	2014-03-13 11:20:57 +0000
@@ -2081,4 +2081,18 @@ EXECUTE stmt;
 a
 DROP TABLE t1, t2;
 DROP VIEW v2;
+#
+# MDEV-5811: Server crashes in best_access_path with materialization+semijoin and big_tables=ON
+#
+SET @tmp_mdev5811= @@big_tables;
+SET big_tables = ON;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (3),(4);
+SELECT * FROM t1 AS t1_1, t1 AS t1_2 
+WHERE ( t1_1.a, t1_2.a ) IN ( SELECT MAX(b), MIN(b) FROM t2 );
+a	a
+DROP TABLE t1,t2;
+SET big_tables=@tmp_mdev5811;
 # End of 5.3 tests

=== modified file 'mysql-test/t/subselect_sj_mat.test'
--- a/mysql-test/t/subselect_sj_mat.test	2014-01-23 17:26:04 +0000
+++ b/mysql-test/t/subselect_sj_mat.test	2014-03-13 11:20:57 +0000
@@ -1726,4 +1726,22 @@ EXECUTE stmt;
 DROP TABLE t1, t2;
 DROP VIEW v2;
 
+--echo #
+--echo # MDEV-5811: Server crashes in best_access_path with materialization+semijoin and big_tables=ON
+--echo #
+SET @tmp_mdev5811= @@big_tables;
+SET big_tables = ON;
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (3),(4);
+
+SELECT * FROM t1 AS t1_1, t1 AS t1_2 
+  WHERE ( t1_1.a, t1_2.a ) IN ( SELECT MAX(b), MIN(b) FROM t2 );
+
+DROP TABLE t1,t2;
+SET big_tables=@tmp_mdev5811;
+
 --echo # End of 5.3 tests

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2014-03-16 20:03:01 +0000
+++ b/sql/sql_select.cc	2014-03-18 08:06:32 +0000
@@ -14976,7 +14976,20 @@ create_tmp_table(THD *thd, TMP_TABLE_PAR
     keyinfo->key_length= 0;  // Will compute the sum of the parts below.
     keyinfo->name= (char*) "distinct_key";
     keyinfo->algorithm= HA_KEY_ALG_UNDEF;
-    keyinfo->rec_per_key=0;
+    /*
+      Needed by non-merged semi-joins: SJ-Materialized table must have a valid 
+      rec_per_key array, because it participates in join optimization. Since
+      the table has no data, the only statistics we can provide is "unknown",
+      i.e. zero values.
+
+      (For table record count, we calculate and set JOIN_TAB::found_records,
+       see get_delayed_table_estimates()).
+    */
+    size_t rpk_size= keyinfo->key_parts* sizeof(keyinfo->rec_per_key[0]);
+    if (!(keyinfo->rec_per_key= (ulong*) alloc_root(&table->mem_root, 
+                                                    rpk_size)))
+      goto err;
+    bzero(keyinfo->rec_per_key, rpk_size);
 
     /*
       Create an extra field to hold NULL bits so that unique indexes on



More information about the commits mailing list