~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join.cc

  • Committer: Monty Taylor
  • Date: 2010-10-07 05:19:48 UTC
  • mto: (1821.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 1822.
  • Revision ID: mordred@inaugust.com-20101007051948-woxgvqo7fr47yp22
TurnedĀ onĀ -Werror.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
 
72
72
/** Declarations of static functions used in this source file. */
73
73
static bool make_group_fields(Join *main_join, Join *curr_join);
74
 
static void calc_group_buffer(Join *join, Order *group);
75
 
static bool alloc_group_fields(Join *join, Order *group);
 
74
static void calc_group_buffer(Join *join,order_st *group);
 
75
static bool alloc_group_fields(Join *join,order_st *group);
76
76
static uint32_t cache_record_length(Join *join, uint32_t index);
77
77
static double prev_record_reads(Join *join, uint32_t idx, table_map found_ref);
78
78
static bool get_best_combination(Join *join);
102
102
static bool make_join_select(Join *join, optimizer::SqlSelect *select,COND *item);
103
103
static bool make_join_readinfo(Join *join);
104
104
static void update_depend_map(Join *join);
105
 
static void update_depend_map(Join *join, Order *order);
106
 
static Order *remove_constants(Join *join,Order *first_order,COND *cond, bool change_list, bool *simple_order);
 
105
static void update_depend_map(Join *join, order_st *order);
 
106
static order_st *remove_constants(Join *join,order_st *first_order,COND *cond, bool change_list, bool *simple_order);
107
107
static int return_zero_rows(Join *join,
108
108
                            select_result *res,
109
109
                            TableList *tables,
121
121
                               List<Item> &fields,
122
122
                               List<Item> &all_fields,
123
123
                               COND **conds,
124
 
                               Order *order,
125
 
                               Order *group,
 
124
                               order_st *order,
 
125
                               order_st *group,
126
126
                               bool *hidden_group_fields);
127
127
static bool make_join_statistics(Join *join, TableList *leaves, COND *conds, DYNAMIC_ARRAY *keyuse);
128
128
static uint32_t build_bitmap_for_nested_joins(List<TableList> *join_list, uint32_t first_unused);
129
 
static Table *get_sort_by_table(Order *a, Order *b,TableList *tables);
 
129
static Table *get_sort_by_table(order_st *a,order_st *b,TableList *tables);
130
130
static void reset_nj_counters(List<TableList> *join_list);
131
 
static bool test_if_subpart(Order *a,Order *b);
 
131
static bool test_if_subpart(order_st *a,order_st *b);
132
132
static void restore_prev_nj_state(JoinTable *last);
133
133
static bool add_ref_to_table_cond(Session *session, JoinTable *join_tab);
134
134
static void free_blobs(Field **ptr); /* Rename this method...conflicts with another in global namespace... */
150
150
                  uint32_t wild_num,
151
151
                  COND *conds_init,
152
152
                  uint32_t og_num,
153
 
                  Order *order_init,
154
 
                  Order *group_init,
 
153
                  order_st *order_init,
 
154
                  order_st *group_init,
155
155
                  Item *having_init,
156
156
                  Select_Lex *select_lex_arg,
157
157
                  Select_Lex_Unit *unit_arg)
192
192
  for (table_ptr= select_lex->leaf_tables;
193
193
       table_ptr;
194
194
       table_ptr= table_ptr->next_leaf)
195
 
  {
196
195
    tables++;
197
 
  }
198
 
 
199
196
 
