~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Monty Taylor
  • Date: 2010-02-05 08:11:15 UTC
  • mfrom: (1283 build)
  • mto: (1273.13.43 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: mordred@inaugust.com-20100205081115-dr82nvrwv4lvw7sd
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
#include "drizzled/table_proto.h"
57
57
 
58
58
using namespace std;
59
 
using namespace drizzled;
 
59
 
 
60
namespace drizzled
 
61
{
60
62
 
61
63
extern pid_t current_pid;
62
64
extern plugin::StorageEngine *heap_engine;
208
210
  case DRIZZLE_TYPE_LONG:
209
211
  case DRIZZLE_TYPE_LONGLONG:
210
212
    default_item= new Item_int(default_value->c_str(),
211
 
                               (int64_t) my_strtoll10(default_value->c_str(),
212
 
                                                      NULL,
213
 
                                                      &error),
 
213
                               (int64_t) internal::my_strtoll10(default_value->c_str(),
 
214
                                                                NULL,
 
215
                                                                &error),
214
216
                               default_value->length());
215
217
    break;
216
218
  case DRIZZLE_TYPE_DOUBLE:
254
256
  return default_item;
255
257
}
256
258
 
257
 
int drizzled::parse_table_proto(Session& session,
258
 
                                message::Table &table,
259
 
                                TableShare *share)
 
259
int parse_table_proto(Session& session,
 
260
                      message::Table &table,
 
261
                      TableShare *share)
260
262
{
261
263
  int error= 0;
262
264
 
873
875
    }
874
876
    case DRIZZLE_TYPE_TIMESTAMP:
875
877
    case DRIZZLE_TYPE_DATETIME:
876
 
      field_length= drizzled::DateTime::MAX_STRING_LENGTH;
 
878
      field_length= DateTime::MAX_STRING_LENGTH;
877
879
      break;
878
880
    case DRIZZLE_TYPE_DATE:
879
 
      field_length= drizzled::Date::MAX_STRING_LENGTH;
 
881
      field_length= Date::MAX_STRING_LENGTH;
880
882
      break;
881
883
    case DRIZZLE_TYPE_ENUM:
882
884
    {
1897
1899
  from_s.append(ext);
1898
1900
  to_s.append(to);
1899
1901
  to_s.append(ext);
1900
 
  return (my_rename(from_s.c_str(),to_s.c_str(),MYF(MY_WME)));
 
1902
  return (internal::my_rename(from_s.c_str(),to_s.c_str(),MYF(MY_WME)));
1901
1903
}
1902
1904
 
1903
1905
/*
2377
2379
  uint32_t  blob_count,group_null_items, string_count;
2378
2380
  uint32_t fieldnr= 0;
2379
2381
  ulong reclength, string_total_length;
2380
 
  bool  using_unique_constraint= 0;
2381
 
  bool  use_packed_rows= 0;
 
2382
  bool  using_unique_constraint= false;
 
2383
  bool  use_packed_rows= true;
2382
2384
  bool  not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS);
2383
2385
  char  *tmpname,path[FN_REFLEN];
2384
2386
  unsigned char *pos, *group_buff, *bitmaps;
2404
2406
    No need to change table name to lower case as we are only creating
2405
2407
    MyISAM or HEAP tables here
2406
2408
  */
2407
 
  fn_format(path, path, drizzle_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME);
 
2409
  internal::fn_format(path, path, drizzle_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME);
2408
2410
 
2409
2411
 
2410
2412
  if (group)
2411
2413
  {
2412
 
    if (!param->quick_group)
 
2414
    if (! param->quick_group)
2413
2415
      group= 0;                                 // Can't use group key
2414
2416
    else for (order_st *tmp=group ; tmp ; tmp=tmp->next)
2415
2417
    {
2421
2423
      */
2422
2424
      (*tmp->item)->marker= 4;
2423
2425
      if ((*tmp->item)->max_length >= CONVERT_IF_BIGGER_TO_BLOB)
2424
 
        using_unique_constraint=1;
 
2426
        using_unique_constraint= true;
2425
2427
    }
2426
2428
    if (param->group_length >= MAX_BLOB_WIDTH)
2427
 
      using_unique_constraint=1;
 
2429
      using_unique_constraint= true;
2428
2430
    if (group)
2429
2431
      distinct= 0;                              // Can't use distinct
2430
2432
  }
2663
2665
  /* If result table is small; use a heap */
2664
2666
  /* future: storage engine selection can be made dynamic? */
2665
2667
  if (blob_count || using_unique_constraint ||
2666
 
      (select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) ==
2667
 
      OPTION_BIG_TABLES || (select_options & TMP_TABLE_FORCE_MYISAM))
 
2668
      (select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) == OPTION_BIG_TABLES)
2668
2669
  {
2669
2670
    share->storage_engine= myisam_engine;
2670
2671
    table->cursor= share->db_type()->getCursor(*share, &table->mem_root);
2671
2672
    if (group &&
2672
2673
        (param->group_parts > table->cursor->getEngine()->max_key_parts() ||
2673
2674
         param->group_length > table->cursor->getEngine()->max_key_length()))
2674
 
      using_unique_constraint=1;
 
2675
      using_unique_constraint= true;
2675
2676
  }
2676
2677
  else
2677
2678
  {
2678
2679
    share->storage_engine= heap_engine;
2679
2680
    table->cursor= share->db_type()->getCursor(*share, &table->mem_root);
2680
2681
  }
2681
 
  if (!table->cursor)
 
2682
  if (! table->cursor)
2682
2683
    goto err;
2683
2684
 
2684
2685
 
2685
 
  if (!using_unique_constraint)
 
2686
  if (! using_unique_constraint)
2686
2687
    reclength+= group_null_items;       // null flag is stored separately
2687
2688
 
2688
2689
  share->blob_fields= blob_count;
3210
3211
 
3211
3212
  if (share->keys)
3212
3213
  {                                             // Get keys for ni_create
3213
 
    bool using_unique_constraint= 0;
 
3214
    bool using_unique_constraint= false;
3214
3215
    HA_KEYSEG *seg= (HA_KEYSEG*) alloc_root(&this->mem_root,
3215
3216
                                            sizeof(*seg) * keyinfo->key_parts);
3216
3217
    if (!seg)
3224
3225
      /* Can't create a key; Make a unique constraint instead of a key */
3225
3226
      share->keys=    0;
3226
3227
      share->uniques= 1;
3227
 
      using_unique_constraint=1;
 
3228
      using_unique_constraint= true;
3228
3229
      memset(&uniquedef, 0, sizeof(uniquedef));
3229
3230
      uniquedef.keysegs=keyinfo->key_parts;
3230
3231
      uniquedef.seg=seg;
3274
3275
          In this case we have to tell MyISAM that two NULL should
3275
3276
          on INSERT be regarded at the same value
3276
3277
        */
3277
 
        if (!using_unique_constraint)
 
3278
        if (! using_unique_constraint)
3278
3279
          keydef.flag|= HA_NULL_ARE_EQUAL;
3279
3280
      }
3280
3281
    }
3737
3738
  return false;
3738
3739
}
3739
3740
 
 
3741
} /* namespace drizzled */