List:Commits« Previous MessageNext Message »
From:Olav Sandstaa Date:March 12 2012 1:35pm
Subject:bzr push into mysql-trunk branch (olav.sandstaa:3745 to 3746) Bug#12667154
View as plain text  
 3746 Olav Sandstaa	2012-03-12
      Revert fix for Bug#12667154 SAME QUERY EXEC AS WHERE SUBQ GIVES DIFFERENT
                                  RESULTS ON IN() & NOT IN() COMP #3
      
      The patch for this bug caused a memory leak of QUICK_RANGE_SELECT objects
      when these were allocated on the heap. This memory leak could cause the
      server to run out of memory.
     @ mysql-test/include/icp_tests.inc
        Revert test case for Bug#12667154.
     @ sql/sql_executor.cc
        Revert fix for Bug#12667154.

    modified:
      mysql-test/include/icp_tests.inc
      mysql-test/r/innodb_icp.result
      mysql-test/r/innodb_icp_all.result
      mysql-test/r/innodb_icp_none.result
      mysql-test/r/myisam_icp.result
      mysql-test/r/myisam_icp_all.result
      mysql-test/r/myisam_icp_none.result
      sql/sql_executor.cc
 3745 Frazer Clement	2012-03-09
      Bug#54854 Can't find good position for replication break between DDL statements
      
      Part 1 of patches to mysql-trunk.
      
      Overall fix has two parts :
        1) Improve Ndb replication channel cutover with precise 
           next-position-after-epoch-trans in the mysql.ndb_binlog_index
           table.
        2) Simplify configuration of DDL-idempotency with a new
           MySQL Server option
      
      Part 1) of the fix includes patches affecting the generic MySQL Server
      (this commit) and patches affecting the Ndb storage engine.
      
      Part 2) of the fix includes patches affecting the generic MySQL Server.
      
      This commit adds a THD member which records the next Binlog position
      (filename and offset) after the last Binlog event recorded by the
      thread.
      This information is exposed via an extension to the Binlog injector
      Api.
      
      Further patches to be pushed to the MySQL Cluster branches make use
      of this functionality to fix bug#54854.
      
      In mysql-trunk builds, this functionality has no externally visible
      effect, and therefore no specific testcase.
      
      Testcases are added in branches merging this branch and MySQL Cluster.

    modified:
      sql/binlog.cc
      sql/binlog.h
      sql/log.h
      sql/log_event.h
      sql/rpl_injector.cc
      sql/rpl_injector.h
      sql/sql_class.cc
      sql/sql_class.h
=== modified file 'mysql-test/include/icp_tests.inc'

=== modified file 'mysql-test/include/icp_tests.inc'
--- a/mysql-test/include/icp_tests.inc	2012-03-09 10:56:36 +0000
+++ b/mysql-test/include/icp_tests.inc	2012-03-12 13:26:55 +0000
@@ -1150,53 +1150,3 @@
 
 DROP FUNCTION f1;
 DROP TABLE t1, t2;
-
---echo #
---echo # Bug#12667154 "SAME QUERY EXEC AS WHERE SUBQ GIVES DIFFERENT RESULTS
---echo #               ON IN() & NOT IN() COMP #3"
---echo #
-
-# Need to avoid materialization for this bug to occur
-SET @save_optimizer_switch_bug12667154= @@optimizer_switch;
-SET SESSION optimizer_switch="materialization=off";
-
-CREATE TABLE t1 (
-  i1 INTEGER,
-  i2 INTEGER,
-  KEY k1 (i1)
-);
-
-INSERT INTO t1 VALUES (9,0), (7,1), (1,9), (7,101), (2,1), (9,102);
-
-CREATE TABLE t2 (
-  pk INTEGER,
-  i2 INTEGER,
-  PRIMARY KEY (pk)
-);
-
-INSERT INTO t2 VALUES (2,1), (3,2), (5,3), (6,4), (7,6), (9,4);
-
-CREATE TABLE t3 (
-  i1 INTEGER,
-  i2 INTEGER
-);
-
-INSERT INTO t3 VALUES (1,0), (1,1), (1,101), (1,102);
-
-let $query=
-SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-  SELECT COUNT(DISTINCT t2.i2), t1.i2
-  FROM t1 JOIN t2 ON t1.i1 = t2.pk
-  WHERE t2.pk BETWEEN 7 AND 9
-  GROUP BY t1.i2
-);
-
---eval EXPLAIN $query
---eval $query
-
-DROP TABLE t1, t2, t3;
-
-# Restore optimizer switch setting
-SET optimizer_switch= @save_optimizer_switch_bug12667154;

