~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/range.cc

  • Committer: Monty Taylor
  • Date: 2010-02-04 08:14:46 UTC
  • mfrom: (1277.2.1 build) (1280.2.1 build)
  • mto: This revision was merged to the branch mainline in revision 1283.
  • Revision ID: mordred@inaugust.com-20100204081446-ldh9m486va30uap6
Put everything in drizzled into drizzled namespace.
Put internal stuff into drizzled::internal namespace.
Removed some cruft.
Now every symbol that is shipped in a header is in the drizzled namespace
and everything in the server that's not shipped is labeled internal. woot. 
Removed a lot of the extra extern "C" stuff that was in there. Less ugliness for
internal callbacks now for Sun Studio.

Show diffs side-by-side

added added

removed removed

Lines of Context:
143
143
#include "drizzled/memory/multi_malloc.h"
144
144
 
145
145
using namespace std;
146
 
using namespace drizzled;
 
146
namespace drizzled
 
147
{
147
148
 
148
149
#define HA_END_SPACE_KEY 0
149
150
 
237
238
class SEL_IMERGE;
238
239
 
239
240
 
240
 
class SEL_TREE :public drizzled::memory::SqlAlloc
 
241
class SEL_TREE :public memory::SqlAlloc
241
242
{
242
243
public:
243
244
  /*
365
366
 
366
367
static bool eq_tree(optimizer::SEL_ARG* a, optimizer::SEL_ARG *b);
367
368
 
368
 
optimizer::SEL_ARG drizzled::optimizer::null_element(optimizer::SEL_ARG::IMPOSSIBLE);
 
369
optimizer::SEL_ARG optimizer::null_element(optimizer::SEL_ARG::IMPOSSIBLE);
369
370
 
370
371
static bool null_part_in_key(KEY_PART *key_part,
371
372
                             const unsigned char *key,
387
388
  This class relies on memory manager to do the cleanup.
388
389
*/
389
390
 
390
 
class SEL_IMERGE : public drizzled::memory::SqlAlloc
 
391
class SEL_IMERGE : public memory::SqlAlloc
391
392
{
392
393
  enum { PREALLOCED_TREES= 10};
393
394
public:
622
623
 
623
624
  if (head->sort.io_cache)
624
625
  {
625
 
    memcpy(select->file, head->sort.io_cache, sizeof(IO_CACHE));
 
626
    memcpy(select->file, head->sort.io_cache, sizeof(internal::IO_CACHE));
626
627
    select->records=(ha_rows) (select->file->end_of_file/
627
628
                               head->cursor->ref_length);
628
629
    delete head->sort.io_cache;
636
637
  :
637
638
    quick(NULL),
638
639
    cond(NULL),
639
 
    file(static_cast<IO_CACHE *>(memory::sql_calloc(sizeof(IO_CACHE)))),
 
640
    file(static_cast<internal::IO_CACHE *>(memory::sql_calloc(sizeof(internal::IO_CACHE)))),
640
641
    free_cond(false)
641
642
{
642
643
  quick_keys.reset();
2006
2007
    ROR_SCAN_INFO's.
2007
2008
    Step 2: Get best ROR-intersection using an approximate algorithm.
2008
2009
  */
2009
 
  my_qsort(tree->ror_scans, tree->n_ror_scans, sizeof(ROR_SCAN_INFO*),
2010
 
           (qsort_cmp)cmp_ror_scan_info);
 
2010
  internal::my_qsort(tree->ror_scans, tree->n_ror_scans, sizeof(ROR_SCAN_INFO*),
 
2011
                     (qsort_cmp)cmp_ror_scan_info);
2011
2012
  print_ror_scans_arr(param->table, "ordered",
2012
2013
                                          tree->ror_scans,
2013
2014
                                          tree->ror_scans_end);
2197
2198
        (*scan)->covered_fields.getFirst();
2198
2199
    }
2199
2200
 
2200
 
    my_qsort(ror_scan_mark, ror_scans_end-ror_scan_mark, sizeof(ROR_SCAN_INFO*),
2201
 
             (qsort_cmp)cmp_ror_scan_info_covering);
 
2201
    internal::my_qsort(ror_scan_mark, ror_scans_end-ror_scan_mark,
 
2202
                       sizeof(ROR_SCAN_INFO*),
 
2203
                       (qsort_cmp)cmp_ror_scan_info_covering);
2202
2204
 
2203
2205
    print_ror_scans_arr(param->table,
2204
2206
                                             "remaining scans",
3233
3235
      max_str[0]= min_str[0]=0;
3234
3236
 
3235
3237
    field_length-= maybe_null;
3236
 
    int escape_code=
3237
 
      make_escape_code(field->charset(),
3238
 
                       ((Item_func_like*)(param->cond))->escape);
 
3238
    int escape_code= make_escape_code(field->charset(),
 
3239
                                      ((Item_func_like*)(param->cond))->escape);
3239
3240
    like_error= my_like_range(field->charset(),
3240
 
                              res->ptr(), res->length(),
 
3241
                              res->ptr(), res->length(),
3241
3242
                              escape_code,
3242
 
                              wild_one, wild_many,
3243
 
                              field_length,
3244
 
                              (char*) min_str+offset, (char*) max_str+offset,
3245
 
                              &min_length, &max_length);
 
3243
                              internal::wild_one, internal::wild_many,
 
3244
                              field_length,
 
3245
                              (char*) min_str+offset, (char*) max_str+offset,
 
3246
                              &min_length, &max_length);
3246
3247
    if (like_error)                             // Can't optimize with LIKE
3247
3248
      goto end;
3248
3249
 
3311
3312
    if (value->real_item()->type() == Item::FIELD_ITEM
3312
3313
        && value->result_type() == STRING_RESULT)
3313
3314
    {
3314
 
      char buff[drizzled::DateTime::MAX_STRING_LENGTH];
 
3315
      char buff[DateTime::MAX_STRING_LENGTH];
3315
3316
      String tmp(buff, sizeof(buff), &my_charset_bin);
3316
3317
      String *res= value->val_str(&tmp);
3317
3318
 
3323
3324
         * Create a datetime from the string and compare to fixed timestamp
3324
3325
         * instances representing the epoch boundaries.
3325
3326
         */
3326
 
        drizzled::DateTime value_datetime;
 
3327
        DateTime value_datetime;
3327
3328
 
3328
3329
        if (! value_datetime.from_string(res->c_ptr(), (size_t) res->length()))
3329
3330
          goto end;
3330
3331
 
3331
 
        drizzled::Timestamp max_timestamp;
3332
 
        drizzled::Timestamp min_timestamp;
 
3332
        Timestamp max_timestamp;
 
3333
        Timestamp min_timestamp;
3333
3334
 
3334
3335
        (void) max_timestamp.from_time_t((time_t) INT32_MAX);
3335
3336
        (void) min_timestamp.from_time_t((time_t) 0);
3341
3342
           * Datetime in right-hand side column is before UNIX epoch, so adjust to
3342
3343
           * lower bound.
3343
3344
           */
3344
 
          char new_value_buff[drizzled::DateTime::MAX_STRING_LENGTH];
 
3345
          char new_value_buff[DateTime::MAX_STRING_LENGTH];
3345
3346
          int new_value_length;
3346
3347
          String new_value_string(new_value_buff, sizeof(new_value_buff), &my_charset_bin);
3347
3348
 
3348
3349
          new_value_length= min_timestamp.to_string(new_value_string.c_ptr(),
3349
 
                                    drizzled::DateTime::MAX_STRING_LENGTH);
3350
 
          assert((new_value_length+1) < drizzled::DateTime::MAX_STRING_LENGTH);
 
3350
                                    DateTime::MAX_STRING_LENGTH);
 
3351
          assert((new_value_length+1) < DateTime::MAX_STRING_LENGTH);
3351
3352
          new_value_string.length(new_value_length);
3352
3353
          err= value->save_str_value_in_field(field, &new_value_string);
3353
3354
        }
3357
3358
           * Datetime in right hand side column is after UNIX epoch, so adjust
3358
3359
           * to the higher bound of the epoch.
3359
3360
           */
3360
 
          char new_value_buff[drizzled::DateTime::MAX_STRING_LENGTH];
 
3361
          char new_value_buff[DateTime::MAX_STRING_LENGTH];
3361
3362
          int new_value_length;
3362
3363
          String new_value_string(new_value_buff, sizeof(new_value_buff), &my_charset_bin);
3363
3364
 
3364
3365
          new_value_length= max_timestamp.to_string(new_value_string.c_ptr(),
3365
 
                                        drizzled::DateTime::MAX_STRING_LENGTH);
3366
 
          assert((new_value_length+1) < drizzled::DateTime::MAX_STRING_LENGTH);
 
3366
                                        DateTime::MAX_STRING_LENGTH);
 
3367
          assert((new_value_length+1) < DateTime::MAX_STRING_LENGTH);
3367
3368
          new_value_string.length(new_value_length);
3368
3369
          err= value->save_str_value_in_field(field, &new_value_string);
3369
3370
        }
6407
6408
    tmp.append(STRING_WITH_LEN("(empty)"));
6408
6409
}
6409
6410
 
 
6411
} /* namespace drizzled */