~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

Reverted 1103

Show diffs side-by-side

added added

removed removed

Lines of Context:
6743
6743
  @return -1 if no item changed
6744
6744
  @return index of the first item that changed
6745
6745
*/
6746
 
int test_if_item_cache_changed(vector<Cached_item*> &list)
 
6746
int test_if_item_cache_changed(List<Cached_item> &list)
6747
6747
{
6748
 
  int idx= -1;
6749
 
  int size= (int)list.size();
 
6748
  List_iterator<Cached_item> li(list);
 
6749
  int idx= -1,i;
 
6750
  Cached_item *buff;
6750
6751
 
6751
 
  for (int i= size - 1; i >= 0; --i)
 
6752
  for (i=(int) list.elements-1 ; (buff=li++) ; i--)
6752
6753
  {
6753
 
    if (list[i]->cmp())
6754
 
      idx= i;
 
6754
    if (buff->cmp())
 
6755
      idx=i;
6755
6756
  }
6756
6757
  return(idx);
6757
6758
}
6798
6799
  res_selected_fields.empty();
6799
6800
  res_all_fields.empty();
6800
6801
  List_iterator_fast<Item> itr(res_all_fields);
6801
 
  vector<Item*> extra_funcs;
 
6802
  List<Item> extra_funcs;
6802
6803
  uint32_t i, border= all_fields.elements - elements;
6803
6804
 
6804
6805
  if (param->field_count &&
6805
6806
      !(copy=param->copy_field= new CopyField[param->field_count]))
6806
6807
    goto err2;
6807
6808
 
6808
 
  param->copy_funcs.clear();
 
6809
  param->copy_funcs.empty();
6809
6810
  for (i= 0; (pos= li++); i++)
6810
6811
  {
6811
6812
    Field *field;
6829
6830
      {
6830
6831
        if (!(pos= new Item_copy_string(pos)))
6831
6832
          goto err;
6832
 
 
6833
 
          /*
6834
 
            Item_copy_string::copy for function can call
6835
 
            Item_copy_string::val_int for blob via Item_ref.
6836
 
            But if Item_copy_string::copy for blob isn't called before,
6837
 
            it's value will be wrong
6838
 
            so let's insert Item_copy_string for blobs in the beginning of
6839
 
            copy_funcs
6840
 
            (to see full test case look at having.test, BUG #4358)
6841
 
          */
6842
 
        param->copy_funcs.push_front(pos);
 
6833
            /*
 
6834
              Item_copy_string::copy for function can call
 
6835
              Item_copy_string::val_int for blob via Item_ref.
 
6836
              But if Item_copy_string::copy for blob isn't called before,
 
6837
              it's value will be wrong
 
6838
              so let's insert Item_copy_string for blobs in the beginning of
 
6839
              copy_funcs
 
6840
              (to see full test case look at having.test, BUG #4358)
 
6841
            */
 
6842
        if (param->copy_funcs.push_front(pos))
 
6843
          goto err;
6843
6844
      }
6844
6845
      else
6845
6846
      {
6884
6885
        goto err;
6885
6886
      if (i < border)                           // HAVING, order_st and GROUP BY
6886
6887
      {
6887
 
        extra_funcs.push_back(pos);
6888
 
      }
6889
 
      else
6890
 
      {
6891
 
        param->copy_funcs.push_back(pos);
6892
 
      }
 
6888
        if (extra_funcs.push_back(pos))
 
6889
          goto err;
 
6890
      }
 
6891
      else if (param->copy_funcs.push_back(pos))
 
6892
        goto err;
6893
6893
    }
6894
6894
    res_all_fields.push_back(pos);
6895
6895
    ref_pointer_array[((i < border)? all_fields.elements-i-1 : i-border)]=
6904
6904
    Put elements from HAVING, order_st BY and GROUP BY last to ensure that any
6905
6905
    reference used in these will resolve to a item that is already calculated
6906
6906
  */
6907
 
  param->copy_funcs.insert(param->copy_funcs.end(),
6908
 
                           extra_funcs.begin(), extra_funcs.end() );
 
6907
  param->copy_funcs.concat(&extra_funcs);
6909
6908
 
6910
6909
  return(0);
6911
6910
 
6931
6930
  for (; ptr != end; ptr++)
6932
6931
    (*ptr->do_copy)(ptr);
6933
6932
 
6934
 
  deque<Item*>::iterator it= param->copy_funcs.begin();
6935
 
  while (it != param->copy_funcs.end())
6936
 
  {
6937
 
    Item_copy_string *item= (Item_copy_string*)*it;
 
6933
  List_iterator_fast<Item> it(param->copy_funcs);
 
6934
  Item_copy_string *item;
 
6935
  while ((item = (Item_copy_string*) it++))
6938
6936
    item->copy();
6939
 
    ++it;
6940
 
  }
6941
6937
}
6942
6938
 
6943
6939
/**