List:Commits« Previous MessageNext Message »
From:Jorgen Loland Date:January 10 2011 2:55pm
Subject:bzr push into mysql-next-mr-bugfixing branch (jorgen.loland:3246 to 3247)
WL#4800
View as plain text  
 3247 Jorgen Loland	2011-01-10
      WL#4800: Fix some review comments by Tor.
     @ sql/opt_trace.h
        Updating comments: EXECUTE is not traced anymore, it's the executed statement
        which is (one level below, in terms of stack frames...).

    modified:
      include/mysql/plugin.h
      sql/item_subselect.cc
      sql/opt_range.cc
      sql/opt_trace.h
      sql/sql_select.cc
 3246 Guilhem Bichot	2011-01-03
      Bugfix: when a view is merged into the parent query, the view's WHERE
      clause, merged into the parent query's WHERE clause, was not displaid
      in the expanded query. It is because we printed the expanded query
      too early, in open_tables(), whereas the WHERE is merged later, in
      JOIN::prepare().
     @ mysql-test/include/optimizer_trace.inc
        Some traces grow a bit: fix test so that its intention is preserved.
     @ mysql-test/r/optimizer_trace2.result
        expanded query is in join_preparation now
     @ mysql-test/r/optimizer_trace_charset.result
        expanded query is in join_preparation now
     @ mysql-test/r/optimizer_trace_no_prot.result
        Expanded query is in join_preparation now.
        Desired effect of this change: a merged view's WHERE is not missing
        from expanded query anymore (look at the first testcase involving
        view "v1").
        Side effects:
        - statements which don't call JOIN::prepare() show no expanded query
        (INSERT VALUES, single-table DELETE and UPDATE). Not too serious,
        their expanded query wasn't informative anyway.
        - one expanded query per select_lex: in particular, one expanded query
        per subquery and one complete expanded query for the top query;
        we used to have one expanded query only for the top query.
        - we now see an expanded query for the fake SELECT (the one created
        for UNION); not informative though
        - for "SELECT ... WHERE x IN (SELECT ...)", JOIN::prepare() of
        select#1 (top select) first calls JOIN::prepare()
        of select#2 (subquery) which will show the expanded subquery
        mostly unchanged (good); that JOIN::prepare() later transforms
        IN(subquery) in EXISTS(subquery), so when we come back
        to JOIN::prepare() of select#1 and print the expanded top
        query, it prints EXISTS, so it's not really the "original top
        query" but rather "the original top query but with transformed
        subqueries". This isn't so bad, as the original subquery was
        printed earlier in the trace.
        - same for "WHERE x > ANY(subq)": ">ANY -> >MIN" is visible
        in the top query's expanded query
        - expanded query shows cached equalities (look for "<cache>"),
        which is not the original query (bad) but gives more insight (good)
        - expanded query for "SELECT *" lists all fields (because
        printing the expanded query happens after substitution of "*").
     @ mysql-test/r/optimizer_trace_ps_prot.result
        Same comments as for optimizer_trace_no_prot.result.
        Additionally:
        - non-informative "<no matter>" printouts for Item_ref are
        gone, replaced by field's name; a good side-effect of the change to
        item.cc
     @ mysql-test/r/optimizer_trace_range.result
        expanded query is in join_preparation now
     @ sql/item.cc
        code can be reverted to how it is in trunk. We had to test "fixed" because
        we printed the expanded query at an early stage, where the Item_ref
        may be "dangling". Now that we print in JOIN::prepare(), after
        fix_fields(), Item_ref is not dangling.
     @ sql/mysqld.h
        printing expanded view definition is not needed anymore:
        - it worked only for a materialized view
        - but for a materialized view, JOIN::prepare() is called
        on it, and now JOIN::prepare() prints the expanded query
        which is itself the view's definition
        - view's definition is anyway not absolutely needed,
        as SHOW CREATE VIEW gives the same info.
     @ sql/opt_trace2server.cc
        opt_trace_print_expanded_query() is a bit simpler now, because we come
        to it from JOIN::prepare(), which eliminates some pathological cases
        which we had when coming from open_tables()
     @ sql/sql_base.cc
        expanded query is not printed in open_tables() anymore
     @ sql/sql_select.cc
        expanded query is printed in JOIN::prepare().
        View definition needn't be printed.
        Print "fake" for fake select numbers, as already do in
        opt_trace_add_select_number()
     @ sql/sql_view.cc
        mention in the trace the select number for the view's definition,
        when we open a view. This is useful to understand that a JOIN::prepare()
        is for a view (this is the case if the join_preparation object
        mentions the same select# as the view).

    modified:
      mysql-test/include/optimizer_trace.inc
      mysql-test/r/optimizer_trace2.result
      mysql-test/r/optimizer_trace_charset.result
      mysql-test/r/optimizer_trace_no_prot.result
      mysql-test/r/optimizer_trace_ps_prot.result
      mysql-test/r/optimizer_trace_range.result
      sql/item.cc
      sql/mysqld.h
      sql/opt_trace.h
      sql/opt_trace2server.cc
      sql/sql_base.cc
      sql/sql_select.cc
      sql/sql_view.cc
=== modified file 'include/mysql/plugin.h'
--- a/include/mysql/plugin.h	2010-09-27 09:26:39 +0000
+++ b/include/mysql/plugin.h	2011-01-10 14:55:06 +0000
@@ -127,9 +127,9 @@ __MYSQL_DECLARE_PLUGIN(NAME, \
 enum enum_mysql_show_type
 {
   SHOW_UNDEF, SHOW_BOOL,
-  SHOW_INT, ///< shown as _unsigned_ int
-  SHOW_LONG, ///< shown as _unsigned_ long
-  SHOW_LONGLONG, ///< shown as _unsigned_ longlong
+  SHOW_INT,        ///< shown as _unsigned_ int
+  SHOW_LONG,       ///< shown as _unsigned_ long
+  SHOW_LONGLONG,   ///< shown as _unsigned_ longlong
   SHOW_CHAR, SHOW_CHAR_PTR,
   SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
   SHOW_always_last

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2010-09-27 09:26:39 +0000
+++ b/sql/item_subselect.cc	2011-01-10 14:55:06 +0000
@@ -1075,8 +1075,9 @@ Item_in_subselect::single_value_transfor
 	!(select_lex->next_select()) &&
         select_lex->table_list.elements)
     {
-      OPT_TRACE_TRANSFO(thd->opt_trace, oto0, oto1, select_lex->select_number,
-                        "> ALL/ANY (SELECT)", "SELECT(MIN)");
+      OPT_TRACE_TRANSFORM(thd->opt_trace, oto0, oto1,
+                          select_lex->select_number,
+                          "> ALL/ANY (SELECT)", "SELECT(MIN)");
       oto1.add("chosen", true);
       Item_sum_hybrid *item;
       nesting_map save_allow_sum_func;
@@ -1123,8 +1124,9 @@ Item_in_subselect::single_value_transfor
     }
     else
     {
-      OPT_TRACE_TRANSFO(thd->opt_trace, oto0, oto1, select_lex->select_number,
-                        "> ALL/ANY (SELECT)", "MIN (SELECT)");
+      OPT_TRACE_TRANSFORM(thd->opt_trace, oto0, oto1,
+                          select_lex->select_number,
+                          "> ALL/ANY (SELECT)", "MIN (SELECT)");
       oto1.add("chosen", true);
       Item_maxmin_subselect *item;
       subs= item= new Item_maxmin_subselect(thd, this, select_lex, func->l_op());
@@ -1229,8 +1231,8 @@ Item_in_subselect::single_value_in_to_ex
   SELECT_LEX *select_lex= join->select_lex;
   DBUG_ENTER("Item_in_subselect::single_value_in_to_exists_transformer");
 
-  OPT_TRACE_TRANSFO(thd->opt_trace, oto0, oto1, select_lex->select_number,
-                    "IN (SELECT)", "EXISTS (CORRELATED SELECT)");
+  OPT_TRACE_TRANSFORM(thd->opt_trace, oto0, oto1, select_lex->select_number,
+                      "IN (SELECT)", "EXISTS (CORRELATED SELECT)");
   oto1.add("chosen", true);
 
   select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
@@ -1503,8 +1505,8 @@ Item_in_subselect::row_value_in_to_exist
                         !select_lex->table_list.elements);
 
   DBUG_ENTER("Item_in_subselect::row_value_in_to_exists_transformer");
-  OPT_TRACE_TRANSFO(thd->opt_trace, oto0, oto1, select_lex->select_number,
-                    "IN (SELECT)", "EXISTS (CORRELATED SELECT)");
+  OPT_TRACE_TRANSFORM(thd->opt_trace, oto0, oto1, select_lex->select_number,
+                      "IN (SELECT)", "EXISTS (CORRELATED SELECT)");
   oto1.add("chosen", true);
 
   select_lex->uncacheable|= UNCACHEABLE_DEPENDENT;
@@ -1885,9 +1887,9 @@ bool Item_in_subselect::setup_engine()
 
     subselect_single_select_engine *old_engine= 
       static_cast<subselect_single_select_engine*>(engine);
-    OPT_TRACE_TRANSFO(thd->opt_trace, oto0, oto1,
-                      old_engine->join->select_lex->select_number,
-                      "IN (SELECT)", "materialization");
+    OPT_TRACE_TRANSFORM(thd->opt_trace, oto0, oto1,
+                        old_engine->join->select_lex->select_number,
+                        "IN (SELECT)", "materialization");
     oto1.add("chosen", true);
 
     if (!(hash_engine= new subselect_hash_sj_engine(thd, this,
@@ -3100,10 +3102,6 @@ bool subselect_uniquesubquery_engine::no
     lookups into the indexed temporary table.
 
   @param tmp_columns  columns of temporary table
-  @param poto         parent Opt_trace_object, for addition of properties; it
-  will go away once BUG#48213 has been pushed (because after that, failure
-  below is not about the presence of BLOBs but a real error causing
-  abortion).
 
   @notice:
     Currently Item_subselect::init() already chooses and creates at parse

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2011-01-03 11:14:55 +0000
+++ b/sql/opt_range.cc	2011-01-10 14:55:06 +0000
@@ -1997,39 +1997,43 @@ public:
   }
 
   void trace_basic_info(const PARAM *param,
-                        Opt_trace_object *trace_object) const
-  {
+                        Opt_trace_object *trace_object) const;
+};
+
+void TRP_RANGE::trace_basic_info(const PARAM *param,
+                                 Opt_trace_object *trace_object) const
+{
 #ifdef OPTIMIZER_TRACE
-    DBUG_ASSERT(param->using_real_indexes);
-    const uint keynr_in_table= param->real_keynr[key_idx];
+  DBUG_ASSERT(param->using_real_indexes);
+  const uint keynr_in_table= param->real_keynr[key_idx];
 
-    const KEY cur_key= param->table->key_info[keynr_in_table];
-    const KEY_PART_INFO *key_part= cur_key.key_part;
+  const KEY &cur_key= param->table->key_info[keynr_in_table];
+  const KEY_PART_INFO *key_part= cur_key.key_part;
 
-    trace_object->add_alnum("type", "range_scan").
-      add_utf8("index", cur_key.name).add("records", records);
+  trace_object->add_alnum("type", "range_scan").
+    add_utf8("index", cur_key.name).add("records", records);
 
-    Opt_trace_array trace_range(param->thd->opt_trace, "ranges");
-    for (const SEL_ARG *current= key;
-         current;
-         current= current->next)
-    {
-      String range_info;
-      range_info.set_charset(system_charset_info);
-      for (const SEL_ARG *part= current;
-           part;
-           part= part->next_key_part)
-      {
-        const KEY_PART_INFO *cur_key_part= key_part + part->part;
-        append_range(&range_info, cur_key_part,
-                     part->min_value, part->max_value,
-                     part->min_flag | part->max_flag);
-      }
-      trace_range.add_utf8(range_info.ptr(), range_info.length());
+  Opt_trace_array trace_range(param->thd->opt_trace, "ranges");
+  for (const SEL_ARG *current= key;
+       current;
+       current= current->next)
+  {
+    String range_info;
+    range_info.set_charset(system_charset_info);
+    for (const SEL_ARG *part= current;
+         part;
+         part= part->next_key_part)
+    {
+      const KEY_PART_INFO *cur_key_part= key_part + part->part;
+      append_range(&range_info, cur_key_part,
+                   part->min_value, part->max_value,
+                   part->min_flag | part->max_flag);
     }
-#endif
+    trace_range.add_utf8(range_info.ptr(), range_info.length());
   }
-};
+#endif
+}
+
 
 typedef struct st_ror_scan_info
 {
@@ -2043,7 +2047,7 @@ typedef struct st_ror_scan_info
   /** Fields used in the query and covered by this ROR scan. */
   MY_BITMAP covered_fields;
   uint      used_fields_covered; ///< # of set bits in covered_fields
-  int       key_rec_length; ///< length of key record (including rowid)
+  int       key_rec_length;      ///< length of key record (including rowid)
 
   /**
     Cost of reading all index records with values in sel_arg intervals set
@@ -2051,7 +2055,7 @@ typedef struct st_ror_scan_info
   */
   double    index_read_cost;
   uint      first_uncovered_field; ///< first unused bit in covered_fields
-  uint      key_components; ///< # of parts in the key
+  uint      key_components;        ///< # of parts in the key
 } ROR_SCAN_INFO;
 
 /* Plan for QUICK_ROR_INTERSECT_SELECT scan. */
@@ -2072,51 +2076,53 @@ public:
   double index_scan_costs; /* SUM(cost(index_scan)) */
 
   void trace_basic_info(const PARAM *param,
-                        Opt_trace_object *trace_object) const
-  {
+                        Opt_trace_object *trace_object) const;
+};
+
+void TRP_ROR_INTERSECT::trace_basic_info(const PARAM *param,
+                                         Opt_trace_object *trace_object) const
+{
 #ifdef OPTIMIZER_TRACE
-    trace_object->add_alnum("type", "index_roworder_intersect").
-      add("records", records).
-      add("cost", read_cost).
-      add("covering", is_covering).
-      add("clustered_pk_scan", cpk_scan != NULL);
-
-    Opt_trace_context *trace_ctx= param->thd->opt_trace;
-    Opt_trace_array ota(trace_ctx, "intersect_of");
-    for (st_ror_scan_info **cur_scan= first_scan;
-         cur_scan != last_scan;
-         cur_scan++)
-    {
-      const KEY cur_key= param->table->key_info[(*cur_scan)->keynr];
-      const KEY_PART_INFO *key_part= cur_key.key_part;
-
-      Opt_trace_object trace_isect_idx(trace_ctx);
-      trace_isect_idx.add_alnum("type", "range_scan").
-        add_utf8("index", cur_key.name).add("records", (*cur_scan)->records);
-
-      Opt_trace_array trace_range(trace_ctx, "ranges");
-      for (const SEL_ARG *current= (*cur_scan)->sel_arg;
-           current;
-           current= current->next)
-      {
-        String range_info;
-        range_info.set_charset(system_charset_info);
-        for (const SEL_ARG *part= current;
-             part;
-             part= part->next_key_part)
-        {
-          const KEY_PART_INFO *cur_key_part= key_part + part->part;
-          append_range(&range_info, cur_key_part,
-                       part->min_value, part->max_value,
-                       part->min_flag | part->max_flag);
-        }
-        trace_range.add_utf8(range_info.ptr(), range_info.length());
+  trace_object->add_alnum("type", "index_roworder_intersect").
+    add("records", records).
+    add("cost", read_cost).
+    add("covering", is_covering).
+    add("clustered_pk_scan", cpk_scan != NULL);
+
+  Opt_trace_context *trace_ctx= param->thd->opt_trace;
+  Opt_trace_array ota(trace_ctx, "intersect_of");
+  for (st_ror_scan_info **cur_scan= first_scan;
+       cur_scan != last_scan;
+       cur_scan++)
+  {
+    const KEY &cur_key= param->table->key_info[(*cur_scan)->keynr];
+    const KEY_PART_INFO *key_part= cur_key.key_part;
+
+    Opt_trace_object trace_isect_idx(trace_ctx);
+    trace_isect_idx.add_alnum("type", "range_scan").
+      add_utf8("index", cur_key.name).add("records", (*cur_scan)->records);
+
+    Opt_trace_array trace_range(trace_ctx, "ranges");
+    for (const SEL_ARG *current= (*cur_scan)->sel_arg;
+         current;
+         current= current->next)
+    {
+      String range_info;
+      range_info.set_charset(system_charset_info);
+      for (const SEL_ARG *part= current;
+           part;
+           part= part->next_key_part)
+      {
+        const KEY_PART_INFO *cur_key_part= key_part + part->part;
+        append_range(&range_info, cur_key_part,
+                     part->min_value, part->max_value,
+                     part->min_flag | part->max_flag);
       }
+      trace_range.add_utf8(range_info.ptr(), range_info.length());
     }
-#endif
   }
-};
-
+#endif
+}
 
 /*
   Plan for QUICK_ROR_UNION_SELECT scan.
@@ -2135,21 +2141,24 @@ public:
   TABLE_READ_PLAN **last_ror;  /* end of the above array */
 
   void trace_basic_info(const PARAM *param,
-                        Opt_trace_object *trace_object) const
-  {
+                        Opt_trace_object *trace_object) const;
+};
+
+void TRP_ROR_UNION::trace_basic_info(const PARAM *param,
+                                     Opt_trace_object *trace_object) const
+{
 #ifdef OPTIMIZER_TRACE
-    trace_object->add_alnum("type", "index_roworder_union");
-    Opt_trace_array ota(param->thd->opt_trace, "union_of");
-    for (TABLE_READ_PLAN **current= first_ror;
-         current != last_ror;
-         current++)
-    {
-      Opt_trace_object trp_info(param->thd->opt_trace);
-      (*current)->trace_basic_info(param, &trp_info);
-    }
-#endif
+  trace_object->add_alnum("type", "index_roworder_union");
+  Opt_trace_array ota(param->thd->opt_trace, "union_of");
+  for (TABLE_READ_PLAN **current= first_ror;
+       current != last_ror;
+       current++)
+  {
+    Opt_trace_object trp_info(param->thd->opt_trace);
+    (*current)->trace_basic_info(param, &trp_info);
   }
-};
+#endif
+}
 
 /*
   Plan for QUICK_INDEX_MERGE_SELECT scan.
@@ -2168,22 +2177,24 @@ public:
   TRP_RANGE **range_scans_end; /* end of the array */
 
   void trace_basic_info(const PARAM *param,
-                        Opt_trace_object *trace_object) const
-  {
-#ifdef OPTIMIZER_TRACE
-    trace_object->add_alnum("type", "index_merge");
-    Opt_trace_array ota(param->thd->opt_trace, "index_merge_of");
-    for (TRP_RANGE **current= range_scans;
-         current != range_scans_end;
-         current++)
-    {
-      Opt_trace_object trp_info(param->thd->opt_trace);
-      (*current)->trace_basic_info(param, &trp_info);
-    }
-#endif
-  }
+                        Opt_trace_object *trace_object) const;
 };
 
