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;
}
Attachment: [text/bzr-bundle] bzr/tor.didriksen@oracle.com-20100727084657-6283s6li1ch2ah1k.bundle
| Thread |
|---|
| • bzr push into mysql-next-mr-opt-backporting branch (tor.didriksen:3218 to3219) Bug#55042 | Tor Didriksen | 27 Jul |