~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join.cc

Monty fixes pluss a few from me for charset.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1512
1512
      setup_copy_fields(session, &curr_join->tmp_table_param,
1513
1513
      items3, tmp_fields_list3, tmp_all_fields3,
1514
1514
      curr_fields_list->elements, *curr_all_fields);
 
1515
      tmp_table_param.save_copy_funcs= curr_join->tmp_table_param.copy_funcs;
1515
1516
      tmp_table_param.save_copy_field= curr_join->tmp_table_param.copy_field;
1516
1517
      tmp_table_param.save_copy_field_end= curr_join->tmp_table_param.copy_field_end;
1517
1518
      curr_join->tmp_all_fields3= tmp_all_fields3;
1519
1520
    }
1520
1521
    else
1521
1522
    {
 
1523
      curr_join->tmp_table_param.copy_funcs= tmp_table_param.save_copy_funcs;
1522
1524
      curr_join->tmp_table_param.copy_field= tmp_table_param.save_copy_field;
1523
1525
      curr_join->tmp_table_param.copy_field_end= tmp_table_param.save_copy_field_end;
1524
1526
    }
1883
1885
  {
1884
1886
    if (tmp_join)
1885
1887
      tmp_table_param.copy_field= 0;
1886
 
 
1887
 
    while (group_fields.empty() == false)
1888
 
    {
1889
 
      delete group_fields.back();
1890
 
      group_fields.pop_back();
1891
 
    }
1892
 
 
 
1888
    group_fields.delete_elements();
1893
1889
    /*
1894
1890
      We can't call delete_elements() on copy_funcs as this will cause
1895
1891
      problems in free_elements() as some of the elements are then deleted.
1896
1892
    */
1897
 
    tmp_table_param.copy_funcs.clear();
 
1893
    tmp_table_param.copy_funcs.empty();
1898
1894
    /*
1899
1895
      If we have tmp_join and 'this' JOIN is not tmp_join and
1900
1896
      tmp_table_param.copy_field's  of them are equal then we have to remove
1906
1902
        tmp_join->tmp_table_param.copy_field ==
1907
1903
        tmp_table_param.copy_field)
1908
1904
    {
1909
 
      tmp_join->tmp_table_param.copy_field= NULL;
1910
 
      tmp_join->tmp_table_param.save_copy_field= NULL;
 
1905
      tmp_join->tmp_table_param.copy_field=
 
1906
        tmp_join->tmp_table_param.save_copy_field= 0;
1911
1907
    }
 
1908
    tmp_table_param.cleanup();
1912
1909
  }
1913
1910
  return;
1914
1911
}
2934
2931
*/
2935
2932
static bool make_group_fields(JOIN *main_join, JOIN *curr_join)
2936
2933
{
2937
 
  if (main_join->group_fields_cache.empty() == false)
 
2934
  if (main_join->group_fields_cache.elements)
2938
2935
  {
2939
2936
    curr_join->group_fields= main_join->group_fields_cache;
2940
2937
    curr_join->sort_and_group= 1;
3026
3023
}
3027
3024
 
3028
3025
/**
3029
 
  Get a list of buffers for saving last group.
 
3026
  Get a list of buffers for saveing last group.
 
3027
 
 
3028
  Groups are saved in reverse order for easyer check loop.
3030
3029
*/
3031
3030
static bool alloc_group_fields(JOIN *join,order_st *group)
3032
3031
{
3035
3034
    for (; group ; group=group->next)
3036
3035
    {
3037
3036
      Cached_item *tmp=new_Cached_item(join->session, *group->item, false);
3038
 
      if (!tmp)
 
3037
      if (!tmp || join->group_fields.push_front(tmp))
3039
3038
        return true;
3040
 
      join->group_fields.push_back(tmp);
3041
3039
    }
3042
3040
  }
3043
3041
  join->sort_and_group=1;     /* Mark for do_select */