~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.cc

  • Committer: Monty Taylor
  • Date: 2009-12-14 22:00:27 UTC
  • mto: (1241.9.10 out-of-tree)
  • mto: This revision was merged to the branch mainline in revision 1250.
  • Revision ID: mordred@inaugust.com-20091214220027-kpmfbl452nctzc0g
pandora-build v0.85 - Fixed C++ standard setting.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
 
17
17
/**
21
21
  This file defines all compare functions
22
22
*/
23
23
 
24
 
#include "config.h"
 
24
#include "drizzled/server_includes.h"
25
25
#include "drizzled/sql_select.h"
26
26
#include "drizzled/error.h"
27
27
#include "drizzled/temporal.h"
31
31
#include "drizzled/item/int_with_ref.h"
32
32
#include "drizzled/check_stack_overrun.h"
33
33
#include "drizzled/time_functions.h"
34
 
#include "drizzled/internal/my_sys.h"
35
 
#include <math.h>
 
34
 
36
35
#include <algorithm>
37
36
 
38
37
using namespace std;
39
38
 
40
 
namespace drizzled
41
 
{
42
 
 
43
 
extern const double log_10[309];
44
39
 
45
40
static Eq_creator eq_creator;
46
41
static Ne_creator ne_creator;
570
565
{
571
566
  owner= item;
572
567
  func= comparator_matrix[type]
573
 
    [test(owner->functype() == Item_func::EQUAL_FUNC)];
574
 
 
 
568
                         [test(owner->functype() == Item_func::EQUAL_FUNC)];
575
569
  switch (type) {
576
570
  case ROW_RESULT:
577
 
    {
578
 
      uint32_t n= (*a)->cols();
579
 
      if (n != (*b)->cols())
580
 
      {
581
 
        my_error(ER_OPERAND_COLUMNS, MYF(0), n);
582
 
        comparators= 0;
583
 
        return 1;
584
 
      }
585
 
      if (!(comparators= new Arg_comparator[n]))
586
 
        return 1;
587
 
      for (uint32_t i=0; i < n; i++)
588
 
      {
589
 
        if ((*a)->element_index(i)->cols() != (*b)->element_index(i)->cols())
590
 
        {
591
 
          my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols());
592
 
          return 1;
593
 
        }
594
 
        comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
595
 
      }
596
 
      break;
597
 
    }
598
 
 
 
571
  {
 
572
    uint32_t n= (*a)->cols();
 
573
    if (n != (*b)->cols())
 
574
    {
 
575
      my_error(ER_OPERAND_COLUMNS, MYF(0), n);
 
576
      comparators= 0;
 
577
      return 1;
 
578
    }
 
579
    if (!(comparators= new Arg_comparator[n]))
 
580
      return 1;
 
581
    for (uint32_t i=0; i < n; i++)
 
582
    {
 
583
      if ((*a)->element_index(i)->cols() != (*b)->element_index(i)->cols())
 
584
      {
 
585
        my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols());
 
586
        return 1;
 
587
      }
 
588
      comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
 
589
    }
 
590
    break;
 
591
  }
599
592
  case STRING_RESULT:
 
593
  {
 
594
    /*
 
595
      We must set cmp_charset here as we may be called from for an automatic
 
596
      generated item, like in natural join
 
597
    */
 
598
    if (cmp_collation.set((*a)->collation, (*b)->collation) ||
 
599
        cmp_collation.derivation == DERIVATION_NONE)
 
600
    {
 
601
      my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name());
 
602
      return 1;
 
603
    }
 
604
    if (cmp_collation.collation == &my_charset_bin)
600
605
    {
601
606
      /*
602
 
        We must set cmp_charset here as we may be called from for an automatic
603
 
        generated item, like in natural join
 
607
        We are using BLOB/BINARY/VARBINARY, change to compare byte by byte,
 
608
        without removing end space
604
609
      */
605
 
      if (cmp_collation.set((*a)->collation, (*b)->collation) ||
606
 
          cmp_collation.derivation == DERIVATION_NONE)
607
 
      {
608
 
        my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name());
609
 
        return 1;
610
 
      }
611
 
      if (cmp_collation.collation == &my_charset_bin)
612
 
      {
613
 
        /*
614
 
          We are using BLOB/BINARY/VARBINARY, change to compare byte by byte,
615
 
          without removing end space
616
 
        */
617
 
        if (func == &Arg_comparator::compare_string)
618
 
          func= &Arg_comparator::compare_binary_string;
619
 
        else if (func == &Arg_comparator::compare_e_string)
620
 
          func= &Arg_comparator::compare_e_binary_string;
 
610
      if (func == &Arg_comparator::compare_string)
 
611
        func= &Arg_comparator::compare_binary_string;
 
612
      else if (func == &Arg_comparator::compare_e_string)
 
613
        func= &Arg_comparator::compare_e_binary_string;
621
614
 
622
 
        /*
623
 
          As this is binary compassion, mark all fields that they can't be
624
 
          transformed. Otherwise we would get into trouble with comparisons
625
 
like:
626
 
WHERE col= 'j' AND col LIKE BINARY 'j'
627
 
which would be transformed to:
628
 
WHERE col= 'j'
 
615
      /*
 
616
        As this is binary compassion, mark all fields that they can't be
 
617
        transformed. Otherwise we would get into trouble with comparisons
 
618
        like:
 
619
        WHERE col= 'j' AND col LIKE BINARY 'j'
 
620
        which would be transformed to:
 
621
        WHERE col= 'j'
629
622
      */
630
 
        (*a)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
631
 
        (*b)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
632
 
      }
633
 
      break;
 
623
      (*a)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
 
624
      (*b)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
634
625
    }
 
626
    break;
 
627
  }
635
628
  case INT_RESULT:
636
 
    {
637
 
      if (func == &Arg_comparator::compare_int_signed)
638
 
      {
639
 
        if ((*a)->unsigned_flag)
640
 
          func= (((*b)->unsigned_flag)?
641
 
                 &Arg_comparator::compare_int_unsigned :
642
 
                 &Arg_comparator::compare_int_unsigned_signed);
643
 
        else if ((*b)->unsigned_flag)
644
 
          func= &Arg_comparator::compare_int_signed_unsigned;
645
 
      }
646
 
      else if (func== &Arg_comparator::compare_e_int)
647
 
      {
648
 
        if ((*a)->unsigned_flag ^ (*b)->unsigned_flag)
649
 
          func= &Arg_comparator::compare_e_int_diff_signedness;
650
 
      }
651
 
      break;
652
 
    }
 
629
  {
 
630
    if (func == &Arg_comparator::compare_int_signed)
 
631
    {
 
632
      if ((*a)->unsigned_flag)
 
633
        func= (((*b)->unsigned_flag)?
 
634
               &Arg_comparator::compare_int_unsigned :
 
635
               &Arg_comparator::compare_int_unsigned_signed);
 
636
      else if ((*b)->unsigned_flag)
 
637
        func= &Arg_comparator::compare_int_signed_unsigned;
 
638
    }
 
639
    else if (func== &Arg_comparator::compare_e_int)
 
640
    {
 
641
      if ((*a)->unsigned_flag ^ (*b)->unsigned_flag)
 
642
        func= &Arg_comparator::compare_e_int_diff_signedness;
 
643
    }
 
644
    break;
 
645
  }
653
646
  case DECIMAL_RESULT:
654
647
    break;
655
648
  case REAL_RESULT:
 
649
  {
 
650
    if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
656
651
    {
657
 
      if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
658
 
      {
659
 
        precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
660
 
        if (func == &Arg_comparator::compare_real)
661
 
          func= &Arg_comparator::compare_real_fixed;
662
 
        else if (func == &Arg_comparator::compare_e_real)
663
 
          func= &Arg_comparator::compare_e_real_fixed;
664
 
      }
665
 
      break;
 
652
      precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
 
653
      if (func == &Arg_comparator::compare_real)
 
654
        func= &Arg_comparator::compare_real_fixed;
 
655
      else if (func == &Arg_comparator::compare_e_real)
 
656
        func= &Arg_comparator::compare_e_real_fixed;
666
657
    }
667
 
  }
668
 
 
 
658
    break;
 
659
  }
 
660
  default:
 
661
    assert(0);
 
662
  }
669
663
  return 0;
670
664
}
671
665
 
722
716
  }
723
717
 
724
718
  if (error > 0)
725
 
  {
726
719
    make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
727
720
                                 str->ptr(), str->length(),
728
721
                                 warn_type, warn_name);
729
 
  }
730
722
 
731
723
  return value;
732
724
}
765
757
*/
766
758
 
767
759
enum Arg_comparator::enum_date_cmp_type
768
 
Arg_comparator::can_compare_as_dates(Item *in_a, Item *in_b,
769
 
                                     uint64_t *const_value)
 
760
Arg_comparator::can_compare_as_dates(Item *a, Item *b, uint64_t *const_value)
770
761
{
771
762
  enum enum_date_cmp_type cmp_type= CMP_DATE_DFLT;
772
763
  Item *str_arg= 0, *date_arg= 0;
773
764
 
774
 
  if (in_a->type() == Item::ROW_ITEM || in_b->type() == Item::ROW_ITEM)
 
765
  if (a->type() == Item::ROW_ITEM || b->type() == Item::ROW_ITEM)
775
766
    return CMP_DATE_DFLT;
776
767
 
777
 
  if (in_a->is_datetime())
 
768
  if (a->is_datetime())
778
769
  {
779
 
    if (in_b->is_datetime())
 
770
    if (b->is_datetime())
780
771
      cmp_type= CMP_DATE_WITH_DATE;
781
 
    else if (in_b->result_type() == STRING_RESULT)
 
772
    else if (b->result_type() == STRING_RESULT)
782
773
    {
783
774
      cmp_type= CMP_DATE_WITH_STR;
784
 
      date_arg= in_a;
785
 
      str_arg= in_b;
 
775
      date_arg= a;
 
776
      str_arg= b;
786
777
    }
787
778
  }
788
 
  else if (in_b->is_datetime() && in_a->result_type() == STRING_RESULT)
 
779
  else if (b->is_datetime() && a->result_type() == STRING_RESULT)
789
780
  {
790
781
    cmp_type= CMP_STR_WITH_DATE;
791
 
    date_arg= in_b;
792
 
    str_arg= in_a;
 
782
    date_arg= b;
 
783
    str_arg= a;
793
784
  }
794
785
 
795
786
  if (cmp_type != CMP_DATE_DFLT)
823
814
      String *str_val;
824
815
      String tmp;
825
816
      /* DateTime used to pick up as many string conversion possibilities as possible. */
826
 
      DateTime temporal;
 
817
      drizzled::DateTime temporal;
827
818
 
828
819
      str_val= str_arg->val_str(&tmp);
829
820
      if (! str_val)
1806
1797
 
1807
1798
    if (not_null_consts &&
1808
1799
        (intervals=
1809
 
          (interval_range*) memory::sql_alloc(sizeof(interval_range) * (rows - 1))))
 
1800
          (interval_range*) sql_alloc(sizeof(interval_range) * (rows - 1))))
1810
1801
    {
1811
1802
      if (use_decimal_comparison)
1812
1803
      {
2036
2027
    ge_cmp.set_datetime_cmp_func(args, args + 1);
2037
2028
    le_cmp.set_datetime_cmp_func(args, args + 2);
2038
2029
  }
2039
 
  else if (args[0]->real_item()->type() == FIELD_ITEM)
 
2030
  else if (args[0]->real_item()->type() == FIELD_ITEM &&
 
2031
           session->lex->sql_command != SQLCOM_SHOW_CREATE)
2040
2032
  {
2041
2033
    Item_field *field_item= (Item_field*) (args[0]->real_item());
2042
2034
    if (field_item->field->can_be_compared_as_int64_t())
2196
2188
    max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
2197
2189
  }
2198
2190
  else
2199
 
  {
2200
2191
    max_length= max(args[0]->max_length, args[1]->max_length);
2201
 
  }
2202
2192
 
2203
2193
  switch (hybrid_type)
2204
2194
  {
2205
2195
  case STRING_RESULT:
2206
2196
    agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1);
2207
2197
    break;
2208
 
 
2209
2198
  case DECIMAL_RESULT:
2210
2199
  case REAL_RESULT:
2211
2200
    break;
2212
 
 
2213
2201
  case INT_RESULT:
2214
2202
    decimals= 0;
2215
2203
    break;
2216
 
 
2217
2204
  case ROW_RESULT:
 
2205
  default:
2218
2206
    assert(0);
2219
2207
  }
2220
 
 
2221
2208
  cached_field_type= agg_field_type(args, 2);
2222
2209
}
2223
2210
 
2729
2716
  Item **agg;
2730
2717
  uint32_t nagg;
2731
2718
  uint32_t found_types= 0;
2732
 
  if (!(agg= (Item**) memory::sql_alloc(sizeof(Item*)*(ncases+1))))
 
2719
  if (!(agg= (Item**) sql_alloc(sizeof(Item*)*(ncases+1))))
2733
2720
    return;
2734
2721
 
2735
2722
  /*
2755
2742
  */
2756
2743
  if (first_expr_num != -1)
2757
2744
  {
 
2745
    uint32_t i;
2758
2746
    agg[0]= args[first_expr_num];
2759
2747
    left_result_type= agg[0]->result_type();
2760
2748
 
2764
2752
    if (!(found_types= collect_cmp_types(agg, nagg)))
2765
2753
      return;
2766
2754
 
2767
 
    for (int i= STRING_RESULT; i <= DECIMAL_RESULT; i++)
 
2755
    for (i= 0; i <= (uint32_t)DECIMAL_RESULT; i++)
2768
2756
    {
2769
2757
      if (found_types & (1 << i) && !cmp_items[i])
2770
2758
      {
2850
2838
 
2851
2839
void Item_func_case::cleanup()
2852
2840
{
 
2841
  uint32_t i;
2853
2842
  Item_func::cleanup();
2854
 
  for (int i= STRING_RESULT; i <= DECIMAL_RESULT; i++)
 
2843
  for (i= 0; i <= (uint32_t)DECIMAL_RESULT; i++)
2855
2844
  {
2856
2845
    delete cmp_items[i];
2857
2846
    cmp_items[i]= 0;
2858
2847
  }
 
2848
  return;
2859
2849
}
2860
2850
 
2861
2851
 
2925
2915
{
2926
2916
  cached_field_type= agg_field_type(args, arg_count);
2927
2917
  agg_result_type(&hybrid_type, args, arg_count);
2928
 
 
2929
2918
  switch (hybrid_type) {
2930
2919
  case STRING_RESULT:
2931
2920
    count_only_length();
2932
2921
    decimals= NOT_FIXED_DEC;
2933
2922
    agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV, 1);
2934
2923
    break;
2935
 
 
2936
2924
  case DECIMAL_RESULT:
2937
2925
    count_decimal_length();
2938
2926
    break;
2939
 
 
2940
2927
  case REAL_RESULT:
2941
2928
    count_real_length();
2942
2929
    break;
2943
 
 
2944
2930
  case INT_RESULT:
2945
2931
    count_only_length();
2946
2932
    decimals= 0;
2947
2933
    break;
2948
 
 
2949
2934
  case ROW_RESULT:
 
2935
  default:
2950
2936
    assert(0);
2951
2937
  }
2952
2938
}
3073
3059
}
3074
3060
 
3075
3061
 
3076
 
void in_vector::sort()
3077
 
{
3078
 
  internal::my_qsort2(base,used_count,size,compare, (void *) collation);
3079
 
}
3080
 
 
3081
 
 
3082
3062
int in_vector::find(Item *item)
3083
3063
{
3084
3064
  unsigned char *result=get_value(item);
3110
3090
{
3111
3091
  if (base)
3112
3092
  {
3113
 
    // base was allocated with help of memory::sql_alloc => following is OK
 
3093
    // base was allocated with help of sql_alloc => following is OK
3114
3094
    for (uint32_t i=0 ; i < count ; i++)
3115
3095
      ((String*) base)[i].free();
3116
3096
  }
3270
3250
  switch (type) {
3271
3251
  case STRING_RESULT:
3272
3252
    return new cmp_item_sort_string(cs);
3273
 
 
3274
3253
  case INT_RESULT:
3275
3254
    return new cmp_item_int;
3276
 
 
3277
3255
  case REAL_RESULT:
3278
3256
    return new cmp_item_real;
3279
 
 
3280
3257
  case ROW_RESULT:
3281
3258
    return new cmp_item_row;
3282
 
 
3283
3259
  case DECIMAL_RESULT:
3284
3260
    return new cmp_item_decimal;
 
3261
  default:
 
3262
    assert(0);
 
3263
    break;
3285
3264
  }
3286
 
 
3287
3265
  return 0; // to satisfy compiler :)
3288
3266
}
3289
3267
 
3362
3340
    return;
3363
3341
  }
3364
3342
  n= tmpl->n;
3365
 
  if ((comparators= (cmp_item **) memory::sql_alloc(sizeof(cmp_item *)*n)))
 
3343
  if ((comparators= (cmp_item **) sql_alloc(sizeof(cmp_item *)*n)))
3366
3344
  {
3367
3345
    item->bring_value();
3368
3346
    item->null_value= 0;
3554
3532
  bool compare_as_datetime= false;
3555
3533
  Item *date_arg= 0;
3556
3534
  uint32_t found_types= 0;
3557
 
  uint32_t type_cnt= 0;
 
3535
  uint32_t type_cnt= 0, i;
3558
3536
  Item_result cmp_type= STRING_RESULT;
3559
3537
  left_result_type= args[0]->result_type();
3560
3538
  if (!(found_types= collect_cmp_types(args, arg_count, true)))
3568
3546
      break;
3569
3547
    }
3570
3548
  }
3571
 
  for (int i= STRING_RESULT; i <= DECIMAL_RESULT; i++)
 
3549
  for (i= 0; i <= (uint32_t)DECIMAL_RESULT; i++)
3572
3550
  {
3573
3551
    if (found_types & 1 << i)
3574
3552
    {
3675
3653
  if (type_cnt == 1 && const_itm && !nulls_in_row())
3676
3654
  {
3677
3655
    if (compare_as_datetime)
3678
 
    {
3679
3656
      array= new in_datetime(date_arg, arg_count - 1);
3680
 
    }
3681
3657
    else
3682
3658
    {
3683
3659
      /*
3688
3664
        comparison type accordingly.
3689
3665
      */
3690
3666
      if (args[0]->real_item()->type() == FIELD_ITEM &&
 
3667
          session->lex->sql_command != SQLCOM_SHOW_CREATE &&
3691
3668
          cmp_type != INT_RESULT)
3692
3669
      {
3693
3670
        Item_field *field_item= (Item_field*) (args[0]->real_item());
3703
3680
            cmp_type= INT_RESULT;
3704
3681
        }
3705
3682
      }
3706
 
 
3707
3683
      switch (cmp_type) {
3708
3684
      case STRING_RESULT:
3709
3685
        array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
3710
3686
                            cmp_collation.collation);
3711
3687
        break;
3712
 
 
3713
3688
      case INT_RESULT:
3714
3689
        array= new in_int64_t(arg_count-1);
3715
3690
        break;
3716
 
 
3717
3691
      case REAL_RESULT:
3718
3692
        array= new in_double(arg_count-1);
3719
3693
        break;
3720
 
 
3721
3694
      case ROW_RESULT:
3722
3695
        /*
3723
3696
          The row comparator was created at the beginning but only DATETIME
3726
3699
        */
3727
3700
        ((in_row*)array)->tmp.store_value(args[0]);
3728
3701
        break;
3729
 
 
3730
3702
      case DECIMAL_RESULT:
3731
3703
        array= new in_decimal(arg_count - 1);
3732
3704
        break;
 
3705
      default:
 
3706
        assert(0);
 
3707
        return;
3733
3708
      }
3734
3709
    }
3735
 
 
3736
3710
    if (array && !(session->is_fatal_error))            // If not EOM
3737
3711
    {
3738
3712
      uint32_t j=0;
3739
3713
      for (uint32_t arg_num=1 ; arg_num < arg_count ; arg_num++)
3740
3714
      {
3741
 
        if (!args[arg_num]->null_value)                 // Skip NULL values
 
3715
        if (!args[arg_num]->null_value)                 // Skip NULL values
3742
3716
        {
3743
3717
          array->set(j,args[arg_num]);
3744
 
          j++;
 
3718
          j++;
3745
3719
        }
3746
 
        else
3747
 
          have_null= 1;
 
3720
        else
 
3721
          have_null= 1;
3748
3722
      }
3749
3723
      if ((array->used_count= j))
3750
 
        array->sort();
 
3724
        array->sort();
3751
3725
    }
3752
3726
  }
