~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.cc

Merge Stewart's dead code removal

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"
 
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;
819
813
      String *str_val;
820
814
      String tmp;
821
815
      /* DateTime used to pick up as many string conversion possibilities as possible. */
822
 
      DateTime temporal;
 
816
      drizzled::DateTime temporal;
823
817
 
824
818
      str_val= str_arg->val_str(&tmp);
825
819
      if (! str_val)
1802
1796
 
1803
1797
    if (not_null_consts &&
1804
1798
        (intervals=
1805
 
          (interval_range*) memory::sql_alloc(sizeof(interval_range) * (rows - 1))))
 
1799
          (interval_range*) sql_alloc(sizeof(interval_range) * (rows - 1))))
1806
1800
    {
1807
1801
      if (use_decimal_comparison)
1808
1802
      {
2721
2715
  Item **agg;
2722
2716
  uint32_t nagg;
2723
2717
  uint32_t found_types= 0;
2724
 
  if (!(agg= (Item**) memory::sql_alloc(sizeof(Item*)*(ncases+1))))
 
2718
  if (!(agg= (Item**) sql_alloc(sizeof(Item*)*(ncases+1))))
2725
2719
    return;
2726
2720
 
2727
2721
  /*
3064
3058
}
3065
3059
 
3066
3060
 
3067
 
void in_vector::sort()
3068
 
{
3069
 
  internal::my_qsort2(base,used_count,size,compare, (void *) collation);
3070
 
}
3071
 
 
3072
 
 
3073
3061
int in_vector::find(Item *item)
3074
3062
{
3075
3063
  unsigned char *result=get_value(item);
3101
3089
{
3102
3090
  if (base)
3103
3091
  {
3104
 
    // base was allocated with help of memory::sql_alloc => following is OK
 
3092
    // base was allocated with help of sql_alloc => following is OK
3105
3093
    for (uint32_t i=0 ; i < count ; i++)
3106
3094
      ((String*) base)[i].free();
3107
3095
  }
3351
3339
    return;
3352
3340
  }
3353
3341
  n= tmpl->n;
3354
 
  if ((comparators= (cmp_item **) memory::sql_alloc(sizeof(cmp_item *)*n)))
 
3342
  if ((comparators= (cmp_item **) sql_alloc(sizeof(cmp_item *)*n)))
3355
3343
  {
3356
3344
    item->bring_value();
3357
3345
    item->null_value= 0;
4357
4345
                    res->ptr(),res->ptr()+res->length(),
4358
4346
                    res2->ptr(),res2->ptr()+res2->length(),
4359
4347
                    make_escape_code(cmp.cmp_collation.collation, escape),
4360
 
                    internal::wild_one,internal::wild_many) ? 0 : 1;
 
4348
                    wild_one,wild_many) ? 0 : 1;
4361
4349
}
4362
4350
 
4363
4351
 
4374
4362
    if (!res2)
4375
4363
      return OPTIMIZE_NONE;
4376
4364
 
4377
 
    if (*res2->ptr() != internal::wild_many)
 
4365
    if (*res2->ptr() != wild_many)
4378
4366
    {
4379
 
      if (args[0]->result_type() != STRING_RESULT || *res2->ptr() != internal::wild_one)
 
4367
      if (args[0]->result_type() != STRING_RESULT || *res2->ptr() != wild_one)
4380
4368
        return OPTIMIZE_OP;
4381
4369
    }
4382
4370
  }
4404
4392
    String *escape_str= escape_item->val_str(&tmp_value1);
4405
4393
    if (escape_str)
4406
4394
    {
4407
 
      escape= (char *)memory::sql_alloc(escape_str->length());
 
4395
      escape= (char *)sql_alloc(escape_str->length());
4408
4396
      strcpy(escape, escape_str->ptr()); 
4409
4397
    }
4410
4398
    else
4411
4399
    {
4412
 
      escape= (char *)memory::sql_alloc(1);
 
4400
      escape= (char *)sql_alloc(1);
4413
4401
      strcpy(escape, "\\");
4414
4402
    } 
4415
4403
   
4432
4420
      */
4433
4421
 
4434
4422
      if (len > MIN_TURBOBM_PATTERN_LEN + 2 &&
4435
 
          *first == internal::wild_many &&
4436
 
          *last  == internal::wild_many)
 
4423
          *first == wild_many &&
 
4424
          *last  == wild_many)
4437
4425
      {
4438
4426
        const char* tmp = first + 1;
4439
 
        for (; *tmp != internal::wild_many && *tmp != internal::wild_one; tmp++)
 
4427
        for (; *tmp != wild_many && *tmp != wild_one; tmp++)
4440
4428
        {
4441
4429
          if (escape == tmp)
4442
4430
            break;
5171
5159
  str->append(')');
5172
5160
}
5173
5161
 
5174
 
} /* namespace drizzled */