+void TRP_INDEX_MERGE::trace_basic_info(const PARAM *param,
+                                       Opt_trace_object *trace_object) const
+{
+#ifdef OPTIMIZER_TRACE
+  trace_object->add_alnum("type", "index_merge");
+  Opt_trace_array ota(param->thd->opt_trace, "index_merge_of");
+  for (TRP_RANGE **current= range_scans;
+       current != range_scans_end;
+       current++)
+  {
+    Opt_trace_object trp_info(param->thd->opt_trace);
+    (*current)->trace_basic_info(param, &trp_info);
+  }
+#endif
+}
 
 /*
   Plan for a QUICK_GROUP_MIN_MAX_SELECT scan. 
@@ -2213,7 +2224,7 @@ private:
   uchar key_infix[MAX_KEY_LENGTH];  ///< Constants from equality predicates
   uint key_infix_len;        ///< Length of key_infix
   SEL_TREE *range_tree;      ///< Represents all range predicates in the query
-  SEL_ARG  *index_tree;   ///< The SEL_ARG sub-tree corresponding to index_info
+  SEL_ARG  *index_tree;      ///< The sub-tree corresponding to index_info
   uint param_idx;            ///< Index of used key in param->key
   bool is_index_scan;        ///< Use index_next() instead of random read
 public:
@@ -2222,52 +2233,7 @@ public:
 public:
 
   void trace_basic_info(const PARAM *param,
-                        Opt_trace_object *trace_object) const
-  {
-#ifdef OPTIMIZER_TRACE
-    trace_object->add_alnum("type", "index_group").
-      add_utf8("index", index_info->name);
-    if (min_max_arg_part)
-      trace_object->add_utf8("group_attribute",
-                             min_max_arg_part->field->field_name);
-    else
-      trace_object->add_null("group_attribute");
-    trace_object->add("min_aggregate", have_min).
-      add("max_aggregate", have_max).
-      add("distinct_aggregate", have_agg_distinct).
-      add("records", records).
-      add("cost", read_cost);
-
-    const KEY_PART_INFO *key_part= index_info->key_part;
-    {
-      Opt_trace_array trace_keyparts(param->thd->opt_trace,
-                                     "key_parts_used_for_access");
-      for (uint partno= 0; partno < used_key_parts; partno++)
-      {
-        const KEY_PART_INFO *cur_key_part= key_part + partno;
-        trace_keyparts.add_utf8(cur_key_part->field->field_name);
-      }
-    }
-    Opt_trace_array trace_range(param->thd->opt_trace, "ranges");
-    for (const SEL_ARG *current= index_tree;
-         current;
-         current= current->next)
-    {
-      String range_info;
-      range_info.set_charset(system_charset_info);
-      for (const SEL_ARG *part= current;
-           part;
-           part= part->next_key_part)
-      {
-        const KEY_PART_INFO *cur_key_part= key_part + part->part;
-        append_range(&range_info, cur_key_part,
-                     part->min_value, part->max_value,
-                     part->min_flag | part->max_flag);
-      }
-      trace_range.add_utf8(range_info.ptr(), range_info.length());
-    }
-#endif
-  }
+                        Opt_trace_object *trace_object) const;
 
   TRP_GROUP_MIN_MAX(bool have_min_arg, bool have_max_arg, 
                     bool have_agg_distinct_arg,
@@ -2297,6 +2263,53 @@ public:
   void use_index_scan() { is_index_scan= TRUE; }
 };
 
+void TRP_GROUP_MIN_MAX::trace_basic_info(const PARAM *param,
+                                         Opt_trace_object *trace_object) const
+{
+#ifdef OPTIMIZER_TRACE
+  trace_object->add_alnum("type", "index_group").
+    add_utf8("index", index_info->name);
+  if (min_max_arg_part)
+    trace_object->add_utf8("group_attribute",
+                           min_max_arg_part->field->field_name);
+  else
+    trace_object->add_null("group_attribute");
+  trace_object->add("min_aggregate", have_min).
+    add("max_aggregate", have_max).
+    add("distinct_aggregate", have_agg_distinct).
+    add("records", records).
+    add("cost", read_cost);
+
+  const KEY_PART_INFO *key_part= index_info->key_part;
+  {
+    Opt_trace_array trace_keyparts(param->thd->opt_trace,
+                                   "key_parts_used_for_access");
+    for (uint partno= 0; partno < used_key_parts; partno++)
+    {
+      const KEY_PART_INFO *cur_key_part= key_part + partno;
+      trace_keyparts.add_utf8(cur_key_part->field->field_name);
+    }
+  }
+  Opt_trace_array trace_range(param->thd->opt_trace, "ranges");
+  for (const SEL_ARG *current= index_tree;
+       current;
+       current= current->next)
+  {
+    String range_info;
+    range_info.set_charset(system_charset_info);
+    for (const SEL_ARG *part= current;
+         part;
+         part= part->next_key_part)
+    {
+      const KEY_PART_INFO *cur_key_part= key_part + part->part;
+      append_range(&range_info, cur_key_part,
+                   part->min_value, part->max_value,
+                   part->min_flag | part->max_flag);
+    }
+    trace_range.add_utf8(range_info.ptr(), range_info.length());
+  }
+#endif
+}
 
 /*
   Fill param->needed_fields with bitmap of fields used in the query.
@@ -6301,7 +6314,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, Item
        field->type() == MYSQL_TYPE_DATETIME))
     field->table->in_use->variables.sql_mode|= MODE_INVALID_DATES;
   {
-    // Note that value may be a stored function call, executed here
+    // Note that value may be a stored function call, executed here.
     err= value->save_in_field_no_warnings(field, 1);
   }
   if (err > 0)
@@ -7962,8 +7975,8 @@ static void step_down_to(String *s, SEL_
       arg->param->table->key_info[arg->real_keyno].key_part + key_tree->part;
 
     append_range(s, key_part,
-                key_tree->min_value, key_tree->max_value,
-                key_tree->min_flag | key_tree->max_flag);
+                 key_tree->min_value, key_tree->max_value,
+                 key_tree->min_flag | key_tree->max_flag);
   }
 #endif
 
@@ -12255,14 +12268,10 @@ static void print_ror_scans_arr(TABLE *t
 
 #endif /* !DBUG_OFF */
 
