~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/ha_myisam.cc

Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include <algorithm>
42
42
 
43
43
using namespace std;
 
44
using namespace drizzled;
44
45
 
45
46
extern pthread_mutex_t LOCK_global_system_variables;
46
47
static const string engine_name("MyISAM");
65
66
  NULL
66
67
};
67
68
 
68
 
class MyisamEngine : public drizzled::plugin::StorageEngine
 
69
class MyisamEngine : public plugin::StorageEngine
69
70
{
70
71
public:
71
72
  MyisamEngine(string name_arg)
72
 
   : drizzled::plugin::StorageEngine(name_arg,
 
73
   : plugin::StorageEngine(name_arg,
73
74
                                     HTON_HAS_DATA_DICTIONARY |
74
75
                                     HTON_CAN_INDEX_BLOBS |
75
76
                                     HTON_STATS_RECORDS_IS_EXACT |
85
86
  { }
86
87
 
87
88
  virtual Cursor *create(TableShare &table,
88
 
                         drizzled::memory::Root *mem_root)
 
89
                         memory::Root *mem_root)
89
90
  {
90
91
    return new (mem_root) ha_myisam(*this, table);
91
92
  }
96
97
 
97
98
  int doCreateTable(Session *, const char *table_name,
98
99
                    Table& table_arg,
99
 
                    drizzled::message::Table&);
 
100
                    message::Table&);
100
101
 
101
102
  int doRenameTable(Session*, const char *from, const char *to);
102
103
 
107
108
                           const char *db,
108
109
                           const char *table_name,
109
110
                           const bool is_tmp,
110
 
                           drizzled::message::Table *table_proto);
 
111
                           message::Table *table_proto);
111
112
 
112
113
  /* Temp only engine, so do not return values. */
113
 
  void doGetTableNames(drizzled::CachedDirectory &, string& , set<string>&) { };
 
114
  void doGetTableNames(CachedDirectory &, string& , set<string>&) { };
114
115
 
115
116
  uint32_t max_supported_keys()          const { return MI_MAX_KEY; }
116
117
  uint32_t max_supported_key_length()    const { return MI_MAX_KEY_LENGTH; }
131
132
                                       const char *,
132
133
                                       const char *,
133
134
                                       const bool,
134
 
                                       drizzled::message::Table *table_proto)
 
135
                                       message::Table *table_proto)
