MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Gleb Shchepa Date:May 13 2009 7:54am
Subject:bzr push into mysql-5.1 branch (gshchepa:2857 to 2858) Bug#44290
View as plain text  
 2858 Gleb Shchepa	2009-05-13
      Bug #44290: explain crashes for subquery with distinct in
                  SQL_SELECT::test_quick_select
      
      The crash was caused by an incomplete cleanup of JOIN_TAB::select
      during the filesort of rows for GROUP BY clause inside a subquery.
      Queries where a quick index access is replaced with filesort was
      was affected. For example:
      
        SELECT 1 FROM
          (SELECT COUNT(DISTINCT c1) FROM t1
             WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x
      
      Quick index access related data in the SQL_SELECT::test_quick_select
      function was inconsistent after an incomplete cleanup.
      This function has been completed to prevent crashes in the
      SQL_SELECT::test_quick_select function.
     @ mysql-test/include/mix1.inc
        Add test case for bug #44290.
     @ mysql-test/r/innodb_mysql.result
        Add test case for bug #44290.
     @ sql/sql_select.cc
        Bug #44290: explain crashes for subquery with distinct in
                    SQL_SELECT::test_quick_select
        
        Quick index access related data in the SQL_SELECT::test_quick_select
        function was inconsistent after an incomplete cleanup.
        This function has been completed to prevent crashes in the
        SQL_SELECT::test_quick_select function.

    modified:
      mysql-test/include/mix1.inc
      mysql-test/r/innodb_mysql.result
      sql/sql_select.cc
 2857 Joerg Bruehe	2009-05-08 [merge]
      Merge main 5.1 into 5.1-build
      
      165 changesets with 23 conflicts:
      Text conflict in mysql-test/r/lock_multi.result
      Text conflict in mysql-test/t/lock_multi.test
      Text conflict in mysql-test/t/mysqldump.test
      Text conflict in sql/item_strfunc.cc
      Text conflict in sql/log.cc
      Text conflict in sql/log_event.cc
      Text conflict in sql/parse_file.cc
      Text conflict in sql/slave.cc
      Text conflict in sql/sp.cc
      Text conflict in sql/sp_head.cc
      Text conflict in sql/sql_acl.cc
      Text conflict in sql/sql_base.cc
      Text conflict in sql/sql_class.cc
      Text conflict in sql/sql_crypt.cc
      Text conflict in sql/sql_db.cc
      Text conflict in sql/sql_lex.cc
      Text conflict in sql/sql_parse.cc
      Text conflict in sql/sql_select.cc
      Text conflict in sql/sql_table.cc
      Text conflict in sql/sql_view.cc
      Text conflict in storage/innobase/handler/ha_innodb.cc
      Text conflict in storage/myisam/mi_packrec.c
      Text conflict in tests/mysql_client_test.c
      
      Updates to Innobase, taken from main 5.1:
      bzr: ERROR: Some change isn't sane:
      File mysql-test/r/innodb-semi-consistent.result is owned by Innobase and should not be updated.
      File mysql-test/t/innodb-semi-consistent.test is owned by Innobase and should not be updated.
      File storage/innobase/handler/ha_innodb.cc is owned by Innobase and should not be updated.
      File storage/innobase/ibuf/ibuf0ibuf.c is owned by Innobase and should not be updated.
      File storage/innobase/include/row0mysql.h is owned by Innobase and should not be updated.
      File storage/innobase/include/srv0srv.h is owned by Innobase and should not be updated.
      File storage/innobase/include/trx0trx.h is owned by Innobase and should not be updated.
      File storage/innobase/include/trx0trx.ic is owned by Innobase and should not be updated.
      File storage/innobase/lock/lock0lock.c is owned by Innobase and should not be updated.
      File storage/innobase/page/page0cur.c is owned by Innobase and should not be updated.
      File storage/innobase/row/row0mysql.c is owned by Innobase and should not be updated.
      File storage/innobase/row/row0sel.c is owned by Innobase and should not be updated.
      File storage/innobase/srv/srv0srv.c is owned by Innobase and should not be updated.
      File storage/innobase/trx/trx0trx.c is owned by Innobase and should not be updated.
      (Set env var 'ALLOW_UPDATE_INNOBASE_OWNED' to override.)

    removed:
      mysql-test/suite/rpl/t/rpl_000015-slave.sh
    added:
      mysql-test/include/diff_master_slave.inc
      mysql-test/include/kill_query.inc
      mysql-test/include/kill_query_and_diff_master_slave.inc
      mysql-test/include/wait_for_status_var.inc
      mysql-test/r/myisam_crash_before_flush_keys.result
      mysql-test/r/myisam_debug.result
      mysql-test/r/parser_not_embedded.result
      mysql-test/std_data/bug37631.MYD
      mysql-test/std_data/bug37631.MYI
      mysql-test/std_data/bug37631.frm
      mysql-test/suite/bugs/r/rpl_bug38205.result
      mysql-test/suite/bugs/t/rpl_bug38205.test
      mysql-test/suite/ibmdb2i/
      mysql-test/suite/ibmdb2i/include/
      mysql-test/suite/ibmdb2i/include/have_i61.inc
      mysql-test/suite/ibmdb2i/include/have_ibmdb2i.inc
      mysql-test/suite/ibmdb2i/r/
      mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44020.result
      mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44025.result
      mysql-test/suite/ibmdb2i/t/
      mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44020.test
      mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44025.test
      mysql-test/suite/rpl/r/rpl_bug38694.result
      mysql-test/suite/rpl/r/rpl_init_slave_errors.result
      mysql-test/suite/rpl/r/rpl_killed_ddl.result
      mysql-test/suite/rpl/t/rpl_bug38694-slave.opt
      mysql-test/suite/rpl/t/rpl_bug38694.test
      mysql-test/suite/rpl/t/rpl_init_slave_errors.test
      mysql-test/suite/rpl/t/rpl_killed_ddl-master.opt
      mysql-test/suite/rpl/t/rpl_killed_ddl.test
      mysql-test/suite/rpl/t/rpl_start_stop_slave-slave.opt
      mysql-test/t/myisam_crash_before_flush_keys-master.opt
      mysql-test/t/myisam_crash_before_flush_keys.test
      mysql-test/t/myisam_debug.test
      mysql-test/t/parser_not_embedded.test
    renamed:
      mysql-test/r/rpl_name_const.result => mysql-test/suite/rpl/r/rpl_name_const.result
      mysql-test/t/rpl_name_const.test => mysql-test/suite/rpl/t/rpl_name_const.test
    modified:
      README
      client/mysql.cc
      cmd-line-utils/libedit/term.c
      include/thr_lock.h
      mysql-test/extra/rpl_tests/rpl_deadlock.test
      mysql-test/include/handler.inc
      mysql-test/mysql-test-run.pl
      mysql-test/r/count_distinct3.result
      mysql-test/r/fulltext.result
      mysql-test/r/func_des_encrypt.result
      mysql-test/r/func_encrypt.result
      mysql-test/r/func_set.result
      mysql-test/r/func_str.result
      mysql-test/r/gis-rtree.result
      mysql-test/r/gis.result
      mysql-test/r/handler_innodb.result
      mysql-test/r/handler_myisam.result
      mysql-test/r/innodb-semi-consistent.result
      mysql-test/r/innodb.result
      mysql-test/r/insert.result
      mysql-test/r/lock_multi.result
      mysql-test/r/merge.result
      mysql-test/r/myisam.result
      mysql-test/r/myisampack.result
      mysql-test/r/mysqlbinlog_row_big.result
      mysql-test/r/mysqldump.result
      mysql-test/r/not_embedded_server.result
      mysql-test/r/parser.result
      mysql-test/r/partition_mgm.result
      mysql-test/r/repair.result
      mysql-test/r/select.result
      mysql-test/r/sp.result
      mysql-test/r/upgrade.result
      mysql-test/r/varbinary.result
      mysql-test/r/variables-notembedded.result
      mysql-test/suite/binlog/r/binlog_stm_ps.result
      mysql-test/suite/binlog/r/binlog_unsafe.result
      mysql-test/suite/binlog/t/binlog_unsafe.test
      mysql-test/suite/funcs_2/charset/charset_master.test
      mysql-test/suite/rpl/include/rpl_mixed_ddl.inc
      mysql-test/suite/rpl/r/rpl_bug33931.result
      mysql-test/suite/rpl/r/rpl_deadlock_innodb.result
      mysql-test/suite/rpl/r/rpl_idempotency.result
      mysql-test/suite/rpl/r/rpl_skip_error.result
      mysql-test/suite/rpl/r/rpl_start_stop_slave.result
      mysql-test/suite/rpl/r/rpl_stm_loadfile.result
      mysql-test/suite/rpl/r/rpl_udf.result
      mysql-test/suite/rpl/t/disabled.def
      mysql-test/suite/rpl/t/rpl_binlog_corruption.test
      mysql-test/suite/rpl/t/rpl_bug33931.test
      mysql-test/suite/rpl/t/rpl_idempotency.test
      mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
      mysql-test/suite/rpl/t/rpl_skip_error.test
      mysql-test/suite/rpl/t/rpl_start_stop_slave.test
      mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result
      mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result
      mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result
      mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result
      mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result
      mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result
      mysql-test/suite/sys_vars/r/log_warnings_basic_64.result
      mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result
      mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result
      mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result
      mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result
      mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result
      mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result
      mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result
      mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result
      mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result
      mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result
      mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result
      mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result
      mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result
      mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result
      mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result
      mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result
      mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result
      mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result
      mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result
      mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result
      mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result
      mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result
      mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result
      mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result
      mysql-test/t/count_distinct3.test
      mysql-test/t/fulltext.test
      mysql-test/t/func_des_encrypt.test
      mysql-test/t/func_encrypt.test
      mysql-test/t/func_set.test
      mysql-test/t/func_str.test
      mysql-test/t/gis-rtree.test
      mysql-test/t/gis.test
      mysql-test/t/innodb-semi-consistent.test
      mysql-test/t/innodb.test
      mysql-test/t/insert.test
      mysql-test/t/lock_multi.test
      mysql-test/t/merge.test
      mysql-test/t/myisam.test
      mysql-test/t/myisampack.test
      mysql-test/t/mysqlbinlog_row_big.test
      mysql-test/t/mysqldump.test
      mysql-test/t/not_embedded_server.test
      mysql-test/t/parser.test
      mysql-test/t/partition_mgm.test
      mysql-test/t/select.test
      mysql-test/t/sp.test
      mysql-test/t/sp_trans_log.test
      mysql-test/t/upgrade.test
      mysql-test/t/variables-notembedded-master.opt
      mysys/charset.c
      mysys/mf_keycache.c
      mysys/my_init.c
      scripts/mysqld_multi.sh
      scripts/mysqlhotcopy.sh
      sql/events.cc
      sql/field.cc
      sql/item.cc
      sql/item_func.cc
      sql/item_geofunc.cc
      sql/item_strfunc.cc
      sql/item_strfunc.h
      sql/log.cc
      sql/log_event.cc
      sql/parse_file.cc
      sql/parse_file.h
      sql/rpl_filter.cc
      sql/share/errmsg.txt
      sql/slave.cc
      sql/sp.cc
      sql/sp_head.cc
      sql/sp_head.h
      sql/sp_pcontext.cc
      sql/sp_pcontext.h
      sql/sql_acl.cc
      sql/sql_base.cc
      sql/sql_class.cc
      sql/sql_crypt.cc
      sql/sql_crypt.h
      sql/sql_db.cc
      sql/sql_handler.cc
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_parse.cc
      sql/sql_rename.cc
      sql/sql_repl.cc
      sql/sql_select.cc
      sql/sql_table.cc
      sql/sql_test.cc
      sql/sql_view.cc
      sql/sql_view.h
      sql/sql_yacc.yy
      storage/ibmdb2i/Makefile.am
      storage/ibmdb2i/db2i_collationSupport.cc
      storage/ibmdb2i/db2i_misc.h
      storage/ibmdb2i/ha_ibmdb2i.cc
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/ibuf/ibuf0ibuf.c
      storage/innobase/include/row0mysql.h
      storage/innobase/include/srv0srv.h
      storage/innobase/include/trx0trx.h
      storage/innobase/include/trx0trx.ic
      storage/innobase/lock/lock0lock.c
      storage/innobase/page/page0cur.c
      storage/innobase/row/row0mysql.c
      storage/innobase/row/row0sel.c
      storage/innobase/srv/srv0srv.c
      storage/innobase/trx/trx0trx.c
      storage/myisam/ft_boolean_search.c
      storage/myisam/ha_myisam.cc
      storage/myisam/mi_close.c
      storage/myisam/mi_delete.c
      storage/myisam/mi_dynrec.c
      storage/myisam/mi_open.c
      storage/myisam/mi_packrec.c
      storage/myisam/mi_write.c
      storage/myisam/myisamchk.c
      storage/myisammrg/ha_myisammrg.cc
      storage/ndb/tools/restore/consumer_restore.cpp
      storage/ndb/tools/restore/consumer_restorem.cpp
      tests/mysql_client_test.c
      win/Makefile.am
=== modified file 'mysql-test/include/mix1.inc'
--- a/mysql-test/include/mix1.inc	2009-04-02 08:21:51 +0000
+++ b/mysql-test/include/mix1.inc	2009-05-13 07:51:39 +0000
@@ -1516,4 +1516,23 @@ DROP TABLE t1;
 # DROP TABLE t1;
 #
 
+--echo #
+--echo # Bug #44290: explain crashes for subquery with distinct in
+--echo #             SQL_SELECT::test_quick_select
+--echo #             (reproduced only with InnoDB tables)
+--echo #
+
+eval
+CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3))
+  ENGINE=$engine_type;
+INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
+
+SELECT 1 FROM (SELECT COUNT(DISTINCT c1) 
+                 FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
+EXPLAIN 
+SELECT 1 FROM (SELECT COUNT(DISTINCT c1) 
+                 FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
+
+DROP TABLE t1;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/r/innodb_mysql.result'
--- a/mysql-test/r/innodb_mysql.result	2009-03-30 08:44:17 +0000
+++ b/mysql-test/r/innodb_mysql.result	2009-05-13 07:51:39 +0000
@@ -1687,6 +1687,25 @@ vid	tid	idx	name	type
 3	1	2	c1	NULL
 3	1	1	pk	NULL
 DROP TABLE t1;
+#
+# Bug #44290: explain crashes for subquery with distinct in
+#             SQL_SELECT::test_quick_select
+#             (reproduced only with InnoDB tables)
+#
+CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3))
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
+SELECT 1 FROM (SELECT COUNT(DISTINCT c1) 
+FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
+1
+1
+EXPLAIN 
+SELECT 1 FROM (SELECT COUNT(DISTINCT c1) 
+FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	1	
+2	DERIVED	t1	index	c3,c2	c2	10	NULL	5	
+DROP TABLE t1;
 End of 5.1 tests
 drop table if exists t1, t2, t3;
 create table t1(a int);

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2009-04-29 02:59:10 +0000
+++ b/sql/sql_select.cc	2009-05-13 07:51:39 +0000
@@ -13471,6 +13471,7 @@ create_sort_index(THD *thd, JOIN *join, 
   {
     select->cleanup();				// filesort did select
     tab->select= 0;
+    table->quick_keys.clear_all();  // as far as we cleanup select->quick
   }
   tab->select_cond=0;
   tab->last_inner= 0;


Attachment: [text/bzr-bundle] bzr/gshchepa@mysql.com-20090513075139-g50shsfjaf1dstdn.bundle
Thread
bzr push into mysql-5.1 branch (gshchepa:2857 to 2858) Bug#44290Gleb Shchepa13 May