=== modified file 'mysql-test/r/innodb_icp.result'
--- a/mysql-test/r/innodb_icp.result	2012-03-09 10:56:36 +0000
+++ b/mysql-test/r/innodb_icp.result	2012-03-12 13:26:55 +0000
@@ -1065,55 +1065,5 @@
 5	5
 DROP FUNCTION f1;
 DROP TABLE t1, t2;
-#
-# Bug#12667154 "SAME QUERY EXEC AS WHERE SUBQ GIVES DIFFERENT RESULTS
-#               ON IN() & NOT IN() COMP #3"
-#
-SET @save_optimizer_switch_bug12667154= @@optimizer_switch;
-SET SESSION optimizer_switch="materialization=off";
-CREATE TABLE t1 (
-i1 INTEGER,
-i2 INTEGER,
-KEY k1 (i1)
-);
-INSERT INTO t1 VALUES (9,0), (7,1), (1,9), (7,101), (2,1), (9,102);
-CREATE TABLE t2 (
-pk INTEGER,
-i2 INTEGER,
-PRIMARY KEY (pk)
-);
-INSERT INTO t2 VALUES (2,1), (3,2), (5,3), (6,4), (7,6), (9,4);
-CREATE TABLE t3 (
-i1 INTEGER,
-i2 INTEGER
-);
-INSERT INTO t3 VALUES (1,0), (1,1), (1,101), (1,102);
-EXPLAIN SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	4	Using where
-2	DEPENDENT SUBQUERY	t1	range	k1	k1	5	NULL	4	Using index condition; Using filesort
-2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i1	1	NULL
-SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-i1	i2
-1	0
-1	1
-1	101
-1	102
-DROP TABLE t1, t2, t3;
-SET optimizer_switch= @save_optimizer_switch_bug12667154;
 set default_storage_engine= @save_storage_engine;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/innodb_icp_all.result'
--- a/mysql-test/r/innodb_icp_all.result	2012-03-09 10:56:36 +0000
+++ b/mysql-test/r/innodb_icp_all.result	2012-03-12 13:26:55 +0000
@@ -1065,55 +1065,5 @@
 5	5
 DROP FUNCTION f1;
 DROP TABLE t1, t2;
-#
-# Bug#12667154 "SAME QUERY EXEC AS WHERE SUBQ GIVES DIFFERENT RESULTS
-#               ON IN() & NOT IN() COMP #3"
-#
-SET @save_optimizer_switch_bug12667154= @@optimizer_switch;
-SET SESSION optimizer_switch="materialization=off";
-CREATE TABLE t1 (
-i1 INTEGER,
-i2 INTEGER,
-KEY k1 (i1)
-);
-INSERT INTO t1 VALUES (9,0), (7,1), (1,9), (7,101), (2,1), (9,102);
-CREATE TABLE t2 (
-pk INTEGER,
-i2 INTEGER,
-PRIMARY KEY (pk)
-);
-INSERT INTO t2 VALUES (2,1), (3,2), (5,3), (6,4), (7,6), (9,4);
-CREATE TABLE t3 (
-i1 INTEGER,
-i2 INTEGER
-);
-INSERT INTO t3 VALUES (1,0), (1,1), (1,101), (1,102);
-EXPLAIN SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	4	Using where
-2	DEPENDENT SUBQUERY	t1	range	k1	k1	5	NULL	4	Using index condition; Using filesort
-2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i1	1	NULL
-SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-i1	i2
-1	0
-1	1
-1	101
-1	102
-DROP TABLE t1, t2, t3;
-SET optimizer_switch= @save_optimizer_switch_bug12667154;
 set default_storage_engine= @save_storage_engine;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/innodb_icp_none.result'
--- a/mysql-test/r/innodb_icp_none.result	2012-03-09 10:56:36 +0000
+++ b/mysql-test/r/innodb_icp_none.result	2012-03-12 13:26:55 +0000
@@ -1064,55 +1064,5 @@
 5	5
 DROP FUNCTION f1;
 DROP TABLE t1, t2;