135
136
{
136
137
  int error= ENOENT;
137
138
  ProtoCache::iterator iter;
196
197
  HA_KEYSEG *keyseg;
197
198
  TableShare *share= table_arg->s;
198
199
  uint32_t options= share->db_options_in_use;
199
 
  if (!(drizzled::memory::multi_malloc(false,
 
200
  if (!(memory::multi_malloc(false,
200
201
          recinfo_out, (share->fields * 2 + 2) * sizeof(MI_COLUMNDEF),
201
202
          keydef_out, share->keys * sizeof(MI_KEYDEF),
202
203
          &keyseg, (share->key_parts + share->keys) * sizeof(HA_KEYSEG),
450
451
}
451
452
 
452
453
 
453
 
extern "C" {
454
 
 
455
454
volatile int *killed_ptr(MI_CHECK *param)
456
455
{
457
456
  /* In theory Unsafe conversion, but should be ok for now */
523
522
  pthread_mutex_unlock(&file->s->intern_lock);
524
523
}
525
524
 
526
 
}
527
 
 
528
 
ha_myisam::ha_myisam(drizzled::plugin::StorageEngine &engine_arg,
 
525
ha_myisam::ha_myisam(plugin::StorageEngine &engine_arg,
529
526
                     TableShare &table_arg)
530
527
  : Cursor(engine_arg, table_arg),
531
528
  file(0),
533
530
  is_ordered(true)
534
531
{ }
535
532
 
536
 
Cursor *ha_myisam::clone(drizzled::memory::Root *mem_root)
 
533
Cursor *ha_myisam::clone(memory::Root *mem_root)
537
534
{
538
535
  ha_myisam *new_handler= static_cast <ha_myisam *>(Cursor::clone(mem_root));
539
536
  if (new_handler)
713
710
      {
714
711
        char buf[40];
715
712
        /* TODO: respect myisam_repair_threads variable */
716
 
        snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map));
 
713
        snprintf(buf, 40, "Repair with %d threads", internal::my_count_bits(key_map));
717
714
        session->set_proc_info(buf);
718
715
        error = mi_repair_parallel(&param, file, fixed_name,
719
716
            param.testflag & T_QUICK);
786
783
    {
787
784
      char llbuff[22],llbuff2[22];
788
785
      mi_check_print_warning(&param,"Number of rows changed from %s to %s",
789
 
                             llstr(rows,llbuff),
790
 
                             llstr(file->state->records,llbuff2));
 
786
                             internal::llstr(rows,llbuff),
 
787
                             internal::llstr(file->state->records,llbuff2));
791
788
    }
792
789
  }
793
790
  else
1187
1184
int ha_myisam::rnd_pos(unsigned char *buf, unsigned char *pos)
1188
1185
{
1189
1186
  ha_statistic_increment(&SSV::ha_read_rnd_count);
1190
 
  int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
 
1187
  int error=mi_rrnd(file, buf, internal::my_get_ptr(pos,ref_length));
1191
1188
  table->status=error ? STATUS_NOT_FOUND: 0;
1192
1189
  return error;
1193
1190
}
1195
1192
 
1196
1193
void ha_myisam::position(const unsigned char *)
1197
1194
{
1198
 
  my_off_t row_position= mi_position(file);
1199
 
  my_store_ptr(ref, ref_length, row_position);
 
1195
  internal::my_off_t row_position= mi_position(file);
 
1196
  internal::my_store_ptr(ref, ref_length, row_position);
1200
1197
}
1201
1198
 
1202
1199
int ha_myisam::info(uint32_t flag)
1288
1285
     if table is symlinked (Ie;  Real name is not same as generated name)
1289
1286
   */
1290
1287
    data_file_name= index_file_name= 0;
1291
 
    fn_format(name_buff, file->filename, "", MI_NAME_DEXT,
 
1288
    internal::fn_format(name_buff, file->filename, "", MI_NAME_DEXT,
1292
1289
              MY_APPEND_EXT | MY_UNPACK_FILENAME);
1293
1290
    if (strcmp(name_buff, misam_info.data_file_name))
1294
1291
      data_file_name=misam_info.data_file_name;
1295
 
    fn_format(name_buff, file->filename, "", MI_NAME_IEXT,
 
1292
    internal::fn_format(name_buff, file->filename, "", MI_NAME_IEXT,
1296
1293
              MY_APPEND_EXT | MY_UNPACK_FILENAME);
1297
1294
    if (strcmp(name_buff, misam_info.index_file_name))
1298
1295
      index_file_name=misam_info.index_file_name;
1300
1297
  if (flag & HA_STATUS_ERRKEY)
1301
1298
  {
1302
1299
    errkey  = misam_info.errkey;
1303
 
    my_store_ptr(dup_ref, ref_length, misam_info.dupp_key_pos);
 
1300
    internal::my_store_ptr(dup_ref, ref_length, misam_info.dupp_key_pos);
1304
1301
  }
1305
1302
  if (flag & HA_STATUS_TIME)
1306
1303
    stats.update_time = misam_info.update_time;
1359
1356
 
1360
1357
int MyisamEngine::doCreateTable(Session *, const char *table_name,
1361
1358
                                Table& table_arg,
1362
 
                                drizzled::message::Table& create_proto)
 
1359
                                message::Table& create_proto)
1363
1360
{
1364
1361
  int error;
1365
1362
  uint32_t create_flags= 0, create_records;
1384
1381
  create_info.index_file_name=  NULL;
1385
1382
  create_info.language= share->table_charset->number;
1386
1383
 
1387
 
  if (create_proto.type() == drizzled::message::Table::TEMPORARY)
 
1384
  if (create_proto.type() == message::Table::TEMPORARY)
1388
1385
    create_flags|= HA_CREATE_TMP_TABLE;
1389
1386
  if (options & HA_OPTION_PACK_RECORD)
1390
1387
    create_flags|= HA_PACK_RECORD;
1391
1388
 
1392
 
  /* TODO: Check that the following fn_format is really needed */
1393
 
  error= mi_create(fn_format(buff, table_name, "", "",
 
1389
  /* TODO: Check that the following internal::fn_format is really needed */
 
1390
  error= mi_create(internal::fn_format(buff, table_name, "", "",
1394
1391
                             MY_UNPACK_FILENAME|MY_APPEND_EXT),
1395
1392
                   share->keys, keydef,
1396
1393
                   create_records, recinfo,
1501
1498
 
1502
1499
static MyisamEngine *engine= NULL;
1503
1500
 
1504
 
static int myisam_init(drizzled::plugin::Registry &registry)
 
1501
static int myisam_init(plugin::Registry &registry)
1505
1502
{
1506
1503
  int error;
1507
1504
  engine= new MyisamEngine(engine_name);
1522
1519
  return 0;
1523
1520
}
1524
1521
 
1525
 
static int myisam_deinit(drizzled::plugin::Registry &registry)
 
1522
static int myisam_deinit(plugin::Registry &registry)
1526
1523
{
1527
1524
  registry.remove(engine);
1528
1525
  delete engine;
1702
1699
                            N_("Default pointer size to be used for MyISAM tables."),
1703
1700
                            NULL, NULL, 6, 2, 7, 0);
1704
1701
 
1705
 
static drizzle_sys_var* system_variables[]= {
 
1702
static drizzle_sys_var* sys_variables[]= {
1706
1703
  DRIZZLE_SYSVAR(key_cache_block_size),
1707
1704
  DRIZZLE_SYSVAR(key_cache_size),
1708
1705
  DRIZZLE_SYSVAR(key_cache_division_limit),
1726
1723
  myisam_init, /* Plugin Init */
1727
1724
  myisam_deinit, /* Plugin Deinit */
1728
1725
  NULL,                       /* status variables                */
1729
 
  system_variables,           /* system variables */
 
1726
  sys_variables,           /* system variables */
1730
1727
  NULL                        /* config options                  */
1731
1728
}
1732
1729
DRIZZLE_DECLARE_PLUGIN_END;