List:Commits« Previous MessageNext Message »
From:Roy Lyseng Date:July 4 2012 2:34pm
Subject:bzr push into mysql-5.6 branch (roy.lyseng:3963 to 3964)
View as plain text  
 3964 Roy Lyseng	2012-07-04 [merge]
      (no message)

    modified:
      sql/item.h
      sql/opt_sum.cc
      sql/sql_optimizer.cc
      sql/sql_planner.cc
      sql/table.h
 3963 Jimmy Yang	2012-07-04
      Fix Bug 14222008 - SHUTDOWN HANG, FTS RELATED
      
      rb://1127 Approved by Sunny Bains

    modified:
      storage/innobase/fts/fts0opt.cc
=== modified file 'sql/item.h'
--- a/sql/item.h	2012-06-01 00:04:28 +0000
+++ b/sql/item.h	2012-07-04 13:47:13 +0000
@@ -2228,7 +2228,7 @@ public:
   {
     DBUG_ASSERT(fixed);
     return field->table->pos_in_table_list->outer_join ||
-           field->table->pos_in_table_list->in_outer_join_nest();
+           field->table->pos_in_table_list->outer_join_nest();
   }
   Field::geometry_type get_geometry_type() const
   {

=== modified file 'sql/opt_sum.cc'
--- a/sql/opt_sum.cc	2012-04-27 14:30:32 +0000
+++ b/sql/opt_sum.cc	2012-07-04 13:47:13 +0000
@@ -265,13 +265,7 @@ int opt_sum_query(THD *thd,
   */
   for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf)
   {
-    TABLE_LIST *embedded;
-    for (embedded= tl ; embedded; embedded= embedded->embedding)
-    {
-      if (embedded->join_cond())
-        break;
-    }
-    if (embedded)
+    if (tl->join_cond() || tl->outer_join_nest())
     /* Don't replace expression on a table that is part of an outer join */
     {
       outer_tables|= tl->table->map;

=== modified file 'sql/sql_optimizer.cc'
--- a/sql/sql_optimizer.cc	2012-06-22 10:11:31 +0000
+++ b/sql/sql_optimizer.cc	2012-07-04 13:47:13 +0000
@@ -2745,6 +2745,9 @@ static uint build_bitmap_for_nested_join
     NESTED_JOIN *nested_join;
     if ((nested_join= table->nested_join))
     {
+      // We should have either a join condition or a semi-join condition
+      DBUG_ASSERT((table->join_cond() == NULL) == (table->sj_on_expr != NULL));
+
       nested_join->nj_map= 0;
       nested_join->nj_total= 0;
       /*
@@ -3038,7 +3041,7 @@ make_join_statistics(JOIN *join, TABLE_L
 
     s->on_expr_ref= tables->join_cond_ref();
 
-    if (tables->in_outer_join_nest())
+    if (tables->outer_join_nest())
     {
       /* s belongs to a nested join, maybe to several embedding joins */
       s->embedding_map= 0;
@@ -3178,7 +3181,7 @@ make_join_statistics(JOIN *join, TABLE_L
     const bool all_partitions_pruned_away= false;
 #endif
 
-    if (tables->in_outer_join_nest())
+    if (tables->outer_join_nest())
     {
       /*
         Table belongs to a nested join, no candidate for const table extraction.
@@ -3319,7 +3322,7 @@ const_table_extraction_done:
         */
 	if (table->file->stats.records <= 1L &&                            // 1
             (table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT) && // 1
-            !tl->in_outer_join_nest() &&                                   // 2
+            !tl->outer_join_nest() &&                                      // 2
             !(*s->on_expr_ref && (*s->on_expr_ref)->is_expensive()))       // 3
 	{					// system table
 	  int tmp= 0;
@@ -3373,7 +3376,7 @@ const_table_extraction_done:
           */
 	  if (eq_part.is_prefix(table->key_info[key].key_parts) &&
               !table->fulltext_searched &&                           // 1
-              !tl->in_outer_join_nest() &&                           // 2
+              !tl->outer_join_nest() &&                              // 2
               !(tl->embedding && tl->embedding->sj_on_expr) &&       // 3
               !(*s->on_expr_ref && (*s->on_expr_ref)->is_expensive()) &&// 4
               !(table->file->ha_table_flags() & HA_BLOCK_CONST_TABLE))  // 5
@@ -5874,12 +5877,11 @@ static void
 make_outerjoin_info(JOIN *join)
 {
   DBUG_ENTER("make_outerjoin_info");
-  for (uint i=join->const_tables ; i < join->tables ; i++)
+  for (uint i= join->const_tables; i < join->tables; i++)
   {
-    JOIN_TAB *tab=join->join_tab+i;
-    TABLE *table=tab->table;
-    TABLE_LIST *tbl= table->pos_in_table_list;
-    TABLE_LIST *embedding= tbl->embedding;
+    JOIN_TAB   *const tab= join->join_tab + i;
+    TABLE      *const table= tab->table;
+    TABLE_LIST *const tbl= table->pos_in_table_list;
 
     if (tbl->outer_join)
     {
@@ -5891,30 +5893,22 @@ make_outerjoin_info(JOIN *join)
       tab->last_inner= tab->first_inner= tab;
       tab->on_expr_ref= tbl->join_cond_ref();
       tab->cond_equal= tbl->cond_equal;
-      if (embedding)
-      {
-        // This outer join nest is embedded in another join nest
-        if (embedding->nested_join->nj_map)
-        {
-          // The embedding nest is an outer join nest, link the join-tabs:
-          tab->first_upper= embedding->nested_join->first_nested;
-        }
-        else if (embedding->embedding)
-        {
-          /*
-            The embedding nest is not an outer join nest, but there is a
-            nest that embeds this nest, which must be an outer join nest.
-          */
-          tab->first_upper= embedding->embedding->nested_join->first_nested;
-        }
-      }
+      /*
+        If this outer join nest is embedded in another join nest,
+        link the join-tabs:
+      */
+      TABLE_LIST *const outer_join_nest= tbl->outer_join_nest();
+      if (outer_join_nest)
+        tab->first_upper= outer_join_nest->nested_join->first_nested;
     }    
-    for ( ; embedding ; embedding= embedding->embedding)
+    for (TABLE_LIST *embedding= tbl->embedding;
+         embedding;
+         embedding= embedding->embedding)
     {
-      // Ignore all join nests that are not outer join nests (ie semi-joins):
-      if (!embedding->nested_join->nj_map)
+      // Ignore join nests that are not outer join nests:
+      if (!embedding->join_cond())
         continue;
-      NESTED_JOIN *nested_join= embedding->nested_join;
+      NESTED_JOIN *const nested_join= embedding->nested_join;
       if (!nested_join->nj_counter)
       {
         /* 
@@ -5924,15 +5918,10 @@ make_outerjoin_info(JOIN *join)
         nested_join->first_nested= tab;
         tab->on_expr_ref= embedding->join_cond_ref();
         tab->cond_equal= tbl->cond_equal;
-        TABLE_LIST *const outer_nest= embedding->embedding;
-        if (outer_nest)
-        {
-          // This outer join nest is embedded in another join nest
-          if (outer_nest->nested_join->nj_map)
-            tab->first_upper= outer_nest->nested_join->first_nested;
-          else if (outer_nest->embedding)
-            tab->first_upper= outer_nest->embedding->nested_join->first_nested;
-        }
+
+        TABLE_LIST *const outer_join_nest= embedding->outer_join_nest();
+        if (outer_join_nest)
+          tab->first_upper= outer_join_nest->nested_join->first_nested;
       }
       if (!tab->first_inner)  
         tab->first_inner= nested_join->first_nested;

=== modified file 'sql/sql_planner.cc'
--- a/sql/sql_planner.cc	2012-06-05 07:13:40 +0000
+++ b/sql/sql_planner.cc	2012-07-04 13:47:13 +0000
@@ -2690,7 +2690,7 @@ bool Optimize_table_order::check_interle
   for (; next_emb != emb_sjm_nest; next_emb= next_emb->embedding)
   {
     // Ignore join nests that are not outer joins.
-    if (!next_emb->nested_join->nj_map)
+    if (!next_emb->join_cond())
       continue;
 
     next_emb->nested_join->nj_counter++;
@@ -3674,11 +3674,11 @@ void Optimize_table_order::backout_nj_st
 
   for (; last_emb != emb_sjm_nest; last_emb= last_emb->embedding)
   {
-    NESTED_JOIN *const nest= last_emb->nested_join;
-
     // Ignore join nests that are not outer joins.
-    if (!nest->nj_map)
+    if (!last_emb->join_cond())
       continue;
+
+    NESTED_JOIN *const nest= last_emb->nested_join;
 
     DBUG_ASSERT(nest->nj_counter > 0);
 

=== modified file 'sql/table.h'
--- a/sql/table.h	2012-06-01 14:02:36 +0000
+++ b/sql/table.h	2012-07-04 13:47:13 +0000
@@ -1502,7 +1502,7 @@ private:
   Item		*m_join_cond;           /* Used with outer join */
 public:
   Item         **join_cond_ref() { return &m_join_cond; }
-  Item          *join_cond() { return m_join_cond; }
+  Item          *join_cond() const { return m_join_cond; }
   Item          *set_join_cond(Item *val)
                  { return m_join_cond= val; }
   /*
@@ -1941,11 +1941,10 @@ public:
   st_select_lex_unit *get_unit();
 
   /**
-    @brief Returns whether the table (or join nest) that this TABLE_LIST 
-    represents, is part of an outer-join nest.
+    @brief Returns the outer join nest that this TABLE_LIST belongs to, if any.
 
     @details There are two kinds of join nests, outer-join nests and semi-join 
-    nests.  This function returns @c TRUE in the following cases:
+    nests.  This function returns non-NULL in the following cases:
       @li 1. If this table/nest is embedded in a nest and this nest IS NOT a 
              semi-join nest.  (In other words, it is an outer-join nest.)
       @li 2. If this table/nest is embedded in a nest and this nest IS a 
@@ -1955,10 +1954,16 @@ public:
              @c simplify_joins() ).
     Note: This function assumes that @c simplify_joins() has been performed.
     Before that, join nests will be present for all types of join.
+
+    @return outer join nest, or NULL if none.
    */
-  bool in_outer_join_nest() const
-  { 
-    return (embedding && (!embedding->sj_on_expr || embedding->embedding)); 
+  TABLE_LIST *outer_join_nest() const
+  {
+    if (!embedding)
+      return NULL;
+    if (embedding->sj_on_expr)
+      return embedding->embedding;
+    return embedding;
   }
 
 private:

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.6 branch (roy.lyseng:3963 to 3964) Roy Lyseng4 Jul