-#
-# Bug#12667154 "SAME QUERY EXEC AS WHERE SUBQ GIVES DIFFERENT RESULTS
-#               ON IN() & NOT IN() COMP #3"
-#
-SET @save_optimizer_switch_bug12667154= @@optimizer_switch;
-SET SESSION optimizer_switch="materialization=off";
-CREATE TABLE t1 (
-i1 INTEGER,
-i2 INTEGER,
-KEY k1 (i1)
-);
-INSERT INTO t1 VALUES (9,0), (7,1), (1,9), (7,101), (2,1), (9,102);
-CREATE TABLE t2 (
-pk INTEGER,
-i2 INTEGER,
-PRIMARY KEY (pk)
-);
-INSERT INTO t2 VALUES (2,1), (3,2), (5,3), (6,4), (7,6), (9,4);
-CREATE TABLE t3 (
-i1 INTEGER,
-i2 INTEGER
-);
-INSERT INTO t3 VALUES (1,0), (1,1), (1,101), (1,102);
-EXPLAIN SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	4	Using where
-2	DEPENDENT SUBQUERY	t1	range	k1	k1	5	NULL	4	Using where; Using filesort
-2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i1	1	NULL
-SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-i1	i2
-1	0
-1	1
-1	101
-1	102
-DROP TABLE t1, t2, t3;
-SET optimizer_switch= @save_optimizer_switch_bug12667154;
 set default_storage_engine= @save_storage_engine;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/myisam_icp.result'
--- a/mysql-test/r/myisam_icp.result	2012-03-09 10:56:36 +0000
+++ b/mysql-test/r/myisam_icp.result	2012-03-12 13:26:55 +0000
@@ -1060,54 +1060,4 @@
 5	5
 DROP FUNCTION f1;
 DROP TABLE t1, t2;
-#
-# Bug#12667154 "SAME QUERY EXEC AS WHERE SUBQ GIVES DIFFERENT RESULTS
-#               ON IN() & NOT IN() COMP #3"
-#
-SET @save_optimizer_switch_bug12667154= @@optimizer_switch;
-SET SESSION optimizer_switch="materialization=off";
-CREATE TABLE t1 (
-i1 INTEGER,
-i2 INTEGER,
-KEY k1 (i1)
-);
-INSERT INTO t1 VALUES (9,0), (7,1), (1,9), (7,101), (2,1), (9,102);
-CREATE TABLE t2 (
-pk INTEGER,
-i2 INTEGER,
-PRIMARY KEY (pk)
-);
-INSERT INTO t2 VALUES (2,1), (3,2), (5,3), (6,4), (7,6), (9,4);
-CREATE TABLE t3 (
-i1 INTEGER,
-i2 INTEGER
-);
-INSERT INTO t3 VALUES (1,0), (1,1), (1,101), (1,102);
-EXPLAIN SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	4	Using where
-2	DEPENDENT SUBQUERY	t1	range	k1	k1	5	NULL	3	Using index condition; Using filesort
-2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i1	1	NULL
-SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-i1	i2
-1	0
-1	1
-1	101
-1	102
-DROP TABLE t1, t2, t3;
-SET optimizer_switch= @save_optimizer_switch_bug12667154;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/myisam_icp_all.result'
--- a/mysql-test/r/myisam_icp_all.result	2012-03-09 10:56:36 +0000
+++ b/mysql-test/r/myisam_icp_all.result	2012-03-12 13:26:55 +0000
@@ -1060,54 +1060,4 @@
 5	5
 DROP FUNCTION f1;
 DROP TABLE t1, t2;
-#
-# Bug#12667154 "SAME QUERY EXEC AS WHERE SUBQ GIVES DIFFERENT RESULTS
-#               ON IN() & NOT IN() COMP #3"
-#
-SET @save_optimizer_switch_bug12667154= @@optimizer_switch;
-SET SESSION optimizer_switch="materialization=off";
-CREATE TABLE t1 (
-i1 INTEGER,
-i2 INTEGER,
-KEY k1 (i1)
-);
-INSERT INTO t1 VALUES (9,0), (7,1), (1,9), (7,101), (2,1), (9,102);
-CREATE TABLE t2 (
-pk INTEGER,
-i2 INTEGER,
-PRIMARY KEY (pk)
-);
-INSERT INTO t2 VALUES (2,1), (3,2), (5,3), (6,4), (7,6), (9,4);
-CREATE TABLE t3 (
-i1 INTEGER,
-i2 INTEGER
-);
-INSERT INTO t3 VALUES (1,0), (1,1), (1,101), (1,102);
-EXPLAIN SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	4	Using where
-2	DEPENDENT SUBQUERY	t1	range	k1	k1	5	NULL	3	Using index condition; Using filesort
-2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i1	1	NULL
-SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-i1	i2
-1	0
-1	1
-1	101
-1	102
-DROP TABLE t1, t2, t3;
-SET optimizer_switch= @save_optimizer_switch_bug12667154;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/myisam_icp_none.result'
--- a/mysql-test/r/myisam_icp_none.result	2012-03-09 10:56:36 +0000
+++ b/mysql-test/r/myisam_icp_none.result	2012-03-12 13:26:55 +0000
@@ -1059,54 +1059,4 @@
 5	5
 DROP FUNCTION f1;
 DROP TABLE t1, t2;
