List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:May 16 2011 1:01pm
Subject:Re: bzr commit into mysql-trunk branch (tor.didriksen:3088) Bug#12552221
View as plain text  
On 2011-05-16 14:44, Guilhem Bichot wrote:
> So, the only usage of Array I found is in sql_select.h:
>   Array<Item_exists_subselect> sj_subselects;
> which could be translated to using your new class with "object type" 
> == "pointer to Item_exists_subselect" ...? 

indeed:

=== modified file 'sql/sql_select.cc'
--- sql/sql_select.cc    2011-05-16 11:48:23 +0000
+++ sql/sql_select.cc    2011-05-16 12:56:07 +0000
@@ -978,7 +978,7 @@

      /* Register the subquery for further processing in 
flatten_subqueries() */
      select_lex->outer_select()->join->
-      sj_subselects.append(thd->mem_root, in_exists_predicate);
+      sj_subselects.push_back(in_exists_predicate);
    }
    else
    {
@@ -4169,11 +4169,11 @@
    Item_exists_subselect **subq_end;
    DBUG_ENTER("JOIN::flatten_subqueries");

-  if (sj_subselects.elements() == 0)
+  if (sj_subselects.empty())
      DBUG_RETURN(FALSE);

    /* First, convert child join's subqueries. We proceed bottom-up here */
-  for (subq= sj_subselects.front(), subq_end= sj_subselects.back();
+  for (subq= sj_subselects.begin(), subq_end= sj_subselects.end();
         subq != subq_end;
         subq++)
    {
@@ -4206,7 +4206,7 @@
    {
      if (tbl->on_expr || tbl->in_outer_join_nest())
      {
-      subq= sj_subselects.front();
+      subq= sj_subselects.begin();
        arena= thd->activate_stmt_arena_if_needed(&backup);
        goto skip_conversion;
      }
@@ -4219,11 +4219,14 @@
        - prefer correlated subqueries over uncorrelated;
        - prefer subqueries that have greater number of outer tables;
    */
-  sj_subselects.sort(subq_sj_candidate_cmp);
+  my_qsort(sj_subselects.begin(),
+           sj_subselects.size(), sj_subselects.element_size(),
+           reinterpret_cast<qsort_cmp>(subq_sj_candidate_cmp));
+  // sj_subselects.sort(subq_sj_candidate_cmp);
    // #tables-in-parent-query + #tables-in-subquery < MAX_TABLES
    /* Replace all subqueries to be flattened with Item_int(1) */
    arena= thd->activate_stmt_arena_if_needed(&backup);
-  for (subq= sj_subselects.front();
+  for (subq= sj_subselects.begin();
         subq != subq_end &&
         tables + (*subq)->unit->first_select()->join->tables < MAX_TABLES;
         subq++)
@@ -4234,7 +4237,7 @@
        DBUG_RETURN(TRUE); /* purecov: inspected */
    }

-  for (subq= sj_subselects.front();
+  for (subq= sj_subselects.begin();
         subq != subq_end &&
         tables + (*subq)->unit->first_select()->join->tables < MAX_TABLES;
         subq++)

=== modified file 'sql/sql_select.h'
--- sql/sql_select.h    2011-05-16 11:48:23 +0000
+++ sql/sql_select.h    2011-05-16 12:57:28 +0000
@@ -56,6 +56,7 @@
        sj_pred_no(UINT_MAX)
    {}

+
    Key_use(TABLE *table_arg, Item *val_arg, table_map used_tables_arg,
            uint key_arg, uint keypart_arg, uint optimize_arg,
            key_part_map keypart_map_arg, ha_rows ref_table_rows_arg,
@@ -1888,7 +1889,7 @@
    bool union_part; ///< this subselect is part of union
    bool optimized; ///< flag to avoid double optimization in EXPLAIN

-  Array<Item_exists_subselect> sj_subselects;
+  Mem_root_array<Item_exists_subselect*, true> sj_subselects;

    /* Temporary tables used to weed-out semi-join duplicates */
    List<TABLE> sj_tmp_tables;
@@ -1913,7 +1914,7 @@
         select_result *result_arg)
      : keyuse(thd_arg->mem_root),
        fields_list(fields_arg),
-      sj_subselects(thd_arg->mem_root, 4)
+      sj_subselects(thd_arg->mem_root)
    {
      init(thd_arg, fields_arg, select_options_arg, result_arg);
    }


Thread
bzr commit into mysql-trunk branch (tor.didriksen:3088) Bug#12552221Tor Didriksen16 May
  • Re: bzr commit into mysql-trunk branch (tor.didriksen:3088) Bug#12552221Guilhem Bichot16 May
    • Re: bzr commit into mysql-trunk branch (tor.didriksen:3088) Bug#12552221Tor Didriksen16 May
      • Re: bzr commit into mysql-trunk branch (tor.didriksen:3088) Bug#12552221Guilhem Bichot16 May
        • Re: bzr commit into mysql-trunk branch (tor.didriksen:3088) Bug#12552221Tor Didriksen16 May
          • Re: bzr commit into mysql-trunk branch (tor.didriksen:3088) Bug#12552221Guilhem Bichot16 May
  • Re: bzr commit into mysql-trunk branch (tor.didriksen:3088) Bug#12552221Davi Arnaut16 May