~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

fixed build warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
  @file
18
18
 
19
19
  @brief
20
 
  mysql_select and join optimization
 
20
  select_query and join optimization
21
21
 
22
22
  @defgroup Query_Optimizer  Query Optimizer
23
23
  @{
78
78
static Item* part_of_refkey(Table *form,Field *field);
79
79
static bool cmp_buffer_with_ref(JoinTable *tab);
80
80
static void change_cond_ref_to_const(Session *session,
81
 
                                     vector<COND_CMP>& save_list,
 
81
                                     list<COND_CMP>& save_list,
82
82
                                     Item *and_father,
83
83
                                     Item *cond,
84
84
                                     Item *field,
131
131
    unit->set_limit(unit->global_parameters);
132
132
    session->session_marker= 0;
133
133
    /*
134
 
      'options' of mysql_select will be set in JOIN, as far as JOIN for
 
134
      'options' of select_query will be set in JOIN, as far as JOIN for
135
135
      every PS/SP execution new, we will not need reset this flag if
136
136
      setup_tables_done_option changed for next rexecution
137
137
    */
138
 
    res= mysql_select(session,
 
138
    res= select_query(session,
139
139
                      &select_lex->ref_pointer_array,
140
140
                      (TableList*) select_lex->table_list.first,
141
141
                      select_lex->with_wild,
270
270
 
271
271
/*****************************************************************************
272
272
  Check fields, find best join, do the select and output fields.
273
 
  mysql_select assumes that all tables are already opened
 
273
  select_query assumes that all tables are already opened
274
274
*****************************************************************************/
275
275
 
276
276
/*
350
350
  @retval
351
351
    true   an error
352
352
*/
353
 
bool mysql_select(Session *session,
 
353
bool select_query(Session *session,
354
354
                  Item ***rref_pointer_array,
355
355
                  TableList *tables, 
356
356
                  uint32_t wild_num, 
931
931
 
932
932
  /*
933
933
    we should restore old value of count_cuted_fields because
934
 
    store_val_in_field can be called from mysql_insert
 
934
    store_val_in_field can be called from insert_query
935
935
    with select_insert, which make count_cuted_fields= 1
936
936
   */
937
937
  enum_check_fields old_count_cuted_fields= session->count_cuted_fields;
2364
2364
  and_level
2365
2365
*/
2366
2366
static void change_cond_ref_to_const(Session *session,
2367
 
                                     vector<COND_CMP>& save_list,
 
2367
                                     list<COND_CMP>& save_list,
2368
2368
                                     Item *and_father,
2369
2369
                                     Item *cond,
2370
2370
                                     Item *field,
2470
2470
}
2471
2471
 
2472
2472
static void propagate_cond_constants(Session *session, 
2473
 
                                     vector<COND_CMP>& save_list, 
 
2473
                                     list<COND_CMP>& save_list, 
2474
2474
                                     COND *and_father, 
2475
2475
                                     COND *cond)
2476
2476
{
2479
2479
    bool and_level= ((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC;
2480
2480
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
2481
2481
    Item *item;
2482
 
    vector<COND_CMP> save;
 
2482
    list<COND_CMP> save;
2483
2483
    while ((item=li++))
2484
2484
    {
2485
2485
      propagate_cond_constants(session, save, and_level ? cond : item, item);
2487
2487
    if (and_level)
2488
2488
    {
2489
2489
      // Handle other found items
2490
 
      for (vector<COND_CMP>::iterator iter= save.begin(); iter != save.end(); ++iter)
 
2490
      for (list<COND_CMP>::iterator iter= save.begin(); iter != save.end(); ++iter)
2491
2491
      {
2492
 
        Item **args= iter->cmp_func->arguments();
 
2492
        Item **args= iter->second->arguments();
2493
2493
        if (not args[0]->const_item())
2494
2494
        {
2495
 
          change_cond_ref_to_const(session, save_list, iter->and_level,
2496
 
                                   iter->and_level, args[0], args[1] );
 
2495
          change_cond_ref_to_const(session, save, iter->first,
 
2496
                                   iter->first, args[0], args[1] );
2497
2497
        }
2498
2498
      }
2499
2499
    }
2684
2684
                             &join->cond_equal);
2685
2685
 
2686
2686
    /* change field = field to field = const for each found field = const */
2687
 
    vector<COND_CMP> temp;
 
2687
    list<COND_CMP> temp;
2688
2688
    propagate_cond_constants(session, temp, conds, conds);
2689
2689
    /*
2690
2690
      Remove all instances of item == item