3753
3727
  else
3756
3730
      cmp_items[STRING_RESULT]= new cmp_item_datetime(date_arg);
3757
3731
    else
3758
3732
    {
3759
 
      for (int i= STRING_RESULT; i <= DECIMAL_RESULT; i++)
 
3733
      for (i= 0; i <= (uint32_t) DECIMAL_RESULT; i++)
3760
3734
      {
3761
3735
        if (found_types & (1 << i) && !cmp_items[i])
3762
3736
        {
4372
4346
                    res->ptr(),res->ptr()+res->length(),
4373
4347
                    res2->ptr(),res2->ptr()+res2->length(),
4374
4348
                    make_escape_code(cmp.cmp_collation.collation, escape),
4375
 
                    internal::wild_one,internal::wild_many) ? 0 : 1;
 
4349
                    wild_one,wild_many) ? 0 : 1;
4376
4350
}
4377
4351
 
4378
4352
 
4389
4363
    if (!res2)
4390
4364
      return OPTIMIZE_NONE;
4391
4365
 
4392
 
    if (*res2->ptr() != internal::wild_many)
 
4366
    if (*res2->ptr() != wild_many)
4393
4367
    {
4394
 
      if (args[0]->result_type() != STRING_RESULT || *res2->ptr() != internal::wild_one)
 
4368
      if (args[0]->result_type() != STRING_RESULT || *res2->ptr() != wild_one)
4395
4369
        return OPTIMIZE_OP;
4396
4370
    }
4397
4371
  }
4419
4393
    String *escape_str= escape_item->val_str(&tmp_value1);
4420
4394
    if (escape_str)
4421
4395
    {
4422
 
      escape= (char *)memory::sql_alloc(escape_str->length());
 
4396
      escape= (char *)sql_alloc(escape_str->length());
4423
4397
      strcpy(escape, escape_str->ptr()); 
4424
4398
    }
4425
4399
    else
4426
4400
    {
4427
 
      escape= (char *)memory::sql_alloc(1);
 
4401
      escape= (char *)sql_alloc(1);
4428
4402
      strcpy(escape, "\\");
4429
4403
    } 
4430
4404
   
4447
4421
      */
4448
4422
 
4449
4423
      if (len > MIN_TURBOBM_PATTERN_LEN + 2 &&
4450
 
          *first == internal::wild_many &&
4451
 
          *last  == internal::wild_many)
 
4424
          *first == wild_many &&
 
4425
          *last  == wild_many)
4452
4426
      {
4453
4427
        const char* tmp = first + 1;
4454
 
        for (; *tmp != internal::wild_many && *tmp != internal::wild_one; tmp++)
 
4428
        for (; *tmp != wild_many && *tmp != wild_one; tmp++)
4455
4429
        {
4456
4430
          if (escape == tmp)
4457
4431
            break;
5114
5088
  while ((item_field= it++))
5115
5089
  {
5116
5090
    /* Skip fields of non-const tables. They haven't been read yet */
5117
 
    if (item_field->field->getTable()->const_table)
 
5091
    if (item_field->field->table->const_table)
5118
5092
    {
5119
5093
      if ((null_value= item_field->null_value) || eval_item->cmp(item_field))
5120
5094
        return 0;
5186
5160
  str->append(')');
5187
5161
}
5188
5162
 
5189
 
} /* namespace drizzled */