From: Ole John Aske Date: April 18 2012 10:48am Subject: bzr push into mysql-trunk branch (ole.john.aske:3877 to 3878) List-Archive: http://lists.mysql.com/commits/143538 Message-Id: <20120418104806.E8F46233@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3878 Ole John Aske 2012-04-18 Extracted optimizer part of previous fix for: bug#13901890 SQL NODE CRASHES DURING INSERT SELECT This has to be added as part of WL#5940 as it extends how 'HA_PUSH_BLOCK_CONST_TABLE' prevents JT_EQ_REF to be converted into JT_CONST. Read the commit message for the full fix for more comments: ftp://bugftp.us.oracle.com/upload/bug_13/bug13901890/commit120418%2dI68V%2eeml modified: sql/abstract_query_plan.cc sql/sql_select.cc 3877 Ole John Aske 2012-03-30 Patch sets for WL#5940: 'handler extensions for pushed join' Patches are commited to branch: mysql-trunk-wl5940_2 which are based on mysql-trunk, revno 3875 @ sql/abstract_query_plan.cc Add an abstraction layer on top of the Query Execution Plan (QEP) in order to make it simpler for non-optimizer modules to extract information from the QEP @ sql/abstract_query_plan.h Add an abstraction layer on top of the Query Execution Plan (QEP) in order to make it simpler for non-optimizer modules to extract information from the QEP @ sql/ha_ndbcluster.h Remove the temporary declaration of HA_PUSH flags as they are now available from handler.h @ sql/handler.cc Implements the handlerton extensions required by pushed joins @ sql/handler.h Defines the handler extensions required by pushed joins @ sql/opt_explain.cc Add code to produce EXPLAIN text for pushed joins @ sql/opt_explain_format.h Add ET_PUSHED_JOIN explain. @ sql/opt_explain_json.cc Add ET_PUSHED_JOIN explain. @ sql/opt_explain_traditional.cc Add ET_PUSHED_JOIN explain. @ sql/sql_executor.cc Extends pick_table_access_method() to also set up new access methods used for pushed joins. Also implements the pushed join access methods join_read_linked_first() and join_read_linked_next() @ sql/sql_optimizer.cc Call handler extensions to build pushed joins if supported. Also pick_table_access_method() at end of ::optimize() @ sql/sql_select.cc pick_table_access_method() is being moved to end of JOIN::optimize(). Instead of prematurely setting the access methods in make_join_readinfo(), and having to maintain/change them during optimize, we defer this work until ::optimize() has completed. added: sql/abstract_query_plan.cc sql/abstract_query_plan.h modified: sql/CMakeLists.txt sql/ha_ndbcluster.h sql/handler.cc sql/handler.h sql/opt_explain.cc sql/opt_explain_format.h sql/opt_explain_json.cc sql/opt_explain_traditional.cc sql/sql_executor.cc sql/sql_optimizer.cc sql/sql_select.cc === modified file 'sql/abstract_query_plan.cc' --- a/sql/abstract_query_plan.cc 2012-03-30 06:52:25 +0000 +++ b/sql/abstract_query_plan.cc 2012-04-18 10:46:39 +0000 @@ -322,7 +322,6 @@ namespace AQP switch (join_tab->type) { case JT_EQ_REF: - case JT_CONST: m_index_no= join_tab->ref.key; if (m_index_no == static_cast(join_tab->table->s->primary_key)) @@ -446,6 +445,8 @@ namespace AQP } break; + case JT_CONST: + case JT_SYSTEM: default: /* Other join_types either cannot be pushed or the code analyze them is === modified file 'sql/sql_select.cc' --- a/sql/sql_select.cc 2012-03-30 06:52:25 +0000 +++ b/sql/sql_select.cc 2012-04-18 10:46:39 +0000 @@ -1509,7 +1509,8 @@ bool create_ref_for_key(JOIN *join, JOIN j->type= null_ref_key ? JT_REF_OR_NULL : JT_REF; j->ref.null_ref_key= null_ref_key; } - else if (keyuse_uses_no_tables) + else if (keyuse_uses_no_tables && + !table->file->test_push_flag(HA_PUSH_BLOCK_CONST_TABLE)) { /* This happen if we are using a constant expression in the ON part No bundle (reason: useless for push emails).