-#
-# Bug#12667154 "SAME QUERY EXEC AS WHERE SUBQ GIVES DIFFERENT RESULTS
-#               ON IN() & NOT IN() COMP #3"
-#
-SET @save_optimizer_switch_bug12667154= @@optimizer_switch;
-SET SESSION optimizer_switch="materialization=off";
-CREATE TABLE t1 (
-i1 INTEGER,
-i2 INTEGER,
-KEY k1 (i1)
-);
-INSERT INTO t1 VALUES (9,0), (7,1), (1,9), (7,101), (2,1), (9,102);
-CREATE TABLE t2 (
-pk INTEGER,
-i2 INTEGER,
-PRIMARY KEY (pk)
-);
-INSERT INTO t2 VALUES (2,1), (3,2), (5,3), (6,4), (7,6), (9,4);
-CREATE TABLE t3 (
-i1 INTEGER,
-i2 INTEGER
-);
-INSERT INTO t3 VALUES (1,0), (1,1), (1,101), (1,102);
-EXPLAIN SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	4	Using where
-2	DEPENDENT SUBQUERY	t1	range	k1	k1	5	NULL	3	Using where; Using filesort
-2	DEPENDENT SUBQUERY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.i1	1	NULL
-SELECT * FROM t3
-WHERE (i1, i2) IN 
-(
-SELECT COUNT(DISTINCT t2.i2), t1.i2
-FROM t1 JOIN t2 ON t1.i1 = t2.pk
-WHERE t2.pk BETWEEN 7 AND 9
-GROUP BY t1.i2
-);
-i1	i2
-1	0
-1	1
-1	101
-1	102
-DROP TABLE t1, t2, t3;
-SET optimizer_switch= @save_optimizer_switch_bug12667154;
 set optimizer_switch=default;

=== modified file 'sql/sql_executor.cc'
--- a/sql/sql_executor.cc	2012-03-09 10:56:36 +0000
+++ b/sql/sql_executor.cc	2012-03-12 13:26:55 +0000
@@ -3927,12 +3927,6 @@
   TABLE *table;
   SQL_SELECT *select;
   JOIN_TAB *tab;
-  /* 
-    If the select->quick object is created outside of create_sort_index()
-    we should not delete it on exit from this function.
-  */
-  bool keep_quick= true;
-
   DBUG_ENTER("create_sort_index");
 
   if (join->tables == join->const_tables)
@@ -3998,7 +3992,6 @@
 			    get_quick_select_for_ref(thd, table, &tab->ref, 
                                                      tab->found_records))))
 	goto err;
-      keep_quick= false;
     }
   }
 
@@ -4041,39 +4034,9 @@
     tablesort_result_cache= table->sort.io_cache;
     table->sort.io_cache= NULL;
 
-    /*
-      If the quick select object was created outside of
-      create_sort_index then we need to save it to avoid that it will
-      be deleted when calling select->cleanup().
-    */
-    QUICK_SELECT_I *saved_quick= NULL;
-
-    if (select->quick && keep_quick)
-    {
-      saved_quick= select->quick;
-      select->quick= NULL;
-      saved_quick->range_end();
-    }
-    /* 
-      filesort did select so we need to cleanup the select object.
-      Unless we have removed the pointer to the quick select object,
-      cleanup() will delete it.
-    */
-    select->cleanup();
-    // Now we can restore the quick select object
-    if (saved_quick)
-      tab->select->set_quick(saved_quick);
-    /*
-      The select object should now be ready for the next use. If 
-      it is re-used then there exists a backup copy of this join 
-      tab which has the pointer to it. The join tab will be restored 
-      in JOIN::reset(). So here we just deletes the pointer to it.
-    */
-    tab->select= NULL;
-    // If we deleted the quick select object we need to clear quick_keys
-    if (!saved_quick)
-      table->quick_keys.clear_all();
-    // Restore the output resultset
+    select->cleanup();				// filesort did select
+    tab->select= 0;
+    table->quick_keys.clear_all();  // as far as we cleanup select->quick
     table->sort.io_cache= tablesort_result_cache;
   }
   tab->set_condition(NULL, __LINE__);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (olav.sandstaa:3745 to 3746) Bug#12667154Olav Sandstaa12 Mar