~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Andrew Hutchings
  • Date: 2011-01-04 11:36:01 UTC
  • mto: This revision was merged to the branch mainline in revision 2057.
  • Revision ID: andrew@linuxjedi.co.uk-20110104113601-diiveyfl32dgaa6f
Refix using placement new for join code, vector for join cache buffer.
Also refix a bug in COND_CMP properly

Show diffs side-by-side

added added

removed removed

Lines of Context:
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,
1220
1220
  select= 0;
1221
1221
  delete quick;
1222
1222
  quick= 0;
1223
 
  if (cache.buff)
 
1223
  if (not cache.buff.empty())
1224
1224
  {
1225
 
    size_t size= cache.end - cache.buff;
 
1225
    size_t size= cache.buff.size();
1226
1226
    global_join_buffer.sub(size);
1227
 
    free(cache.buff);
 
1227
    cache.buff.clear();
1228
1228
  }
1229
 
  cache.buff= 0;
1230
1229
  limit= 0;
1231
1230
  if (table)
1232
1231
  {
2364
2363
  and_level
2365
2364
*/
2366
2365
static void change_cond_ref_to_const(Session *session,
2367
 
                                     vector<COND_CMP>& save_list,
 
2366
                                     list<COND_CMP>& save_list,
2368
2367
                                     Item *and_father,
2369
2368
                                     Item *cond,
2370
2369
                                     Item *field,
2470
2469
}
2471
2470
 
2472
2471
static void propagate_cond_constants(Session *session, 
2473
 
                                     vector<COND_CMP>& save_list, 
 
2472
                                     list<COND_CMP>& save_list, 
2474
2473
                                     COND *and_father, 
2475
2474
                                     COND *cond)
2476
2475
{
2479
2478
    bool and_level= ((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC;
2480
2479
    List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
2481
2480
    Item *item;
2482
 
    vector<COND_CMP> save;
 
2481
    list<COND_CMP> save;
2483
2482
    while ((item=li++))
2484
2483
    {
2485
2484
      propagate_cond_constants(session, save, and_level ? cond : item, item);
2487
2486
    if (and_level)
2488
2487
    {
2489
2488
      // Handle other found items
2490
 
      for (vector<COND_CMP>::iterator iter= save.begin(); iter != save.end(); ++iter)
 
2489
      for (list<COND_CMP>::iterator iter= save.begin(); iter != save.end(); ++iter)
2491
2490
      {
2492
 
        Item **args= iter->cmp_func->arguments();
 
2491
        Item **args= iter->second->arguments();
2493
2492
        if (not args[0]->const_item())
2494
2493
        {
2495
 
          change_cond_ref_to_const(session, save_list, iter->and_level,
2496
 
                                   iter->and_level, args[0], args[1] );
 
2494
          change_cond_ref_to_const(session, save, iter->first,
 
2495
                                   iter->first, args[0], args[1] );
2497
2496
        }
2498
2497
      }
2499
2498
    }
2684
2683
                             &join->cond_equal);
2685
2684
 
2686
2685
    /* change field = field to field = const for each found field = const */
2687
 
    vector<COND_CMP> temp;
 
2686
    list<COND_CMP> temp;
2688
2687
    propagate_cond_constants(session, temp, conds, conds);
2689
2688
    /*
2690
2689
      Remove all instances of item == item