List:Commits« Previous MessageNext Message »
From:Sergey Petrunia Date:November 21 2008 2:36pm
Subject:bzr push into mysql-6.0-opt-subqueries branch (sergefp:2728 to 2729)
WL#3985
View as plain text  
 2729 Sergey Petrunia	2008-11-21
      WL#3985: Subquery optimization: Smart choice between semi-join and materialization
      - Added purecov deadcode annotations.
modified:
  sql/sql_select.cc
  sql/sql_test.cc

 2728 Sergey Petrunia	2008-11-21
      WL#3985: Subqueries: Smart choice between semi-join and materialization
      - Make EXPLAIN handle the case when FirstMatch strategy handles a subquery predicate that 
         doesn't depend on any outer tables all (that is, it's  ... WHERE const IN (SELECT ...))
modified:
  mysql-test/r/subselect3.result
  mysql-test/t/subselect3.test
  sql/sql_select.cc
  sql/sql_select.h

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-11-20 23:42:04 +0000
+++ b/sql/sql_select.cc	2008-11-21 14:32:02 +0000
@@ -1410,7 +1410,7 @@ JOIN::optimize()
   
   /* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
   if (flatten_subqueries())
-    return 1;
+    DBUG_RETURN(1); /* purecov: inspected */
   /* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
 
   row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR :
@@ -4397,7 +4397,7 @@ make_join_statistics(JOIN *join, TABLE_L
     optimize_keyuse(join, keyuse_array);
    
   if (optimize_semijoin_nests(join, all_table_map))
-    DBUG_RETURN(TRUE);
+    DBUG_RETURN(TRUE); /* purecov: inspected */
 
   /* Find an optimal join order of the non-constant tables. */
   if (join->const_tables != join->tables)
@@ -4457,7 +4457,7 @@ static bool optimize_semijoin_nests(JOIN
       {
         join->emb_sjm_nest= sj_nest;
         if (choose_plan(join, all_table_map))
-          DBUG_RETURN(TRUE);
+          DBUG_RETURN(TRUE); /* purecov: inspected */
         /*
           The best plan to run the subquery is now in join->best_positions,
           save it.
@@ -4467,7 +4467,7 @@ static bool optimize_semijoin_nests(JOIN
         if (!(sjm= new SJ_MATERIALIZATION_INFO) ||
             !(sjm->positions= (POSITION*)join->thd->alloc(sizeof(POSITION)*
                                                           n_tables)))
-          DBUG_RETURN(TRUE);
+          DBUG_RETURN(TRUE); /* purecov: inspected */
         sjm->tables= n_tables;
         sjm->is_used= FALSE;
         double subjoin_out_rows, subjoin_read_time;
@@ -9388,7 +9388,7 @@ Item *create_subq_in_equalities(THD *thd
     }
   }
   if (res->fix_fields(thd, &res))
-    return NULL;
+    return NULL; /* purecov: inspected */
   return res;
 }
 
@@ -9442,7 +9442,7 @@ bool setup_sj_materialization(JOIN_TAB *
                                      thd->options | TMP_TABLE_ALL_COLUMNS, 
                                      HA_POS_ERROR /*rows_limit */, 
                                      (char*)"sj-materialize")))
-    DBUG_RETURN(TRUE);
+    DBUG_RETURN(TRUE); /* purecov: inspected */
   sjm->table->file->extra(HA_EXTRA_WRITE_CACHE);
   sjm->table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
   tab->join->sj_tmp_tables.push_back(sjm->table);
@@ -9462,7 +9462,7 @@ bool setup_sj_materialization(JOIN_TAB *
     */
     TABLE_REF *tab_ref;
     if (!(tab_ref= (TABLE_REF*) thd->alloc(sizeof(TABLE_REF))))
-      DBUG_RETURN(TRUE);
+      DBUG_RETURN(TRUE); /* purecov: inspected */
     tab_ref->key= 0; /* The only temp table index. */
     tab_ref->key_length= tmp_key->key_length;
     if (!(tab_ref->key_buff=
@@ -9472,7 +9472,7 @@ bool setup_sj_materialization(JOIN_TAB *
                                     (tmp_key_parts + 1)))) ||
         !(tab_ref->items=
           (Item**) thd->alloc(sizeof(Item*) * tmp_key_parts)))
-      DBUG_RETURN(TRUE);
+      DBUG_RETURN(TRUE); /* purecov: inspected */
 
     tab_ref->key_buff2=tab_ref->key_buff+ALIGN_SIZE(tmp_key->key_length);
     tab_ref->key_err=1;
@@ -9518,7 +9518,7 @@ bool setup_sj_materialization(JOIN_TAB *
     }
     if (!(sjm->in_equality= create_subq_in_equalities(thd, sjm,
                                                       emb_sj_nest->sj_subq_pred)))
-      DBUG_RETURN(TRUE);
+      DBUG_RETURN(TRUE); /* purecov: inspected */
   }
   else
   {
@@ -9607,7 +9607,7 @@ make_join_readinfo(JOIN *join, ulonglong
 
   if (!join->select_lex->sj_nests.is_empty() &&
       setup_semijoin_dups_elimination(join, options, no_jbuf_after))
-    DBUG_RETURN(TRUE);
+    DBUG_RETURN(TRUE); /* purecov: inspected */
 
   for (i=join->const_tables ; i < join->tables ; i++)
   {
@@ -9625,9 +9625,9 @@ make_join_readinfo(JOIN *join, ulonglong
     sorted= 0;                                  // only first must be sorted
     if (tab->loosescan_match_tab)
     {
-      if (!(tab->loosescan_buf= 
-            (uchar*)join->thd->alloc(tab->loosescan_key_len)))
-        return TRUE;
+      if (!(tab->loosescan_buf= (uchar*)join->thd->alloc(tab->
+                                                         loosescan_key_len)))
+        return TRUE; /* purecov: inspected */
     }
     if (sj_is_materialize_strategy(join->best_positions[i].sj_strategy))
     {

=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc	2008-10-31 18:53:23 +0000
+++ b/sql/sql_test.cc	2008-11-21 14:32:02 +0000
@@ -247,6 +247,7 @@ void print_keyuse(KEYUSE *keyuse)
 }
 
 
+/* purecov: begin inspected */
 void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array)
 {
   DBUG_LOCK_FILE;
@@ -358,7 +359,6 @@ print_plan(JOIN* join, uint idx, double 
 }
 
 
-#ifndef DBUG_OFF
 void print_sjm(SJ_MATERIALIZATION_INFO *sjm)
 {
   DBUG_LOCK_FILE;
@@ -377,8 +377,7 @@ void print_sjm(SJ_MATERIALIZATION_INFO *
   fprintf(DBUG_FILE, "}\n");
   DBUG_UNLOCK_FILE;
 }
-#endif 
-
+/* purecov: end */
 #endif
 
 typedef struct st_debug_lock

Thread
bzr push into mysql-6.0-opt-subqueries branch (sergefp:2728 to 2729)WL#3985Sergey Petrunia21 Nov