~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Jay Pipes
  • Date: 2009-01-30 05:54:48 UTC
  • mto: (779.3.22 devel)
  • mto: This revision was merged to the branch mainline in revision 823.
  • Revision ID: jpipes@serialcoder-20090130055448-7hsp1jgrrl6wo2ki
Fixes crash in optimizer where LEFT JOIN was mixing with a subselect.

Problem was in the JOIN::flatten_subqueries() method, which was not
properly populating the join->cond member that was being passed to the
replace_where_subcondition() static function later on in the method call.

After checking out the source for MySQL 6.0, I noticed that the optimizer
team has punted on LEFT JOIN with dependent subqueries, probably because
of this issue, so I adapted the code from 6.0 into Drizzle.

After that, I modified the test case subselect_sj.test to put back in the
tests for LEFT JOIN on a condition with a subquery and verified that 
the results returned were correct.  The SELECT returns a valid and correct
data set now for both un-commented queries, and the EXPLAIN SELECT just 
shows SUBQUERY, not DEPENDENT or UNIQUE SUBQUERY.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3095
3095
    (*in_subq)->sj_convert_priority=
3096
3096
      (*in_subq)->is_correlated * MAX_TABLES + child_join->outer_tables;
3097
3097
  }
 
3098
  
 
3099
  /*
 
3100
   * Temporary measure: disable semi-joins when they are together with outer
 
3101
   * joins.
 
3102
   *
 
3103
   * @see LP Bug #314911
 
3104
   */
 
3105
  for (TableList *tbl= select_lex->leaf_tables; tbl; tbl=tbl->next_leaf)
 
3106
  {
 
3107
    TableList *embedding= tbl->embedding;
 
3108
    if (tbl->on_expr || (tbl->embedding && !(embedding->sj_on_expr && 
 
3109
                                            !embedding->embedding)))
 
3110
    {
 
3111
      in_subq= sj_subselects.front();
 
3112
      return false;
 
3113
    }
 
3114
  }
3098
3115
 
3099
3116
  /*
3100
3117
    2. Pick which subqueries to convert: