~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-11-28 22:02:19 UTC
  • mfrom: (1228 push)
  • mto: (1228.4.1 push)
  • mto: This revision was merged to the branch mainline in revision 1234.
  • Revision ID: osullivan.padraig@gmail.com-20091128220219-m3x28m8q2unbirke
MergeĀ fromĀ trunk.

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