From: Tor Didriksen Date: July 27 2010 11:49am Subject: bzr push into mysql-next-mr-opt-backporting branch (tor.didriksen:3218 to 3219) Bug#55042 List-Archive: http://lists.mysql.com/commits/114433 X-Bug: 55042 Message-Id: <20100727114923.B4F7C3593@atum07.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5706975216179810358==" --===============5706975216179810358== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 3219 Tor Didriksen 2010-07-27 Bug #55042 valgrind reports error in best_access_path when running subquery_mat_all The code was using loose_scan_pos, even though it was explicitly set to invalid. @ sql/sql_select.cc Terminate search in optimize_wo_join_buffering() if we has a cost of DBL_MAX (as determined by best_access_path()) Remove sj_inner_fanout output argument, it was unused. modified: sql/sql_select.cc 3218 Evgeny Potemkin 2010-07-26 [merge] Manual merge: next-mr-bugfixing => next-mr-opt-backporting. removed: include/config-win.h include/my_trie.h include/my_vle.h libmysql/dll.c mysql-test/r/raid.result mysys/default_modify.c mysys/make-conf.c mysys/mf_wfile.c mysys/my_append.c mysys/my_clock.c mysys/my_dup.c mysys/my_net.c mysys/my_vle.c mysys/test_fn.c mysys/trie.c sql/sql_map.cc sql/sql_map.h sql/sql_olap.cc strings/bmove512.c strings/r_strinstr.c strings/strings-not-used.h strings/strinstr-sparc.s strings/strinstr.c added: mysql-test/include/ctype_unicode520.inc packaging/Makefile.am packaging/WiX/custom_ui.wxs modified: BUILD/SETUP.sh Makefile.am client/mysql.cc client/mysqlbinlog.cc client/mysqldump.c client/mysqltest.cc cmake/os/WindowsCache.cmake config.h.cmake config/ac-macros/character_sets.m4 configure.cmake configure.in extra/replace.c extra/resolve_stack_dump.c extra/yassl/CMakeLists.txt extra/yassl/taocrypt/CMakeLists.txt include/Makefile.am include/atomic/gcc_builtins.h include/atomic/nolock.h include/atomic/x86-gcc.h include/m_ctype.h include/m_string.h include/my_atomic.h include/my_attribute.h include/my_bit.h include/my_bitmap.h include/my_global.h include/my_net.h include/my_nosys.h include/my_sys.h include/myisam.h include/mysql_embed.h libmysql/Makefile.am libmysql/Makefile.shared libmysql/errmsg.c libmysql/libmysql.c libmysql_r/Makefile.am libmysqld/CMakeLists.txt libmysqld/Makefile.am mysql-test/r/ctype_ldml.result mysql-test/r/ctype_uca.result mysql-test/r/ctype_ucs.result mysql-test/r/ctype_utf16_uca.result mysql-test/r/ctype_utf32_uca.result mysql-test/std_data/Index.xml mysql-test/suite/engines/funcs/r/db_alter_collate_utf8.result mysql-test/suite/engines/funcs/t/db_alter_collate_utf8.test mysql-test/suite/perfschema/r/server_init.result mysql-test/suite/perfschema/t/server_init.test mysql-test/suite/rpl/r/rpl_do_grant.result mysql-test/suite/rpl/r/rpl_grant.result mysql-test/suite/rpl/t/rpl_grant.test mysql-test/suite/sys_vars/inc/collation_basic.inc mysql-test/suite/sys_vars/r/collation_connection_basic.result mysql-test/suite/sys_vars/r/collation_database_basic.result mysql-test/suite/sys_vars/r/collation_server_basic.result mysql-test/t/ctype_ldml.test mysql-test/t/ctype_uca.test mysql-test/t/ctype_ucs.test mysql-test/t/ctype_utf16_uca.test mysql-test/t/ctype_utf32_uca.test mysql-test/t/show_check.test mysys/CMakeLists.txt mysys/Makefile.am mysys/charset-def.c mysys/charset.c mysys/checksum.c mysys/default.c mysys/mf_iocache.c mysys/mf_iocache2.c mysys/mf_keycache.c mysys/my_atomic.c mysys/my_bit.c mysys/my_bitmap.c mysys/my_handler.c mysys/my_init.c mysys/my_pthread.c mysys/my_static.c mysys/my_static.h mysys/rijndael.c mysys/test_charset.c mysys/thr_alarm.c packaging/WiX/CMakeLists.txt packaging/WiX/CPackWixConfig.cmake packaging/WiX/create_msi.cmake.in packaging/WiX/extra.wxs.in packaging/WiX/mysql_server.wxs.in regex/regcomp.c regex/regcomp.ih scripts/make_win_bin_dist sql/CMakeLists.txt sql/Makefile.am sql/binlog.cc sql/field.cc sql/field.h sql/field_conv.cc sql/filesort.cc sql/gen_lex_hash.cc sql/ha_partition.cc sql/ha_partition.h sql/handler.cc sql/handler.h sql/hostname.cc sql/item_cmpfunc.cc sql/item_cmpfunc.h sql/item_geofunc.cc sql/item_subselect.h sql/log.h sql/mysqld.cc sql/mysqld.h sql/nt_servc.cc sql/protocol.cc sql/rpl_record.cc sql/rpl_slave.cc sql/sql_acl.cc sql/sql_binlog.cc sql/sql_class.cc sql/sql_error.cc sql/sql_lex.cc sql/sql_lex.h sql/sql_parse.cc sql/sql_plugin.cc sql/sql_priv.h sql/sql_select.cc sql/sql_show.cc sql/sys_vars.cc sql/table.cc sql/udf_example.c storage/csv/ha_tina.cc storage/federated/ha_federated.cc storage/heap/ha_heap.cc storage/heap/hp_test2.c storage/myisam/ft_boolean_search.c storage/myisam/ft_nlq_search.c storage/myisam/ft_parser.c storage/myisam/ft_update.c storage/myisam/mi_check.c storage/myisam/mi_create.c storage/myisam/mi_delete_table.c storage/myisam/mi_dynrec.c storage/myisam/mi_key.c storage/myisam/mi_log.c storage/myisam/mi_open.c storage/myisam/mi_packrec.c storage/myisam/mi_rename.c storage/myisam/mi_static.c storage/myisam/mi_test1.c storage/myisam/mi_test2.c storage/myisam/mi_test3.c storage/myisam/mi_unique.c storage/myisam/mi_write.c storage/myisam/myisam_ftdump.c storage/myisam/myisamchk.c storage/myisam/myisamdef.h storage/myisam/myisamlog.c storage/myisam/myisampack.c storage/myisam/rt_test.c storage/myisam/sp_key.c storage/myisam/sp_test.c storage/myisammrg/ha_myisammrg.cc storage/ndb/include/kernel/signaldata/FsOpenReq.hpp storage/ndb/include/util/ndb_opts.h storage/ndb/src/cw/cpcd/main.cpp storage/ndb/src/kernel/blocks/dbtux/Dbtux.hpp storage/ndb/src/kernel/vm/Configuration.cpp storage/ndb/src/mgmclient/main.cpp storage/ndb/src/mgmsrv/main.cpp storage/ndb/src/ndbapi/TransporterFacade.hpp storage/ndb/test/ndbapi/testIndexStat.cpp storage/ndb/test/ndbapi/test_event_merge.cpp storage/ndb/test/ndbapi/test_event_multi_table.cpp storage/ndb/test/run-test/main.cpp storage/ndb/test/src/NDBT_Test.cpp storage/ndb/test/tools/connect.cpp storage/ndb/tools/delete_all.cpp storage/ndb/tools/desc.cpp storage/ndb/tools/drop_index.cpp storage/ndb/tools/drop_tab.cpp storage/ndb/tools/listTables.cpp storage/ndb/tools/ndb_config.cpp storage/ndb/tools/restore/restore_main.cpp storage/ndb/tools/select_all.cpp storage/ndb/tools/select_count.cpp storage/ndb/tools/waiter.cpp storage/perfschema/pfs_events_waits.cc strings/CMakeLists.txt strings/Makefile.am strings/conf_to_src.c strings/ctype-big5.c strings/ctype-bin.c strings/ctype-cp932.c strings/ctype-czech.c strings/ctype-euc_kr.c strings/ctype-eucjpms.c strings/ctype-extra.c strings/ctype-gb2312.c strings/ctype-gbk.c strings/ctype-latin1.c strings/ctype-mb.c strings/ctype-simple.c strings/ctype-sjis.c strings/ctype-tis620.c strings/ctype-uca.c strings/ctype-ucs2.c strings/ctype-ujis.c strings/ctype-utf8.c strings/ctype-win1250ch.c strings/ctype.c strings/do_ctype.c strings/str_test.c strings/string.doc strings/strings-x86.s strings/uca-dump.c tests/mysql_client_test.c tests/thread_test.c unittest/gunit/gunit_test_main.cc unittest/gunit/thread_utils.cc unittest/gunit/thread_utils.h unittest/mysys/my_atomic-t.c unittest/mytap/tap.c === modified file 'sql/sql_select.cc' --- a/sql/sql_select.cc 2010-07-26 11:34:07 +0000 +++ b/sql/sql_select.cc 2010-07-27 08:46:57 +0000 @@ -13308,9 +13308,9 @@ static bool check_interleaving_with_nj(J no_jbuf_before Don't allow to use join buffering before this table reopt_rec_count OUT New output record count + DBL_MAX if we could find no plan. reopt_cost OUT New join prefix cost - sj_inner_fanout OUT Fanout in the [first_tab; last_tab] range that - is produced by semi-join-inner tables. + DBL_MAX if we could find no plan. DESCRIPTION Given a join prefix [0; ... first_tab], change the access to the tables @@ -13327,13 +13327,14 @@ static bool check_interleaving_with_nj(J void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab, table_map last_remaining_tables, bool first_alt, uint no_jbuf_before, - double *reopt_rec_count, double *reopt_cost, - double *sj_inner_fanout) + double *reopt_rec_count, double *reopt_cost) { double cost, outer_fanout, inner_fanout= 1.0; table_map reopt_remaining_tables= last_remaining_tables; uint i; + DBUG_ENTER("optimize_wo_join_buffering"); + if (first_tab > join->const_tables) { cost= join->positions[first_tab - 1].prefix_cost.total_cost(); @@ -13342,7 +13343,7 @@ void optimize_wo_join_buffering(JOIN *jo else { cost= 0.0; - outer_fanout= 1; + outer_fanout= 1.0; } for (i= first_tab; i <= last_tab; i++) @@ -13357,15 +13358,26 @@ void optimize_wo_join_buffering(JOIN *jo { /* Find the best access method that would not use join buffering */ best_access_path(join, rs, reopt_remaining_tables, i, - test(i < no_jbuf_before), inner_fanout*outer_fanout, + i < no_jbuf_before, inner_fanout * outer_fanout, &pos, &loose_scan_pos); } else pos= join->positions[i]; - if ((i == first_tab && first_alt)) + if (i == first_tab && first_alt) pos= loose_scan_pos; + /* + Terminate search if best_access_path found no possible plan. + Otherwise we will be getting infinite cost when summing up below. + */ + if (pos.read_time == DBL_MAX) + { + *reopt_rec_count= DBL_MAX; + *reopt_cost= DBL_MAX; + DBUG_VOID_RETURN; + } + reopt_remaining_tables &= ~rs->table->map; cost += pos.read_time; @@ -13378,7 +13390,7 @@ void optimize_wo_join_buffering(JOIN *jo *reopt_rec_count= outer_fanout; *reopt_cost= cost; - *sj_inner_fanout= inner_fanout; + DBUG_VOID_RETURN; } @@ -13440,6 +13452,8 @@ void advance_sj_state(JOIN *join, table_ POSITION *pos= join->positions + idx; remaining_tables &= ~new_join_tab->table->map; + DBUG_ENTER("advance_sj_state"); + pos->prefix_cost.convert_from_cost(*current_read_time); pos->prefix_record_count= *current_record_count; pos->sj_strategy= SJ_OPT_NONE; @@ -13535,24 +13549,28 @@ void advance_sj_state(JOIN *join, table_ Got a complete FirstMatch range. Calculate correct costs and fanout */ - double reopt_cost, reopt_rec_count, sj_inner_fanout; + double reopt_cost, reopt_rec_count; optimize_wo_join_buffering(join, pos->first_firstmatch_table, idx, remaining_tables, FALSE, idx, - &reopt_rec_count, &reopt_cost, - &sj_inner_fanout); - /* - We don't yet know what are the other strategies, so pick the - FirstMatch. + &reopt_rec_count, &reopt_cost); + if (reopt_cost < DBL_MAX) + { + /* + We don't yet know what are the other strategies, so pick the + FirstMatch. - We ought to save the alternate POSITIONs produced by - optimize_wo_join_buffering but the problem is that providing save - space uses too much space. Instead, we will re-calculate the - alternate POSITIONs after we've picked the best QEP. - */ - pos->sj_strategy= SJ_OPT_FIRST_MATCH; - *current_read_time= reopt_cost; - *current_record_count= reopt_rec_count; - handled_by_fm_or_ls= pos->firstmatch_need_tables; + We ought to save the alternate POSITIONs produced by + optimize_wo_join_buffering but the problem is that providing save + space uses too much space. Instead, we will re-calculate the + alternate POSITIONs after we've picked the best QEP. + */ + pos->sj_strategy= SJ_OPT_FIRST_MATCH; + *current_read_time= reopt_cost; + *current_record_count= reopt_rec_count; + handled_by_fm_or_ls= pos->firstmatch_need_tables; + } + else + DBUG_PRINT("info", ("Cannot use FirstMatch")); } } } @@ -13599,7 +13617,7 @@ void advance_sj_state(JOIN *join, table_ first=join->positions + pos->first_loosescan_table; uint n_tables= my_count_bits(first->table->emb_sj_nest->sj_inner_tables); /* Got a complete LooseScan range. Calculate its cost */ - double reopt_cost, reopt_rec_count, sj_inner_fanout; + double reopt_cost, reopt_rec_count; /* The same problem as with FirstMatch - we need to save POSITIONs somewhere but reserving space for all cases would require too @@ -13610,18 +13628,23 @@ void advance_sj_state(JOIN *join, table_ TRUE, //first_alt pos->first_loosescan_table + n_tables, &reopt_rec_count, - &reopt_cost, &sj_inner_fanout); - /* - We don't yet have any other strategies that could handle this - semi-join nest (the other options are Duplicate Elimination or - Materialization, which need at least the same set of tables in - the join prefix to be considered) so unconditionally pick the - LooseScan. - */ - pos->sj_strategy= SJ_OPT_LOOSE_SCAN; - *current_read_time= reopt_cost; - *current_record_count= reopt_rec_count; - handled_by_fm_or_ls= first->table->emb_sj_nest->sj_inner_tables; + &reopt_cost); + if (reopt_cost < DBL_MAX) + { + /* + We don't yet have any other strategies that could handle this + semi-join nest (the other options are Duplicate Elimination or + Materialization, which need at least the same set of tables in + the join prefix to be considered) so unconditionally pick the + LooseScan. + */ + pos->sj_strategy= SJ_OPT_LOOSE_SCAN; + *current_read_time= reopt_cost; + *current_record_count= reopt_rec_count; + handled_by_fm_or_ls= first->table->emb_sj_nest->sj_inner_tables; + } + else + DBUG_PRINT("info", ("Cannot use LooseScan")); } } @@ -13876,6 +13899,7 @@ void advance_sj_state(JOIN *join, table_ } } } + DBUG_VOID_RETURN; } --===============5706975216179810358== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/tor.didriksen@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: tor.didriksen@stripped\ # 6283s6li1ch2ah1k # target_branch: file:///export/home/didrik/repo/next-mr-opt-\ # backporting-valgrind/ # testament_sha1: 7c2e391f5f455d9c5ad85d9ff3879f3525bee03b # timestamp: 2010-07-27 13:49:23 +0200 # base_revision_id: epotemkin@stripped\ # 97mj9zm97haxsf6t # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWakuRywAA6B/gHVQCBbZ9/// f/f/wL////pgCGzm3N19689WF7Cdbt7t2W7h1WbNjHCSSCPQjEp6I/SG0jTTFNqNNpoCNDQaGmRp o0aPUEoim9RU/0p5k1Cek1PUA009JowCZMgNAAGRkekDFTMkyU8kzSnpqA9R6Q/U1D1PU9QANAAA DQAEiIp6IyTCmaT0amienqnqeU9CDQDIGgyB6jQ0MhxkwTQyGRkZNDQBoMjCAaDRpkMQ0AEkQTRo mhoJqn6NU9qTZE8hMgekaaAyA0NDRiEy+DCSNvS1Wr14ssJDPHrQQQM0LBF9+w6cuLbMLSvkbSzt 9scXTIPe7xFcqpISlfxUav7s7cFX9VoGvWwgM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