~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.cc

  • Committer: Brian Aker
  • Date: 2011-01-12 06:45:23 UTC
  • mto: (2073.1.4 catalogs)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: brian@tangent.org-20110112064523-rqhptaqbph22qmj1
Remove custom error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
  This file defines all compare functions
22
22
*/
23
23
 
24
 
#include <config.h>
25
 
 
26
 
#include <drizzled/cached_item.h>
27
 
#include <drizzled/check_stack_overrun.h>
28
 
#include <drizzled/current_session.h>
29
 
#include <drizzled/error.h>
30
 
#include <drizzled/internal/my_sys.h>
31
 
#include <drizzled/item/cache_int.h>
32
 
#include <drizzled/item/cmpfunc.h>
33
 
#include <drizzled/item/int_with_ref.h>
34
 
#include <drizzled/item/subselect.h>
35
 
#include <drizzled/session.h>
36
 
#include <drizzled/sql_select.h>
37
 
#include <drizzled/temporal.h>
38
 
#include <drizzled/time_functions.h>
39
 
 
 
24
#include "config.h"
 
25
#include "drizzled/sql_select.h"
 
26
#include "drizzled/error.h"
 
27
#include "drizzled/temporal.h"
 
28
#include "drizzled/item/cmpfunc.h"
 
29
#include "drizzled/cached_item.h"
 
30
#include "drizzled/item/cache_int.h"
 
31
#include "drizzled/item/int_with_ref.h"
 
32
#include "drizzled/check_stack_overrun.h"
 
33
#include "drizzled/time_functions.h"
 
34
#include "drizzled/internal/my_sys.h"
40
35
#include <math.h>
41
36
#include <algorithm>
42
37
 