200
197
  if (setup_wild(session, fields_list, &all_fields, wild_num) ||
201
198
      select_lex->setup_ref_array(session, og_num) ||
291
288
 
292
289
  if (order)
293
290
  {
294
 
    Order *ord;
 
291
    order_st *ord;
295
292
    for (ord= order; ord; ord= ord->next)
296
293
    {
297
294
      Item *item= *ord->item;
336
333
  {
337
334
    /* Caclulate the number of groups */
338
335
    send_group_parts= 0;
339
 
    for (Order *group_tmp= group_list ; group_tmp ; group_tmp= group_tmp->next)
 
336
    for (order_st *group_tmp= group_list ; group_tmp ; group_tmp= group_tmp->next)
340
337
      send_group_parts++;
341
338
  }
342
339
 
343
340
  if (error)
344
 
    return(-1);
 
341
    goto err;
345
342
 
346
343
  /* 
347
344
   * The below will create the new table for
350
347
   * @see create_table_from_items() in drizzled/sql_insert.cc
351
348
   */
352
349
  if (result && result->prepare(fields_list, unit_arg))
353
 
    return(-1);
 
350
    goto err;
354
351
 
355
352
  /* Init join struct */
356
353
  count_field_types(select_lex, &tmp_table_param, all_fields, 0);
362
359
  if (sum_func_count && !group_list && (func_count || field_count))
363
360
  {
364
361
    my_message(ER_WRONG_SUM_SELECT,ER(ER_WRONG_SUM_SELECT),MYF(0));
365
 
    return(-1);
 
362
    goto err;
366
363
  }
367
364
#endif
368
365
  if (select_lex->olap == ROLLUP_TYPE && rollup_init())
369
 
    return(-1);
370
 
 
 
366
    goto err;
371
367
  if (alloc_func_list())
372
 
    return(-1);
373
 
 
374
 
  return 0; // All OK
 
368
    goto err;
 
369
 
 
370
  return(0); // All OK
 
371
 
 
372
err:
 
373
  return(-1);
375
374
}
376
375
 
377
376
/*
594
593
    return 1;
595
594
  }
596
595
  if (const_tables && !(select_options & SELECT_NO_UNLOCK))
597
 
    session->unlockSomeTables(table, const_tables);
 
596
    mysql_unlock_some_tables(session, table, const_tables);
598
597
  if (!conds && outer_join)
599
598
  {
600
599
    /* Handle the case where we have an OUTER JOIN without a WHERE */
656
655
 
657
656
  /* Optimize distinct away if possible */
658
657
  {
659
 
    Order *org_order= order;
 
658
    order_st *org_order= order;
660
659
    order= remove_constants(this, order,conds,1, &simple_order);
661
660
    if (session->is_error())
662
661
    {
790
789
  }
791
790
  simple_group= 0;
792
791
  {
793
 
    Order *old_group_list;
 
792
    order_st *old_group_list;
794
793
    group_list= remove_constants(this, (old_group_list= group_list), conds,
795
794
                                 rollup.state == ROLLUP::STATE_NONE,
796
795
                                 &simple_group);
868
867
        save_index_subquery_explain_info(join_tab, where);
869
868
        join_tab[0].type= AM_UNIQUE_SUBQUERY;
870
869
        error= 0;
871
 
        return(unit->item->change_engine(new subselect_uniquesubquery_engine(session, join_tab, unit->item, where)));
 
870
        return(unit->item->
 
871
                    change_engine(new
 
872
                                  subselect_uniquesubquery_engine(session,
 
873
                                                                  join_tab,
 
874
                                                                  unit->item,
 
875
                                                                  where)));
872
876
      }
873
877
      else if (join_tab[0].type == AM_REF &&
874
878
         join_tab[0].ref.items[0]->name == in_left_expr_name)
877
881
        save_index_subquery_explain_info(join_tab, where);
878
882
        join_tab[0].type= AM_INDEX_SUBQUERY;
879
883
        error= 0;
880
 
        return(unit->item->change_engine(new subselect_indexsubquery_engine(session, join_tab, unit->item, where, NULL, 0)));
 
884
        return(unit->item->
 
885
                    change_engine(new
 
886
                                  subselect_indexsubquery_engine(session,
 
887
                                                                 join_tab,
 
888
                                                                 unit->item,
 
889
                                                                 where,
 
890
                                                                 NULL,
 
891
                                                                 0)));
881
892
      }
882
893
    } 
883
894
    else if (join_tab[0].type == AM_REF_OR_NULL &&
888
899
      error= 0;
889
900
      conds= remove_additional_cond(conds);
890
901
      save_index_subquery_explain_info(join_tab, conds);
891
 
      return(unit->item->change_engine(new subselect_indexsubquery_engine(session, join_tab, unit->item, conds, having, 1)));
 
902
      return(unit->item->
 
903
      change_engine(new subselect_indexsubquery_engine(session,
 
904
                   join_tab,
 
905
                   unit->item,
 
906
                   conds,
 
907
                                                                   having,
 
908
                   1)));
892
909
    }
893
910
 
894
911
  }
940
957
        Force using of tmp table if sorting by a SP or UDF function due to
941
958
        their expensive and probably non-deterministic nature.
942
959
      */
943
 
      for (Order *tmp_order= order; tmp_order ; tmp_order=tmp_order->next)
 
960
      for (order_st *tmp_order= order; tmp_order ; tmp_order=tmp_order->next)
