List:Commits« Previous MessageNext Message »
From:Sergey Petrunia Date:July 28 2008 3:48pm
Subject:bzr commit into mysql-6.0-opt-subqueries branch (sergefp:2686)
View as plain text  
#At file:///home/psergey/dev/mysql-6.0-subq-r16/

 2686 Sergey Petrunia	2008-07-28
      Remove deadcode - old version of setup_semijoin_dups_elimination()
modified:
  sql/sql_select.cc

per-file messages:
  sql/sql_select.cc
    Remove deadcode - old version of setup_semijoin_dups_elimination()
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-07-28 15:44:17 +0000
+++ b/sql/sql_select.cc	2008-07-28 15:48:11 +0000
@@ -1162,266 +1162,6 @@ TABLE *create_duplicate_weedout_tmp_tabl
     FALSE  OK 
     TRUE   Out of memory error
 */
-#if 0
-static
-int setup_semijoin_dups_elimination(JOIN *join, ulonglong options, uint no_jbuf_after)
-{
-  table_map cur_map= join->const_table_map | PSEUDO_TABLE_BITS;
-  enum sj_strategy_enum { 
-    SJ_STRATEGY_INVALID,
-    SJ_STRATEGY_INSIDEOUT,
-    SJ_STRATEGY_DUPS_WEEDOUT,
-    SJ_STRATEGY_DUPS_WEEDOUT_JBUF
-  };
-  struct {
-    /* 
-      0 - invalid (EOF marker), 
-      1 - LooseScan, 
-      2 - Temptable (maybe confluent),
-      3 - Temptable with join buffering
-    */
-    enum sj_strategy_enum strategy;
-    uint start_idx; /* Left range bound */
-    uint end_idx;   /* Right range bound */
-    /* 
-      For Temptable strategy: Bitmap of all outer and correlated tables from 
-      all involved join nests.
-    */
-    table_map outer_tables;
-  } dups_ranges [MAX_TABLES];
-
-  TABLE_LIST *emb_insideout_nest= NULL;
-  table_map emb_sj_map= 0;  /* A bitmap of sj-nests (that is, their sj-inner
-                               tables) whose ranges we're in */
-  table_map emb_outer_tables= 0; /* sj-outer tables for those sj-nests */
-  table_map range_start_map; /* table_map at current range start */
-  bool dealing_with_jbuf= FALSE; /* TRUE <=> table within cur range uses join buf */
-  int cur_range= 0;
-  uint i;
-
-  DBUG_ENTER("setup_semijoin_dups_elimination");
-  LINT_INIT(range_start_map); // protected by emb_sj_map
-  /*
-    First pass: locate the duplicate-generating ranges and pick the strategies.
-  */
-  for (i= join->const_tables ; i < join->tables ; i++)
-  {
-    JOIN_TAB *tab=join->join_tab+i;
-    TABLE *table=tab->table;
-    cur_map |= table->map;
-
-    if (join->best_positions[i].use_sj_mat)
-      continue;
-
-    if (tab->emb_sj_nest) // Encountered an sj-inner table
-    {
-      if (!emb_sj_map)
-      {
-        dups_ranges[cur_range].start_idx= i;
-        range_start_map= cur_map & ~table->map;
-        /*
-          Remember if this is a possible start of range that is covered by
-          the LooseScan strategy (the reason that it is not covered could
-          be that it overlaps with anther semi-join's range. we don't
-          support LooseScan for joined ranges)
-        */
-        if (join->best_positions[i].loosescan_key != MAX_KEY)
-          emb_insideout_nest= tab->emb_sj_nest;
-      }
-
-      emb_sj_map |= tab->emb_sj_nest->sj_inner_tables;
-      emb_outer_tables |= tab->emb_sj_nest->nested_join->sj_depends_on;
-
-      if (tab->emb_sj_nest != emb_insideout_nest)
-      {
-        /*
-          Two different semi-joins interleave. This cannot be handled by
-          LooseScan strategy.
-        */
-        emb_insideout_nest= NULL;
-      }
-    }
-
-    if (emb_sj_map) /* We're in duplicate-generating range */
-    {
-      if (i != join->const_tables && !(options & SELECT_NO_JOIN_CACHE) &&
-          tab->type == JT_ALL && tab->use_quick != 2 && !tab->first_inner &&
-          i <= no_jbuf_after && !dealing_with_jbuf)
-      {
-        /*
-          This table uses join buffering, which makes use of FirstMatch or 
-          LooseScan strategies impossible for the current and (we assume) 
-          preceding duplicate-producing ranges.
-          That is, for the join order:
-
-              x x [ x  x]  x  [x x x]  x  [x x X*  x] x
-                  |     |     |     |          | \
-                  +-----+     +-----+          |  join buffering use
-                     r1          r2         we're here
-
-          we'll have to remove r1 and r2 and use duplicate-elimination
-          strategy that spans all the tables, starting from the very 1st
-          one.
-        */
-        dealing_with_jbuf= TRUE;
-        emb_insideout_nest= FALSE;
-
-        /* 
-          Absorb all preceding duplicate-eliminating ranges. Their strategies
-          do not matter: 
-        */
-        for (int prev_range= 0; prev_range < cur_range; prev_range++)
-        {
-          dups_ranges[cur_range].outer_tables |= 
-            dups_ranges[prev_range].outer_tables;
-        }
-        dups_ranges[0].start_idx= 0; /* Will need to start from the 1st table */
-        dups_ranges[0].outer_tables= dups_ranges[cur_range].outer_tables;
-        cur_range=  0;
-      }
-
-      /*
-        Check if we are at the end of duplicate-producing range. We are if
-
-        1. It's an LooseScan range (which presumes all correlated tables are
-           in the prefix), and all inner tables are in the join order prefix,
-           or
-        2. It's a DuplicateElimination range (possibly covering several
-           SJ-nests), and all inner, outer, and correlated tables of all 
-           sj-nests are in the join order prefix.
-      */
-      bool end_of_range= FALSE;
-      if (emb_insideout_nest && 
-          bitmap_covers(cur_map, emb_insideout_nest->sj_inner_tables))
-      {
-        /* Save that this range is handled with LooseScan: */
-        dups_ranges[cur_range].strategy= SJ_STRATEGY_INSIDEOUT;
-        end_of_range= TRUE;
-      }
-      else if (bitmap_covers(cur_map, emb_outer_tables | emb_sj_map))
-      {
-        /*
-          This is a complete range to be handled with either DuplicateWeedout 
-          or FirstMatch
-        */
-        dups_ranges[cur_range].strategy= 
-          dealing_with_jbuf? SJ_STRATEGY_DUPS_WEEDOUT_JBUF: 
-                             SJ_STRATEGY_DUPS_WEEDOUT;
-        /* 
-          This will hold tables from within the range that need to be put 
-          into the join buffer before we can use the FirstMatch on its tail.
-        */
-        dups_ranges[cur_range].outer_tables= emb_outer_tables & 
-                                             ~range_start_map;
-        end_of_range= TRUE;
-      }
-
-      if (end_of_range)
-      {
-        dups_ranges[cur_range].end_idx= i+1;
-        emb_sj_map= emb_outer_tables= 0;
-        emb_insideout_nest= NULL;
-        dealing_with_jbuf= FALSE;
-        dups_ranges[++cur_range].strategy= SJ_STRATEGY_INVALID;
-      }
-      else
-      {
-        /* We don't support interleaving for LooseScan*/
-        if (!tab->emb_sj_nest)
-          emb_insideout_nest= NULL;
-      }
-    }
-  }
-
-  THD *thd= join->thd;
-  /*
-    The second pass: setup the chosen strategies    
-  */
-  for (int j= 0; j < cur_range; j++)
-  {
-    JOIN_TAB *tab=join->join_tab + dups_ranges[j].start_idx;
-    JOIN_TAB *jump_to;
-    if (dups_ranges[j].strategy == SJ_STRATEGY_INSIDEOUT)
-    {
-      ...
-    }
-    else // DuplicateWeedout or FirstMatch
-    {
-      SJ_TMP_TABLE::TAB sjtabs[MAX_TABLES];
-      table_map cur_map= join->const_table_map | PSEUDO_TABLE_BITS;
-      uint jt_rowid_offset= 0; // # tuple bytes are already occupied (w/o NULL bytes)
-      uint jt_null_bits= 0;    // # null bits in tuple bytes
-      SJ_TMP_TABLE::TAB *last_tab= sjtabs;
-      uint rowid_keep_flags= JOIN_TAB::CALL_POSITION | JOIN_TAB::KEEP_ROWID;
-      JOIN_TAB *last_outer_tab= tab - 1;
-      /*
-        Walk through the range and remember
-         - tables that need their rowids to be put into temptable
-         - the last outer table
-      */
-      for (; tab < join->join_tab + dups_ranges[j].end_idx; tab++)
-      {
-        if (sj_table_is_included(join, tab))
-        {
-          last_tab->join_tab= tab;
-          last_tab->rowid_offset= jt_rowid_offset;
-          jt_rowid_offset += tab->table->file->ref_length;
-          if (tab->table->maybe_null)
-          {
-            last_tab->null_byte= jt_null_bits / 8;
-            last_tab->null_bit= jt_null_bits++;
-          }
-          last_tab++;
-          tab->table->prepare_for_position();
-          tab->rowid_keep_flags= rowid_keep_flags;
-        }
-        cur_map |= tab->table->map;
-        if (!tab->emb_sj_nest && bitmap_covers(cur_map, 
-                                               dups_ranges[j].outer_tables))
-          last_outer_tab= tab;
-      }
-
-      if (jt_rowid_offset) /* Temptable has at least one rowid */
-      {
-        SJ_TMP_TABLE *sjtbl;
-        uint tabs_size= (last_tab - sjtabs) * sizeof(SJ_TMP_TABLE::TAB);
-        if (!(sjtbl= (SJ_TMP_TABLE*)thd->alloc(sizeof(SJ_TMP_TABLE))) ||
-            !(sjtbl->tabs= (SJ_TMP_TABLE::TAB*) thd->alloc(tabs_size)))
-          DBUG_RETURN(TRUE);
-        memcpy(sjtbl->tabs, sjtabs, tabs_size);
-        sjtbl->tabs_end= sjtbl->tabs + (last_tab - sjtabs);
-        sjtbl->rowid_len= jt_rowid_offset;
-        sjtbl->null_bits= jt_null_bits;
-        sjtbl->null_bytes= (jt_null_bits + 7)/8;
-
-
-        sjtbl->tmp_table= 
-          create_duplicate_weedout_tmp_table(thd, 
-                                             sjtbl->rowid_len + 
-                                             sjtbl->null_bytes,
-                                             sjtbl);
-
-        join->sj_tmp_tables.push_back(sjtbl->tmp_table);
-        join->join_tab[dups_ranges[j].start_idx].flush_weedout_table= sjtbl;
-        join->join_tab[dups_ranges[j].end_idx - 1].check_weed_out_table= sjtbl;
-      }
-      tab= last_outer_tab + 1;
-      jump_to= last_outer_tab;
-    }
-
-    /* Create the FirstMatch tail */
-    for (; tab < join->join_tab + dups_ranges[j].end_idx; tab++)
-    {
-      if (!tab->emb_sj_nest)
-        jump_to= tab;
-    }
-    if (tab - 1 != jump_to)
-      tab[-1].do_firstmatch= jump_to;
-  }
-  DBUG_RETURN(FALSE);
-}
-#endif
-
 
 int setup_semijoin_dups_elimination2(JOIN *join, ulonglong options, uint no_jbuf_after)
 {

Thread
bzr commit into mysql-6.0-opt-subqueries branch (sergefp:2686) Sergey Petrunia28 Jul