-/*****************************************************************************
-** Append a range for a single keypart into a stream.
-*****************************************************************************/
-
 #ifdef OPTIMIZER_TRACE
 
 /**
-  Print a key into a stream
+  Print a key to a string
 
   @param[out] out          String the key is appended to
   @param[in]  key_part     Index components description

=== modified file 'sql/opt_trace.h'
--- a/sql/opt_trace.h	2011-01-03 20:36:18 +0000
+++ b/sql/opt_trace.h	2011-01-10 14:55:06 +0000
@@ -1422,7 +1422,7 @@ public:
    @param from           description of the before-transformation state
    @param to             description of the after-transformation state
 */
-#define OPT_TRACE_TRANSFO(trace,object_level0,object_level1,select_number,from,to) \
+#define OPT_TRACE_TRANSFORM(trace,object_level0,object_level1,select_number,from,to) \
   Opt_trace_object object_level0(trace);                                \
   Opt_trace_object object_level1(trace, "transformation");              \
   opt_trace_add_select_number(&object_level1, select_number);           \

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-01-03 20:36:18 +0000
+++ b/sql/sql_select.cc	2011-01-10 14:55:06 +0000
@@ -817,7 +817,8 @@ bool resolve_subquery(THD *thd, JOIN *jo
 {
   DBUG_ENTER("resolve_subquery");
 
-  int8 choice= 0; // 1=semijoin, 2=materialization, 0=other_or_none
+  enum subquery_type {SQ_NONE, SQ_SEMIJOIN, SQ_MATERIALIZATION};
+  subquery_type sq_choice= SQ_NONE;
   bool types_problem= false; // if types prevented subq materialization
   SELECT_LEX *select_lex= join->select_lex;
 
@@ -923,7 +924,7 @@ bool resolve_subquery(THD *thd, JOIN *jo
     /* Register the subquery for further processing in flatten_subqueries() */
     select_lex->outer_select()->join->
       sj_subselects.append(thd->mem_root, in_exists_predicate);
-    choice= 1;
+    sq_choice= SQ_SEMIJOIN;
   }
   else
   {
@@ -979,7 +980,7 @@ bool resolve_subquery(THD *thd, JOIN *jo
       if (subquery_types_allow_materialization(in_predicate))             // 7
       {
         in_predicate->exec_method= Item_exists_subselect::EXEC_MATERIALIZATION;
-        choice= 2;
+        sq_choice= SQ_MATERIALIZATION;
       }
       else
         types_problem= true;
@@ -990,21 +991,21 @@ bool resolve_subquery(THD *thd, JOIN *jo
   if (subq_predicate_substype == Item_subselect::IN_SUBS)
   {
     {
-      OPT_TRACE_TRANSFO(trace, oto, oto1, select_lex->select_number,
-                        "IN (SELECT)", "semijoin");
-      oto1.add("chosen", choice == 1);
-    }
-    if (choice != 1)
-    {
-      OPT_TRACE_TRANSFO(trace, oto0, oto1, select_lex->select_number,
-                        "IN (SELECT)", "materialization");
-      oto1.add("chosen", choice == 2);
+      OPT_TRACE_TRANSFORM(trace, oto, oto1, select_lex->select_number,
+                          "IN (SELECT)", "semijoin");
+      oto1.add("chosen", sq_choice == SQ_SEMIJOIN);
+    }
+    if (sq_choice != SQ_SEMIJOIN)
+    {
+      OPT_TRACE_TRANSFORM(trace, oto0, oto1, select_lex->select_number,
+                          "IN (SELECT)", "materialization");
+      oto1.add("chosen", sq_choice == SQ_MATERIALIZATION);
       if (types_problem)
         oto1.add_alnum("cause", "field_types");
     }
   }
 
-  if (choice != 1 &&
+  if (sq_choice != SQ_SEMIJOIN &&
       subq_predicate->select_transformer(join) == Item_subselect::RES_ERROR)
     DBUG_RETURN(TRUE);
 
@@ -4107,9 +4108,9 @@ bool JOIN::flatten_subqueries()
            tables + (*subq)->unit->first_select()->join->tables < MAX_TABLES;
          subq++)
     {
-      OPT_TRACE_TRANSFO(trace, oto0, oto1,
-                        (*subq)->get_select_lex()->select_number,
-                        "IN (SELECT)", "semijoin");
+      OPT_TRACE_TRANSFORM(trace, oto0, oto1,
+                          (*subq)->get_select_lex()->select_number,
+                          "IN (SELECT)", "semijoin");
       oto1.add("chosen", true);
       if (convert_subquery_to_semijoin(this, *subq))
         DBUG_RETURN(TRUE);
@@ -4123,9 +4124,9 @@ skip_conversion:
   for (; subq!= subq_end; subq++)
   {
     {
-      OPT_TRACE_TRANSFO(trace, oto0, oto1,
-                        (*subq)->get_select_lex()->select_number,
-                        "IN (SELECT)", "semijoin");
+      OPT_TRACE_TRANSFORM(trace, oto0, oto1,
+                          (*subq)->get_select_lex()->select_number,
+                          "IN (SELECT)", "semijoin");
       if (outer_join_objection)
         oto1.add_alnum("cause", "outer_join");
       oto1.add("chosen", false);
@@ -6492,8 +6493,7 @@ add_group_and_distinct_keys(JOIN *join, 
   ORDER      *cur_group;
   Item_field *cur_item;
   key_map possible_keys;
-
-  const char* cause;
+  const char *cause;
 
   if (join->group_list)
   { /* Collect all query fields referenced in the GROUP clause. */
@@ -17983,7 +17983,6 @@ int safe_index_read(JOIN_TAB *tab)
    Reads content of constant table
    @param tab  table
    @param pos  position of table in query plan
-   @param trace_array parent Opt_trace_array, for addition of properties
    @retval 0   ok
    @retval >0  error
    @retval <0  ??

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-next-mr-bugfixing branch (jorgen.loland:3246 to 3247)WL#4800Jorgen Loland10 Jan