~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Jay Pipes
  • Date: 2009-02-04 15:44:25 UTC
  • mfrom: (829 drizzle)
  • mto: This revision was merged to the branch mainline in revision 830.
  • Revision ID: jpipes@serialcoder-20090204154425-th8xfk2ujz2y8xwg
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
2043
2043
 
2044
2044
  session->set_proc_info("executing");
2045
2045
  error= 0;
2046
 
  (void) result->prepare2(); // Currently, this cannot fail.
2047
2046
 
2048
2047
  if (!tables_list && (tables || !select_lex->with_sum_func))
2049
2048
  {                                           // Only test of functions
3095
3094
    (*in_subq)->sj_convert_priority=
3096
3095
      (*in_subq)->is_correlated * MAX_TABLES + child_join->outer_tables;
3097
3096
  }
3098
 
 
 
3097
  
 
3098
  bool outer_join_disable_semi_join= false;
3099
3099
  /*
3100
 
    2. Pick which subqueries to convert:
3101
 
      sort the subquery array
3102
 
      - prefer correlated subqueries over uncorrelated;
3103
 
      - prefer subqueries that have greater number of outer tables;
3104
 
  */
3105
 
  sj_subselects.sort(subq_sj_candidate_cmp);
3106
 
  // #tables-in-parent-query + #tables-in-subquery < MAX_TABLES
3107
 
  /* Replace all subqueries to be flattened with Item_int(1) */
3108
 
  for (in_subq= sj_subselects.front();
3109
 
       in_subq != in_subq_end &&
3110
 
       tables + ((*in_subq)->sj_convert_priority % MAX_TABLES) < MAX_TABLES;
3111
 
       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)
3112
3106
  {
3113
 
    if (replace_where_subcondition(this, *in_subq, new Item_int(1), false))
3114
 
      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
    }
3115
3114
  }
3116
3115
 
3117
 
  for (in_subq= sj_subselects.front();
3118
 
       in_subq != in_subq_end &&
3119
 
       tables + ((*in_subq)->sj_convert_priority % MAX_TABLES) < MAX_TABLES;
3120
 
       in_subq++)
 
3116
  if (! outer_join_disable_semi_join)
3121
3117
  {
3122
 
    if (convert_subq_to_sj(this, *in_subq))
3123
 
      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
    }
3124
3144
  }
3125
3145
 
3126
3146
  /* 3. Finalize those we didn't convert */
16549
16569
bool JOIN::change_result(select_result *res)
16550
16570
{
16551
16571
  result= res;
16552
 
  if (result->prepare(fields_list, select_lex->master_unit()) ||
16553
 
                     result->prepare2())
 
16572
  if (result->prepare(fields_list, select_lex->master_unit()))
16554
16573
  {
16555
16574
    return(true);
16556
16575
  }