498
493
void Item_bool_func2::fix_length_and_dec()
499
494
{
500
495
  max_length= 1;                                     // Function returns 0 or 1
 
496
  Session *session;
501
497
 
502
498
  /*
503
499
    As some compare functions are generated after sql_yacc,
535
531
    return;
536
532
  }
537
533
 
 
534
  session= current_session;
538
535
  Item_field *field_item= NULL;
539
536
 
540
537
  if (args[0]->real_item()->type() == FIELD_ITEM)
543
540
    if (field_item->field->can_be_compared_as_int64_t() &&
544
541
        !(field_item->is_datetime() && args[1]->result_type() == STRING_RESULT))
545
542
    {
546
 
      if (convert_constant_item(&getSession(), field_item, &args[1]))
 
543
      if (convert_constant_item(session, field_item, &args[1]))
547
544
      {
548
545
        cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
549
546
                         INT_RESULT);           // Works for all types.
559
556
          !(field_item->is_datetime() &&
560
557
            args[0]->result_type() == STRING_RESULT))
561
558
      {
562
 
        if (convert_constant_item(&getSession(), field_item, &args[0]))
 
559
        if (convert_constant_item(session, field_item, &args[0]))
563
560
        {
564
561
          cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
565
562
                           INT_RESULT); // Works for all types.
572
569
  set_cmp_func();
573
570
}
574
571
 
575
 
Arg_comparator::Arg_comparator():
576
 
  session(current_session),
577
 
  a_cache(0),
578
 
  b_cache(0)
579
 
{}
580
 
 
581
 
Arg_comparator::Arg_comparator(Item **a1, Item **a2):
582
 
  a(a1),
583
 
  b(a2),
584
 
  session(current_session),
585
 
  a_cache(0),
586
 
  b_cache(0)
587
 
{}
588
572
 
589
573
int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type)
590
574
{
712
696
    converted value. 0 on error and on zero-dates -- check 'failure'
713
697
*/
714
698
 
715
 
static int64_t
716
 
get_date_from_str(Session *session, String *str, type::timestamp_t warn_type,
 
699
static uint64_t
 
700
get_date_from_str(Session *session, String *str, enum enum_drizzle_timestamp_type warn_type,
717
701
                  char *warn_name, bool *error_arg)
718
702
{
719
 
  int64_t value= 0;
720
 
  type::cut_t error= type::VALID;
 
703
  uint64_t value= 0;
 
704
  int error;
721
705
  type::Time l_time;
722
 
  type::timestamp_t ret;
723
 
 
724
 
  ret= l_time.store(str->ptr(), str->length(),
725
 
                    (TIME_FUZZY_DATE | MODE_INVALID_DATES | (session->variables.sql_mode & MODE_NO_ZERO_DATE)),
726
 
                    error);
727
 
 
728
 
  if (ret == type::DRIZZLE_TIMESTAMP_DATETIME || ret == type::DRIZZLE_TIMESTAMP_DATE)
 
706
  enum enum_drizzle_timestamp_type ret;
 
707
 
 
708
  ret= str_to_datetime(str->ptr(), str->length(), &l_time,
 
709
                       (TIME_FUZZY_DATE | MODE_INVALID_DATES |
 
710
                        (session->variables.sql_mode & MODE_NO_ZERO_DATE)),
 
711
                       &error);
 
712
 
 
713
  if (ret == DRIZZLE_TIMESTAMP_DATETIME || ret == DRIZZLE_TIMESTAMP_DATE)
729
714
  {
730
715
    /*
731
716
      Do not return yet, we may still want to throw a "trailing garbage"
732
717
      warning.
733
718
    */
734
719
    *error_arg= false;
735
 
    l_time.convert(value);
 
720
    value= TIME_to_uint64_t_datetime(&l_time);
736
721
  }
737
722
  else
738
723
  {
739
724
    *error_arg= true;
740
 
    error= type::CUT;                                   /* force warning */
 
725
    error= 1;                                   /* force warning */
741
726
  }
742
727
 
743
 
  if (error != type::VALID)
 
728
  if (error > 0)
744
729
  {
745
730
    make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
746
731
                                 str->ptr(), str->length(),
785
770
 
786
771
enum Arg_comparator::enum_date_cmp_type
787
772
Arg_comparator::can_compare_as_dates(Item *in_a, Item *in_b,
788
 
                                     int64_t *const_value)
 
773
                                     uint64_t *const_value)
789
774
{
790
775
  enum enum_date_cmp_type cmp_type= CMP_DATE_DFLT;
791
776
  Item *str_arg= 0, *date_arg= 0;
796
781
  if (in_a->is_datetime())
797
782
  {
798
783
    if (in_b->is_datetime())
799
 
    {
800
784
      cmp_type= CMP_DATE_WITH_DATE;
801
 
    }
802
785
    else if (in_b->result_type() == STRING_RESULT)
803
786
    {
804
787
      cmp_type= CMP_DATE_WITH_STR;
840
823
       * Does a uint64_t conversion really have to happen here?  Fields return int64_t
841
824
       * from val_int(), not uint64_t...
842
825
       */
843
 
      int64_t value;
 
826
      uint64_t value;
844
827
      String *str_val;
845
828
      String tmp;
846
829
      /* DateTime used to pick up as many string conversion possibilities as possible. */
866
849
      }
867
850
 
868
851
      /* String conversion was good.  Convert to an integer for comparison purposes. */
869
 
      temporal.to_int64_t(&value);
 
852
      int64_t int_value;
 
853
      temporal.to_int64_t(&int_value);
 
854
      value= (uint64_t) int_value;
870
855
 
871
856
      if (const_value)
872
857
        *const_value= value;
880
865
                                        Item **a1, Item **a2,
881
866
                                        Item_result type)
882
867
{
883
 
  enum_date_cmp_type cmp_type;
884
 
  int64_t const_value= -1;
 
868
  enum enum_date_cmp_type cmp_type;
 
869
  uint64_t const_value= (uint64_t)-1;
885
870
  a= a1;
886
871
  b= a2;
887
872
 
888
873
  if ((cmp_type= can_compare_as_dates(*a, *b, &const_value)))
889
874
  {
 
875
    session= current_session;
890
876
    owner= owner_arg;
891
877
    a_type= (*a)->field_type();
892
878
    b_type= (*b)->field_type();
893
879
    a_cache= 0;
894
880
    b_cache= 0;
895
881
 
896
 
    if (const_value != -1)
 
882
    if (const_value != (uint64_t)-1)
897
883
    {
898
884
      Item_cache_int *cache= new Item_cache_int();
899
885
      /* Mark the cache as non-const to prevent re-caching. */
914
900
    is_nulls_eq= test(owner && owner->functype() == Item_func::EQUAL_FUNC);
915
901
    func= &Arg_comparator::compare_datetime;
916
902
    get_value_func= &get_datetime_value;
917
 
 
918
903
    return 0;
919
904
  }
920
905
 
924
909
 
925
910
void Arg_comparator::set_datetime_cmp_func(Item **a1, Item **b1)
926
911
{
 
912
  session= current_session;
927
913
  /* A caller will handle null values by itself. */
928
914
  owner= NULL;
929
915
  a= a1;
967
953
    obtained value
968
954
*/
969
955
 
970
 
int64_t
 
956
uint64_t
971
957
get_datetime_value(Session *session, Item ***item_arg, Item **cache_arg,
972
958
                   Item *warn_item, bool *is_null)
973
959
{
974
 
  int64_t value= 0;
 
960
  uint64_t value= 0;
975
961
  String buf, *str= 0;
976
962
  Item *item= **item_arg;
977
963
 
995
981
    str= item->val_str(&buf);
996
982
    *is_null= item->null_value;
997
983
  }
998
 
 
999
984
  if (*is_null)
1000
985
    return ~(uint64_t) 0;
1001
 
 
1002
986
  /*
1003
987
    Convert strings to the integer DATE/DATETIME representation.
1004
988
    Even if both dates provided in strings we can't compare them directly as
1009
993
  {
1010
994
    bool error;
1011
995
    enum_field_types f_type= warn_item->field_type();
1012
 
    type::timestamp_t t_type= f_type == DRIZZLE_TYPE_DATE ? type::DRIZZLE_TIMESTAMP_DATE : type::DRIZZLE_TIMESTAMP_DATETIME;
 
996
    enum enum_drizzle_timestamp_type t_type= f_type ==
 
997
      DRIZZLE_TYPE_DATE ? DRIZZLE_TIMESTAMP_DATE : DRIZZLE_TIMESTAMP_DATETIME;
1013
998
    value= get_date_from_str(session, str, t_type, warn_item->name, &error);
1014
999
    /*
1015
1000
      If str did not contain a valid date according to the current
1032
1017
    *cache_arg= cache;
1033
1018
    *item_arg= cache_arg;
1034
1019
  }
1035
 
 
1036
1020
  return value;
1037
1021
}
1038
1022
 
1684
1668
    change records at each execution.
1685
1669
  */
1686
1670
  if ((*args) != new_item)
1687
 
    getSession().change_item_tree(args, new_item);
 
1671
    current_session->change_item_tree(args, new_item);
1688
1672
 
1689
1673
  /*
1690
1674
    Transform the right IN operand which should be an Item_in_subselect or a
1997
1981
  if (Item_func_opt_neg::fix_fields(session, ref))
1998
1982
    return 1;
1999
1983
 
2000
 
  session->getLex()->current_select->between_count++;
 
1984
  session->lex->current_select->between_count++;
2001
1985
 
2002
1986
  /* not_null_tables_cache == union(T1(e),T1(e1),T1(e2)) */
2003
1987
  if (pred_level && !negated)
2018
2002
  int i;
2019
2003
  bool datetime_found= false;
2020
2004
  compare_as_dates= true;
 
2005
  Session *session= current_session;
2021
2006
 
2022
2007
  /*
2023
2008
    As some compare functions are generated after sql_yacc,
2064
2049
        The following can't be recoded with || as convert_constant_item
2065
2050
        changes the argument
2066
2051
      */
2067
 
      if (convert_constant_item(&getSession(), field_item, &args[1]))
 
2052
      if (convert_constant_item(session, field_item, &args[1]))
2068
2053
        cmp_type=INT_RESULT;                    // Works for all types.
2069
 
      if (convert_constant_item(&getSession(), field_item, &args[2]))
 
2054
      if (convert_constant_item(session, field_item, &args[2]))
2070
2055
        cmp_type=INT_RESULT;                    // Works for all types.
2071
2056
    }
2072
2057
  }
3196
3181
  return;
3197
3182
}
3198
3183
 
3199
 
in_int64_t::in_int64_t(uint32_t elements) :
3200
 
  in_vector(elements, sizeof(packed_int64_t),(qsort2_cmp) cmp_int64_t, 0)
 
3184
in_int64_t::in_int64_t(uint32_t elements)
 
3185
  :in_vector(elements,sizeof(packed_int64_t),(qsort2_cmp) cmp_int64_t, 0)
3201
3186
{}
3202
3187
 
3203
3188
void in_int64_t::set(uint32_t pos,Item *item)
3217
3202
  return (unsigned char*) &tmp;
3218
3203
}
3219
3204
 
3220
 
in_datetime::in_datetime(Item *warn_item_arg, uint32_t elements) :
3221
 
  in_int64_t(elements),
3222
 
  session(current_session),
3223
 
  warn_item(warn_item_arg),
3224
 
  lval_cache(0)
3225
 
{}
3226
 
 
3227
 
void in_datetime::set(uint32_t pos, Item *item)
 
3205
void in_datetime::set(uint32_t pos,Item *item)
3228
3206
{
3229
3207
  Item **tmp_item= &item;
3230
3208
  bool is_null;
3574
3552
{
3575
3553
  Item **arg, **arg_end;
3576
3554
  bool const_itm= 1;
 
3555
  Session *session= current_session;
3577
3556
  bool datetime_found= false;
3578
3557
  /* true <=> arguments values will be compared as DATETIMEs. */
3579
3558
  bool compare_as_datetime= false;
3721
3700
          bool all_converted= true;
3722
3701
          for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
3723
3702
          {
3724
 
            if (!convert_constant_item (&getSession(), field_item, &arg[0]))
 
3703
            if (!convert_constant_item (session, field_item, &arg[0]))
3725
3704
              all_converted= false;
3726
3705
          }
3727
3706
          if (all_converted)
3758
3737
      }
3759
3738
    }
3760
3739
 
3761
 
    if (array && !(getSession().is_fatal_error))                // If not EOM
 
3740
    if (array && !(session->is_fatal_error))            // If not EOM
3762
3741
    {
3763
3742
      uint32_t j=0;
3764
3743
      for (uint32_t arg_num=1 ; arg_num < arg_count ; arg_num++)
3886
3865
 
3887
3866
void Item_cond::copy_andor_arguments(Session *session, Item_cond *item)
3888
3867
{
3889
 
  List<Item>::iterator li(item->list.begin());
 
3868
  List_iterator_fast<Item> li(item->list);
3890
3869
  while (Item *it= li++)
3891
3870
    list.push_back(it->copy_andor_structure(session));
3892
3871
}
3896
3875
Item_cond::fix_fields(Session *session, Item **)
3897
3876
{
3898
3877
  assert(fixed == 0);
3899
 
  List<Item>::iterator li(list.begin());
 
3878
  List_iterator<Item> li(list);
3900
3879
  Item *item;
3901
3880
  void *orig_session_marker= session->session_marker;
3902
3881
  unsigned char buff[sizeof(char*)];                    // Max local vars in function
3936
3915
           !((Item_cond*) item)->list.is_empty())
3937
3916
    {                                           // Identical function
3938
3917
      li.replace(((Item_cond*) item)->list);
3939
 
      ((Item_cond*) item)->list.clear();
 
3918
      ((Item_cond*) item)->list.empty();
3940
3919
      item= *li.ref();                          // new current item
3941
3920
    }
3942
3921
    if (abort_on_null)
3962
3941
    if (item->maybe_null)
3963
3942
      maybe_null=1;
3964
3943
  }
3965
 
  session->getLex()->current_select->cond_count+= list.elements;
 
3944
  session->lex->current_select->cond_count+= list.elements;
3966
3945
  session->session_marker= orig_session_marker;
3967
3946
  fix_length_and_dec();
3968
3947
  fixed= 1;
3972
3951
 
3973
3952
void Item_cond::fix_after_pullout(Select_Lex *new_parent, Item **)
3974
3953
{
3975
 
  List<Item>::iterator li(list.begin());
 
3954
  List_iterator<Item> li(list);
3976
3955
  Item *item;
3977
3956
 
3978
3957
  used_tables_cache=0;
4004
3983
 
4005
3984
bool Item_cond::walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
4006
3985
{
4007
 
  List<Item>::iterator li(list.begin());
 
3986
  List_iterator_fast<Item> li(list);
4008
3987
  Item *item;
4009
3988
  while ((item= li++))
4010
3989
    if (item->walk(processor, walk_subquery, arg))
4033
4012
 
4034
4013
Item *Item_cond::transform(Item_transformer transformer, unsigned char *arg)
4035
4014
{
4036
 
  List<Item>::iterator li(list.begin());
 
4015
  List_iterator<Item> li(list);
4037
4016
  Item *item;
4038
4017
  while ((item= li++))
4039
4018
  {
4048
4027
      change records at each execution.
4049
4028
    */
4050
4029
    if (new_item != item)
4051
 
      getSession().change_item_tree(li.ref(), new_item);
 
4030
      current_session->change_item_tree(li.ref(), new_item);
4052
4031
  }
4053
4032
  return Item_func::transform(transformer, arg);
4054
4033
}
4084
4063
  if (!(this->*analyzer)(arg_p))
4085
4064
    return 0;
4086
4065
 
4087
 
  List<Item>::iterator li(list.begin());
 
4066
  List_iterator<Item> li(list);
4088
4067
  Item *item;
4089
4068
  while ((item= li++))
4090
4069
  {
4103
4082
void Item_cond::traverse_cond(Cond_traverser traverser,
4104
4083
                              void *arg, traverse_order order)
4105
4084
{
4106
 
  List<Item>::iterator li(list.begin());
 
4085
  List_iterator<Item> li(list);
4107
4086
  Item *item;
4108
4087
 
4109
4088
  switch (order) {
4144
4123
void Item_cond::split_sum_func(Session *session, Item **ref_pointer_array,
4145
4124
                               List<Item> &fields)
4146
4125
{
4147
 
  List<Item>::iterator li(list.begin());
 
4126
  List_iterator<Item> li(list);
4148
4127
  Item *item;
4149
4128
  while ((item= li++))
4150
4129
    item->split_sum_func(session, ref_pointer_array,
4161
4140
 
4162
4141
void Item_cond::update_used_tables()
4163
4142
{
4164
 
  List<Item>::iterator li(list.begin());
 
4143
  List_iterator_fast<Item> li(list);
4165
4144
  Item *item;
4166
4145
 
4167
4146
  used_tables_cache=0;
4178
4157
void Item_cond::print(String *str, enum_query_type query_type)
4179
4158
{
4180
4159
  str->append('(');
4181
 
  List<Item>::iterator li(list.begin());
 
4160
  List_iterator_fast<Item> li(list);
4182
4161
  Item *item;
4183
4162
  if ((item=li++))
4184
4163
    item->print(str, query_type);
4195
4174
 
4196
4175
void Item_cond::neg_arguments(Session *session)
4197
4176
{
4198
 
  List<Item>::iterator li(list.begin());
 
4177
  List_iterator<Item> li(list);
4199
4178
  Item *item;
4200
4179
  while ((item= li++))          /* Apply not transformation to the arguments */
4201
4180
  {
4233
4212
int64_t Item_cond_and::val_int()
4234
4213
{
4235
4214
  assert(fixed == 1);
4236
 
  List<Item>::iterator li(list.begin());
 
4215
  List_iterator_fast<Item> li(list);
4237
4216
  Item *item;
4238
4217
  null_value= 0;
4239
4218
  while ((item=li++))
4251
4230
int64_t Item_cond_or::val_int()
4252
4231
{
4253
4232
  assert(fixed == 1);
4254
 
  List<Item>::iterator li(list.begin());
 
4233
  List_iterator_fast<Item> li(list);
4255
4234
  Item *item;
4256
4235
  null_value=0;
4257
4236
  while ((item=li++))
4488
4467
      {
4489
4468
        pattern     = first + 1;
4490
4469
        pattern_len = (int) len - 2;
4491
 
        int *suff = (int*) session->getMemRoot()->allocate((int) (sizeof(int)*
4492
 
                                                                  ((pattern_len + 1)*2+
4493
 
                                                                   alphabet_size)));
 
4470
        int *suff = (int*) session->alloc((int) (sizeof(int)*
 
4471
                                      ((pattern_len + 1)*2+
 
4472
                                      alphabet_size)));
4494
4473
        bmGs      = suff + pattern_len + 1;
4495
4474
        bmBc      = bmGs + pattern_len + 1;
4496
4475
        turboBM_compute_good_suffix_shifts(suff);
4507
4486
  Item_bool_func2::cleanup();
4508
4487
}
4509
4488
 
4510
 
static unsigned char likeconv(const CHARSET_INFO *cs, unsigned char a)
4511
 
{
4512
4489
#ifdef LIKE_CMP_TOUPPER
4513
 
  return cs->toupper(a);
 
4490
#define likeconv(cs,A) (unsigned char) (cs)->toupper(A)
4514
4491
#else
4515
 
  return cs->sort_order[a];
 
4492
#define likeconv(cs,A) (unsigned char) (cs)->sort_order[(unsigned char) (A)]
4516
4493
#endif
4517
 
}
 
4494
 
4518
4495
 
4519
4496
/**
4520
4497
  Precomputation dependent only on pattern_len.
4651
4628
 
4652
4629
bool Item_func_like::turboBM_matches(const char* text, int text_len) const
4653
4630
{
4654
 
  int bcShift;
4655
 
  int turboShift;
 
4631
  register int bcShift;
 
4632
  register int turboShift;
4656
4633
  int shift = pattern_len;
4657
4634
  int j     = 0;
4658
4635
  int u     = 0;
4666
4643
  {
4667
4644
    while (j <= tlmpl)
4668
4645
    {
4669
 
      int i= plm1;
 
4646
      register int i= plm1;
4670
4647
      while (i >= 0 && pattern[i] == text[i + j])
4671
4648
      {
4672
4649
        i--;
4676
4653
      if (i < 0)
4677
4654
        return 1;
4678
4655
 
4679
 
      const int v = plm1 - i;
 
4656
      register const int v = plm1 - i;
4680
4657
      turboShift = u - v;
4681
4658
      bcShift    = bmBc[(uint32_t) (unsigned char) text[i + j]] - plm1 + i;
4682
4659
      shift      = (turboShift > bcShift) ? turboShift : bcShift;
4697
4674
  {
4698
4675
    while (j <= tlmpl)
4699
4676
    {
4700
 
      int i = plm1;
 
4677
      register int i = plm1;
4701
4678
      while (i >= 0 && likeconv(cs,pattern[i]) == likeconv(cs,text[i + j]))
4702
4679
      {
4703
4680
        i--;
4708
4685
      if (i < 0)
4709
4686
        return 1;
4710
4687
 
4711
 
      const int v= plm1 - i;
 
4688
      register const int v= plm1 - i;
4712
4689
      turboShift= u - v;
4713
4690
      bcShift= bmBc[(uint32_t) likeconv(cs, text[i + j])] - plm1 + i;
4714
4691
      shift= (turboShift > bcShift) ? turboShift : bcShift;
4749
4726
int64_t Item_cond_xor::val_int()
4750
4727
{
4751
4728
  assert(fixed == 1);
4752
 
  List<Item>::iterator li(list.begin());
 
4729
  List_iterator<Item> li(list);
4753
4730
  Item *item;
4754
4731
  int result=0;
4755
4732
  null_value=0;
4929
4906
  : item::function::Boolean(), eval_item(0), cond_false(0)
4930
4907
{
4931
4908
  const_item_cache= false;
4932
 
  List<Item_field>::iterator li(item_equal->fields.begin());
 
4909
  List_iterator_fast<Item_field> li(item_equal->fields);
4933
4910
  Item_field *item;
4934
4911
  while ((item= li++))
4935
4912
  {
4981
4958
 
4982
4959
bool Item_equal::contains(Field *field)
4983
4960
{
4984
 
  List<Item_field>::iterator it(fields.begin());
 
4961
  List_iterator_fast<Item_field> it(fields);
4985
4962
  Item_field *item;
4986
4963
  while ((item= it++))
4987
4964
  {
5040
5017
void Item_equal::sort(Item_field_cmpfunc cmp, void *arg)
5041
5018
{
5042
5019
  bool swap;
5043
 
  List<Item_field>::iterator it(fields.begin());
 
5020
  List_iterator<Item_field> it(fields);
5044
5021
  do
5045
5022
  {
5046
5023
    Item_field *item1= it++;
5064
5041
        ref1= ref2;
5065
5042
      }
5066
5043
    }
5067
 
    it= fields.begin();
 
5044
    it.rewind();
5068
5045
  } while (swap);
5069
5046
}
5070
5047
 
5081
5058
 
5082
5059
void Item_equal::update_const()
5083
5060
{
5084
 
  List<Item_field>::iterator it(fields.begin());
 
5061
  List_iterator<Item_field> it(fields);
5085
5062
  Item *item;
5086
5063
  while ((item= it++))
5087
5064
  {
5095
5072
 
5096
5073
bool Item_equal::fix_fields(Session *, Item **)
5097
5074
{
5098
 
  List<Item_field>::iterator li(fields.begin());
 
5075
  List_iterator_fast<Item_field> li(fields);
5099
5076
  Item *item;
5100
5077
  not_null_tables_cache= used_tables_cache= 0;
5101
5078
  const_item_cache= false;
5115
5092
 
5116
5093
void Item_equal::update_used_tables()
5117
5094
{
5118
 
  List<Item_field>::iterator li(fields.begin());
 
5095
  List_iterator_fast<Item_field> li(fields);
5119
5096
  Item *item;
5120
5097
  not_null_tables_cache= used_tables_cache= 0;
5121
5098
  if ((const_item_cache= cond_false))
5133
5110
  Item_field *item_field;
5134
5111
  if (cond_false)
5135
5112
    return 0;
5136
 
  List<Item_field>::iterator it(fields.begin());
 
5113
  List_iterator_fast<Item_field> it(fields);
5137
5114
  Item *item= const_item ? const_item : it++;
 
5115
  if ((null_value= item->null_value))
 
5116
    return 0;
5138
5117
  eval_item->store_value(item);
5139
 
  if ((null_value= item->null_value))
5140
 
    return 0;
5141
5118
  while ((item_field= it++))
5142
5119
  {
5143
5120
    /* Skip fields of non-const tables. They haven't been read yet */
5144
5121
    if (item_field->field->getTable()->const_table)
5145
5122
    {
5146
 
      if (eval_item->cmp(item_field) || (null_value= item_field->null_value))
 
5123
      if ((null_value= item_field->null_value) || eval_item->cmp(item_field))
5147
5124
        return 0;
5148
5125
    }
5149
5126
  }
5159
5136
 
5160
5137
bool Item_equal::walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
5161
5138
{
5162
 
  List<Item_field>::iterator it(fields.begin());
 
5139
  List_iterator_fast<Item_field> it(fields);
5163
5140
  Item *item;
5164
5141
  while ((item= it++))
5165
5142
  {
5171
5148
 
5172
5149
Item *Item_equal::transform(Item_transformer transformer, unsigned char *arg)
5173
5150
{
5174
 
  List<Item_field>::iterator it(fields.begin());
 
5151
  List_iterator<Item_field> it(fields);
5175
5152
  Item *item;
5176
5153
  while ((item= it++))
5177
5154
  {
5186
5163
      change records at each execution.
5187
5164
    */
5188
5165
    if (new_item != item)
5189
 
      getSession().change_item_tree((Item **) it.ref(), new_item);
 
5166
      current_session->change_item_tree((Item **) it.ref(), new_item);
5190
5167
  }
5191
5168
  return Item_func::transform(transformer, arg);
5192
5169
}
5195
5172
{
5196
5173
  str->append(func_name());
5197
5174
  str->append('(');
5198
 
  List<Item_field>::iterator it(fields.begin());
 
5175
  List_iterator_fast<Item_field> it(fields);
5199
5176
  Item *item;
5200
5177
  if (const_item)
5201
5178
    const_item->print(str, query_type);
5213
5190
  str->append(')');
5214
5191
}
5215
5192
 
5216
 
cmp_item_datetime::cmp_item_datetime(Item *warn_item_arg) :
5217
 
  session(current_session),
5218
 
  warn_item(warn_item_arg),
5219
 
  lval_cache(0)
5220
 
{}
5221
 
 
5222
5193
} /* namespace drizzled */