[Commits] Rev 3691: Fix bug MDEV-4657 SQ pushdown: Valgrind warnings (Conditional jump or move depends on uninitialised value) in compare_items_by_cost in file:///home/tsk/mprog/src/10.0-md83-lp/

timour at askmonty.org timour at askmonty.org
Thu Aug 22 13:47:50 EEST 2013


At file:///home/tsk/mprog/src/10.0-md83-lp/

------------------------------------------------------------
revno: 3691
revision-id: timour at askmonty.org-20130809153423-txf3a35b80u28kv1
parent: timour at askmonty.org-20130809113013-gkhz150p92svwhen
fixes bug: https://mariadb.atlassian.net/browse/MDEV-4657
committer: timour at askmonty.org
branch nick: 10.0-md83
timestamp: Fri 2013-08-09 18:34:23 +0300
message:
  Fix bug MDEV-4657 SQ pushdown: Valgrind warnings (Conditional jump or move depends on uninitialised value) in compare_items_by_cost
  
  Analysis:
  Subqueries without tables were not optimized via make_join_statistics,
  and the cost of such query plans (JOIN::best_read) was not set. When
  subsequent optimization needed the cost of such a subquery, the access
  to the unitialized JOIN::best_read resulted in a valgrind error.
  
  Solution:
  Set the cost of query plans without tables before returning from JOIN::optimize_inner.
-------------- next part --------------
=== modified file 'mysql-test/r/subselect4.result'
--- a/mysql-test/r/subselect4.result	2013-08-09 11:30:13 +0000
+++ b/mysql-test/r/subselect4.result	2013-08-09 15:34:23 +0000
@@ -2492,6 +2492,28 @@ i1	i2	c2
 1       8       c
 1       6       c
 drop table t1, t2, t3, t4;
+#
+# MDEV-4657 SQ pushdown: Valgrind warnings (Conditional jump or move depends on uninitialised value) in compare_items_by_cost
+#
+CREATE TABLE t1 (i1 INT, c1 CHAR(1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (i2 INT, c2 CHAR(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3,'m'),(4,'n');
+SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE (i2 = i1) AND ( c2 , c1 )  IN ( SELECT 'f' , 'q' );
+i1      c1      i2      c2
+drop table t1, t2;
+#
+# MDEV-4659 SQ pushdown: Valgrind warnings (Conditional jump or move depends on uninitialised value) in best_extension_by_limited_search /
+# greedy_search with expensive_pred_static_pushdown=on
+#
+SET optimizer_switch='expensive_pred_static_pushdown=on';
+CREATE TABLE t1 (i INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (8),(18);
+SELECT 1 FROM t1 WHERE i IN ( SELECT 8 UNION SELECT 8 );
+1
+1
+SET optimizer_switch='expensive_pred_static_pushdown=off';
+drop table t1;
 SET optimizer_switch=@@global.optimizer_switch;
 SET optimizer_use_condition_selectivity=default;
 SET use_stat_tables=default;

=== modified file 'mysql-test/t/subselect4.test'
--- a/mysql-test/t/subselect4.test	2013-08-09 11:30:13 +0000
+++ b/mysql-test/t/subselect4.test	2013-08-09 15:34:23 +0000
@@ -1998,6 +1998,34 @@ WHERE i1 IN ( SELECT i3 FROM t3, t4 WHER
 
 drop table t1, t2, t3, t4;
 
+--echo #
+--echo # MDEV-4657 SQ pushdown: Valgrind warnings (Conditional jump or move depends on uninitialised value) in compare_items_by_cost
+--echo #
+
+CREATE TABLE t1 (i1 INT, c1 CHAR(1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,'a'),(2,'b');
+
+CREATE TABLE t2 (i2 INT, c2 CHAR(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3,'m'),(4,'n');
+
+SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE (i2 = i1) AND ( c2 , c1 )  IN ( SELECT 'f' , 'q' );
+
+drop table t1, t2;
+
+--echo #
+--echo # MDEV-4659 SQ pushdown: Valgrind warnings (Conditional jump or move depends on uninitialised value) in best_extension_by_limited_search /
+--echo # greedy_search with expensive_pred_static_pushdown=on
+--echo #
+
+SET optimizer_switch='expensive_pred_static_pushdown=on';
+
+CREATE TABLE t1 (i INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (8),(18);
+SELECT 1 FROM t1 WHERE i IN ( SELECT 8 UNION SELECT 8 );
+
+SET optimizer_switch='expensive_pred_static_pushdown=off';
+
+drop table t1;
 
 SET optimizer_switch=@@global.optimizer_switch;
 SET optimizer_use_condition_selectivity=default;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2013-04-01 10:36:05 +0000
+++ b/sql/sql_select.cc	2013-08-09 15:34:23 +0000
@@ -1304,6 +1304,11 @@ TODO: make view to decide if it is possi
   {
     DBUG_PRINT("info",("No tables"));
     error= 0;
+    /*
+      Even if there are no tables the query has some small cost. Use the default
+      cost of all 'cheap' items.
+    */
+    best_read= (1 / (double)TIME_FOR_COMPARE);
     goto setup_subq_exit;
   }
   error= -1;                                    // Error is sent to client



More information about the commits mailing list