~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join.cc

  • Committer: Brian Aker
  • Date: 2009-07-29 18:35:48 UTC
  • mfrom: (1101.1.12 merge)
  • Revision ID: brian@gaz-20090729183548-yp36iwoaemfc76z0
Merging Monty (which includes new replication)

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