944
961
      {
945
962
        Item *item= *tmp_order->item;
946
963
        if (item->is_expensive())
984
1001
 
985
1002
    tmp_table_param.hidden_field_count= (all_fields.elements -
986
1003
           fields_list.elements);
987
 
    Order *tmp_group= ((!simple_group &&
 
1004
    order_st *tmp_group= ((!simple_group && 
988
1005
                           ! (test_flags.test(TEST_NO_KEY_GROUP))) ? group_list :
989
 
                                                                     (Order*) 0);
 
1006
                                                                     (order_st*) 0);
990
1007
    /*
991
1008
      Pushing LIMIT to the temporary table creation is not applicable
992
1009
      when there is ORDER BY or GROUP BY or there is no GROUP BY, but
1089
1106
      If this join belongs to an uncacheable subquery save
1090
1107
      the original join
1091
1108
    */
1092
 
    if (select_lex->uncacheable.any() && 
1093
 
        ! is_top_level_join() &&
 
1109
    if (select_lex->uncacheable && !is_top_level_join() &&
1094
1110
        init_save_join_tab())
1095
 
    {
1096
 
      return -1;
1097
 
    }
 
1111
      return(-1);
1098
1112
  }
1099
1113
 
1100
1114
  error= 0;
1101
 
  return 0;
 
1115
  return(0);
1102
1116
 
1103
1117
setup_subq_exit:
1104
1118
  /* Even with zero matching rows, subqueries in the HAVING clause
1174
1188
{
1175
1189
  if (!(tmp_join= (Join*)session->alloc(sizeof(Join))))
1176
1190
    return 1;
1177
 
 
1178
1191
  error= 0;              // Ensure that tmp_join.error= 0
1179
1192
  restore_tmp();
1180
 
 
1181
1193
  return 0;
1182
1194
}
1183
1195
 
1184
1196
bool Join::save_join_tab()
1185
1197
{
1186
 
  if (! join_tab_save && select_lex->master_unit()->uncacheable.any())
 
1198
  if (!join_tab_save && select_lex->master_unit()->uncacheable)
1187
1199
  {
1188
1200
    if (!(join_tab_save= (JoinTable*)session->memdup((unsigned char*) join_tab,
1189
1201
            sizeof(JoinTable) * tables)))
1433
1445
              exec_tmp_table2= create_tmp_table(session,
1434
1446
                                                &curr_join->tmp_table_param,
1435
1447
                                                *curr_all_fields,
1436
 
                                                (Order*) 0,
 
1448
                                                (order_st*) 0,
1437
1449
                                                curr_join->select_distinct &&
1438
1450
                                                !curr_join->group_list,
1439
1451
                                                1, curr_join->select_options,
1791
1803
    is called after all rows are sent, but before EOF packet is sent.
1792
1804
 
1793
1805
    For a simple SELECT with no subqueries this function performs a full
1794
 
    cleanup of the Join and calls unlockReadTables to free used base
 
1806
    cleanup of the Join and calls mysql_unlock_read_tables to free used base
1795
1807
    tables.
1796
1808
 
1797
1809
    If a Join is executed for a subquery or if it has a subquery, we can't
1823
1835
    Optimization: if not EXPLAIN and we are done with the Join,
1824
1836
    free all tables.
1825
1837
  */
1826
 
  bool full= (select_lex->uncacheable.none() && ! session->lex->describe);
 
1838
  bool full= (!select_lex->uncacheable && !session->lex->describe);
1827
1839
  bool can_unlock= full;
1828
1840
 
1829
1841
  cleanup(full);
1863
1875
      TODO: unlock tables even if the join isn't top level select in the
1864
1876
      tree.
1865
1877
    */
1866
 
    session->unlockReadTables(lock);           // Don't free join->lock
 
1878
    mysql_unlock_read_tables(session, lock);           // Don't free join->lock
1867
1879
    lock= 0;
1868
1880
  }
1869
1881
 
1993
2005
    */
1994
2006
    if (order)
1995
2007
    {
1996
 
      Order *ord;
 
2008
      order_st *ord;
1997
2009
      for (ord= order; ord; ord= ord->next)
1998
2010
        group_parts++;
1999
2011
    }
2103
2115
  Item *item;
2104
2116
  while ((item= it++))
2105
2117
  {
2106
 
    Order *group_tmp;
 
2118
    order_st *group_tmp;
2107
2119
    bool found_in_group= 0;
2108
2120
 
2109
2121
    for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next)
2132
2144
            return 1;
2133
2145
          new_item->fix_fields(session, (Item **) 0);
2134
2146
          session->change_item_tree(it.ref(), new_item);
2135
 
          for (Order *tmp= group_tmp; tmp; tmp= tmp->next)
 
2147
          for (order_st *tmp= group_tmp; tmp; tmp= tmp->next)
2136
2148
          {
2137
2149
            if (*tmp->item == item)
2138
2150
              session->change_item_tree(tmp->item, new_item);
2207
2219
    Item *item;
2208
2220
    List_iterator<Item> new_it(rollup.fields[pos]);
2209
2221
    Item **ref_array_start= rollup.ref_pointer_arrays[pos];
2210
 
    Order *start_group;
 
2222
    order_st *start_group;
2211
2223
 
2212
2224
    /* Point to first hidden field */
2213
2225
    Item **ref_array= ref_array_start + fields_arg.elements-1;
2249
2261
      else
2250
2262
      {
2251
2263
        /* Check if this is something that is part of this group by */
2252
 
        Order *group_tmp;
 
2264
        order_st *group_tmp;
2253
2265
        for (group_tmp= start_group, i= pos ;
2254
2266
                  group_tmp ; group_tmp= group_tmp->next, i++)
2255
2267
        {
2465
2477
    return NESTED_LOOP_ERROR;
2466
2478
  if (error < 0)
2467
2479
    return NESTED_LOOP_NO_MORE_ROWS;
2468
 
  if (join->session->getKilled())                       // Aborted by user
 
2480
  if (join->session->killed)                    // Aborted by user
2469
2481
  {
2470
2482
    join->session->send_kill_message();
2471
2483
    return NESTED_LOOP_KILLED;
2677
2689
  info= &join_tab->read_record;
2678
2690
  do
2679
2691
  {
2680
 
    if (join->session->getKilled())
 
2692
    if (join->session->killed)
2681
2693
    {
2682
2694
      join->session->send_kill_message();
2683
2695
      return NESTED_LOOP_KILLED;
2809
2821
{
2810
2822
  Table *table= join->tmp_table;
2811
2823
 
2812
 
  if (join->session->getKilled())                       // Aborted by user
 
2824
  if (join->session->killed)                    // Aborted by user
2813
2825
  {
2814
2826
    join->session->send_kill_message();
2815
2827
    return NESTED_LOOP_KILLED;
2817
2829
  if (!end_of_records)
2818
2830
  {
2819
2831
    copy_fields(&join->tmp_table_param);
2820
 
    if (copy_funcs(join->tmp_table_param.items_to_copy, join->session))
2821
 
      return NESTED_LOOP_ERROR;
 
2832
    copy_funcs(join->tmp_table_param.items_to_copy);
2822
2833
    if (!join->having || join->having->val_int())
2823
2834
    {
2824
2835
      int error;
2826
2837
      if ((error=table->cursor->insertRecord(table->getInsertRecord())))
2827
2838
      {
2828
2839
        if (!table->cursor->is_fatal_error(error, HA_CHECK_DUP))
2829
 
        {
2830
 
          return NESTED_LOOP_OK;
2831
 
        }
 
2840
          goto end;
2832
2841
 
2833
2842
        my_error(ER_USE_SQL_BIG_RESULT, MYF(0));
2834
2843
        return NESTED_LOOP_ERROR;        // Table is_full error
2843
2852
      }
2844
2853
    }
2845
2854
  }
2846
 
 
 
2855
end:
2847
2856
  return NESTED_LOOP_OK;
2848
2857
}
2849
2858
 
2851
2860
enum_nested_loop_state end_update(Join *join, JoinTable *, bool end_of_records)
2852
2861
{
2853
2862
  Table *table= join->tmp_table;
2854
 
  Order *group;
 
2863
  order_st *group;
2855
2864
  int   error;
2856
2865
 
2857
2866
  if (end_of_records)
2858
2867
    return NESTED_LOOP_OK;
2859
 
  if (join->session->getKilled())                       // Aborted by user
 
2868
  if (join->session->killed)                    // Aborted by user
2860
2869
  {
2861
2870
    join->session->send_kill_message();
2862
2871
    return NESTED_LOOP_KILLED;
2903
2912
      memcpy(table->getInsertRecord()+key_part->offset, group->buff, 1);
2904
2913
  }
2905
2914
  init_tmptable_sum_functions(join->sum_funcs);
2906
 
  if (copy_funcs(join->tmp_table_param.items_to_copy, join->session))
2907
 
    return NESTED_LOOP_ERROR;
 
2915
  copy_funcs(join->tmp_table_param.items_to_copy);
2908
2916
  if ((error=table->cursor->insertRecord(table->getInsertRecord())))
2909
2917
  {
2910
2918
    my_error(ER_USE_SQL_BIG_RESULT, MYF(0));
2922
2930
 
2923
2931
  if (end_of_records)
2924
2932
    return NESTED_LOOP_OK;
2925
 
  if (join->session->getKilled())                       // Aborted by user
 
2933
  if (join->session->killed)                    // Aborted by user
2926
2934
  {
2927
2935
    join->session->send_kill_message();
2928
2936
    return NESTED_LOOP_KILLED;
2930
2938
 
2931
2939
  init_tmptable_sum_functions(join->sum_funcs);
2932
2940
  copy_fields(&join->tmp_table_param);          // Groups are copied twice.
2933
 
  if (copy_funcs(join->tmp_table_param.items_to_copy, join->session))
2934
 
    return NESTED_LOOP_ERROR;
 
2941
  copy_funcs(join->tmp_table_param.items_to_copy);
2935
2942
 
2936
2943
  if (!(error= table->cursor->insertRecord(table->getInsertRecord())))
2937
2944
    join->send_records++;                       // New group
2990
2997
/**
2991
2998
  calc how big buffer we need for comparing group entries.
2992
2999
*/
2993
 
static void calc_group_buffer(Join *join, Order *group)
 
3000
static void calc_group_buffer(Join *join,order_st *group)
2994
3001
{
2995
3002
  uint32_t key_length=0, parts=0, null_parts=0;
2996
3003
 
3016
3023
      case REAL_RESULT:
3017
3024
        key_length+= sizeof(double);
3018
3025
        break;
3019
 
 
3020
3026
      case INT_RESULT:
3021
3027
        key_length+= sizeof(int64_t);
3022
3028
        break;
3023
 
 
3024
3029
      case DECIMAL_RESULT:
3025
3030
        key_length+= my_decimal_get_binary_size(group_item->max_length -
3026
3031
                                                (group_item->decimals ? 1 : 0),
3027
3032
                                                group_item->decimals);
3028
3033
        break;
3029
 
 
3030
3034
      case STRING_RESULT:
3031
 
        {
3032
 
          enum enum_field_types type= group_item->field_type();
 
3035
      {
 
3036
        enum enum_field_types type= group_item->field_type();
 
3037
        /*
 
3038
          As items represented as DATE/TIME fields in the group buffer
 
3039
          have STRING_RESULT result type, we increase the length
 
3040
          by 8 as maximum pack length of such fields.
 
3041
        */
 
3042
        if (type == DRIZZLE_TYPE_DATE ||
 
3043
            type == DRIZZLE_TYPE_DATETIME ||
 
3044
            type == DRIZZLE_TYPE_TIMESTAMP)
 
3045
        {
 
3046
          key_length+= 8;
 
3047
        }
 
3048
        else
 
3049
        {
3033
3050
          /*
3034
 
            As items represented as DATE/TIME fields in the group buffer
3035
 
            have STRING_RESULT result type, we increase the length
3036
 
            by 8 as maximum pack length of such fields.
 
3051
            Group strings are taken as varstrings and require an length field.
 
3052
            A field is not yet created by create_tmp_field()
 
3053
            and the sizes should match up.
3037
3054
          */
3038
 
          if (type == DRIZZLE_TYPE_DATE ||
3039
 
              type == DRIZZLE_TYPE_DATETIME ||
3040
 
              type == DRIZZLE_TYPE_TIMESTAMP)
3041
 
          {
3042
 
            key_length+= 8;
3043
 
          }
3044
 
          else
3045
 
          {
3046
 
            /*
3047
 
              Group strings are taken as varstrings and require an length field.
3048
 
              A field is not yet created by create_tmp_field()
3049
 
              and the sizes should match up.
3050
 
            */
3051
 
            key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH;
3052
 
          }
3053
 
          break;
 
3055
          key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH;
3054
3056
        }
3055
 
 
3056
 
      case ROW_RESULT:
 
3057
        break;
 
3058
      }
 
3059
      default:
3057
3060
        /* This case should never be choosen */
3058
3061
        assert(0);
3059
3062
        my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
3060
3063
      }
3061
3064
    }
3062
 
 
3063
3065
    parts++;
3064
 
 
3065
3066
    if (group_item->maybe_null)
3066
3067
      null_parts++;
3067
3068
  }
3068
 
 
3069
3069
  join->tmp_table_param.group_length=key_length+null_parts;
3070
3070
  join->tmp_table_param.group_parts=parts;
3071
3071
  join->tmp_table_param.group_null_parts=null_parts;
3076
3076
 
3077
3077
  Groups are saved in reverse order for easyer check loop.
3078
3078
*/
3079
 
static bool alloc_group_fields(Join *join, Order *group)
 
3079
static bool alloc_group_fields(Join *join,order_st *group)
3080
3080
{
3081
3081
  if (group)
3082
3082
  {
4195
4195
                                             uint32_t prune_level)
4196
4196
{
4197
4197
  Session *session= join->session;
4198
 
  if (session->getKilled())  // Abort
 
4198
  if (session->killed)  // Abort
4199
4199
    return(true);
4200
4200
 
4201
4201
  /*
4957
4957
}
4958
4958
 
4959
4959
/** Update the dependency map for the sort order. */
4960
 
static void update_depend_map(Join *join, Order *order)
 
4960
static void update_depend_map(Join *join, order_st *order)
4961
4961
{
4962
4962
  for (; order ; order=order->next)
4963
4963
  {
4995
4995
  @return
4996
4996
    Returns new sort order
4997
4997
*/
4998
 
static Order *remove_constants(Join *join,Order *first_order, COND *cond, bool change_list, bool *simple_order)
 
4998
static order_st *remove_constants(Join *join,order_st *first_order, COND *cond, bool change_list, bool *simple_order)
4999
4999
{
5000
5000
  if (join->tables == join->const_tables)
5001
5001
    return change_list ? 0 : first_order;               // No need to sort
5002
5002
 
5003
 
  Order *order,**prev_ptr;
 
5003
  order_st *order,**prev_ptr;
5004
5004
  table_map first_table= join->join_tab[join->const_tables].table->map;
5005
5005
  table_map not_const_tables= ~join->const_table_map;
5006
5006
  table_map ref;
5441
5441
                               List<Item> &fields,
5442
5442
                               List<Item> &all_fields,
5443
5443
                               COND **conds,
5444
 
                               Order *order,
5445
 
                               Order *group,
 
5444
                               order_st *order,
 
5445
                               order_st *group,
5446
5446
                               bool *hidden_group_fields)
5447
5447
{
5448
5448
  int res;
5881
5881
  if (join->const_tables != join->tables)
5882
5882
  {
5883
5883
    optimize_keyuse(join, keyuse_array);
5884
 
    // @note c_str() is not likely to be valid here if dtrace expects it to
5885
 
    // exist for any period of time.
5886
 
    DRIZZLE_QUERY_OPT_CHOOSE_PLAN_START(join->session->getQueryString()->c_str(), join->session->thread_id);
 
5884
    DRIZZLE_QUERY_OPT_CHOOSE_PLAN_START(join->session->query.c_str(), join->session->thread_id);
5887
5885
    bool res= choose_plan(join, all_table_map & ~join->const_table_map);
5888
5886
    DRIZZLE_QUERY_OPT_CHOOSE_PLAN_DONE(res ? 1 : 0);
5889
5887
    if (res)
5895
5893
    join->best_read= 1.0;
5896
5894
  }
5897
5895
  /* Generate an execution plan from the found optimal join order. */
5898
 
  return (join->session->getKilled() || get_best_combination(join));
 
5896
  return (join->session->killed || get_best_combination(join));
5899
5897
}
5900
5898
 
5901
5899
/**
5955
5953
  Return table number if there is only one table in sort order
5956
5954
  and group and order is compatible, else return 0.
5957
5955
*/
5958
 
static Table *get_sort_by_table(Order *a, Order *b,TableList *tables)
 
5956
static Table *get_sort_by_table(order_st *a,order_st *b,TableList *tables)
5959
5957
{
5960
5958
  table_map map= (table_map) 0;
5961
5959
 
6010
6008
  If first parts has different direction, change it to second part
6011
6009
  (group is sorted like order)
6012
6010
*/
6013
 
static bool test_if_subpart(Order *a, Order *b)
 
6011
static bool test_if_subpart(order_st *a,order_st *b)
6014
6012
{
6015
6013
  for (; a && b; a=a->next,b=b->next)
6016
6014
  {