~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Brian Aker
  • Date: 2009-02-02 23:10:18 UTC
  • mfrom: (779.3.40 devel)
  • Revision ID: brian@tangent.org-20090202231018-zlp0hka6kgwy1vfy
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
3094
3094
    (*in_subq)->sj_convert_priority=
3095
3095
      (*in_subq)->is_correlated * MAX_TABLES + child_join->outer_tables;
3096
3096
  }
3097
 
 
 
3097
  
 
3098
  bool outer_join_disable_semi_join= false;
3098
3099
  /*
3099
 
    2. Pick which subqueries to convert:
3100
 
      sort the subquery array
3101
 
      - prefer correlated subqueries over uncorrelated;
3102
 
      - prefer subqueries that have greater number of outer tables;
3103
 
  */
3104
 
  sj_subselects.sort(subq_sj_candidate_cmp);
3105
 
  // #tables-in-parent-query + #tables-in-subquery < MAX_TABLES
3106
 
  /* Replace all subqueries to be flattened with Item_int(1) */
3107
 
  for (in_subq= sj_subselects.front();
3108
 
       in_subq != in_subq_end &&
3109
 
       tables + ((*in_subq)->sj_convert_priority % MAX_TABLES) < MAX_TABLES;
3110
 
       in_subq++)
 
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)
3111
3106
  {
3112
 
    if (replace_where_subcondition(this, *in_subq, new Item_int(1), false))
3113
 
      return(true);
 
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
      outer_join_disable_semi_join= true;
 
3113
    }
3114
3114
  }
3115
3115
 
3116
 
  for (in_subq= sj_subselects.front();
3117
 
       in_subq != in_subq_end &&
3118
 
       tables + ((*in_subq)->sj_convert_priority % MAX_TABLES) < MAX_TABLES;
3119
 
       in_subq++)
 
3116
  if (! outer_join_disable_semi_join)
3120
3117
  {
3121
 
    if (convert_subq_to_sj(this, *in_subq))
3122
 
      return(true);
 
3118
    /*
 
3119
      2. Pick which subqueries to convert:
 
3120
        sort the subquery array
 
3121
        - prefer correlated subqueries over uncorrelated;
 
3122
        - prefer subqueries that have greater number of outer tables;
 
3123
    */
 
3124
    sj_subselects.sort(subq_sj_candidate_cmp);
 
3125
    // #tables-in-parent-query + #tables-in-subquery < MAX_TABLES
 
3126
    /* Replace all subqueries to be flattened with Item_int(1) */
 
3127
    for (in_subq= sj_subselects.front();
 
3128
        in_subq != in_subq_end &&
 
3129
        tables + ((*in_subq)->sj_convert_priority % MAX_TABLES) < MAX_TABLES;
 
3130
        in_subq++)
 
3131
    {
 
3132
      if (replace_where_subcondition(this, *in_subq, new Item_int(1), false))
 
3133
        return(true);
 
3134
    }
 
3135
 
 
3136
    for (in_subq= sj_subselects.front();
 
3137
        in_subq != in_subq_end &&
 
3138
        tables + ((*in_subq)->sj_convert_priority % MAX_TABLES) < MAX_TABLES;
 
3139
        in_subq++)
 
3140
    {
 
3141
      if (convert_subq_to_sj(this, *in_subq))
 
3142
        return(true);
 
3143
    }
3123
3144
  }
3124
3145
 
3125
3146
  /* 3. Finalize those we didn't convert */