~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/ha_myisam.cc

Merged null-not-zero-as-pointer into remove-bit_fields_as_long.

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 |
76
77
                                     HTON_TEMPORARY_ONLY |
77
78
                                     HTON_NULL_IN_KEY |
78
 
                                     HTON_MRR_CANT_SORT |
79
79
                                     HTON_HAS_RECORDS |
80
80
                                     HTON_DUPLICATE_POS |
81
81
                                     HTON_AUTO_PART_KEY |
82
 
                                     HTON_NEED_READ_RANGE_BUFFER |
83
82
                                     HTON_SKIP_STORE_LOCK |
84
83
                                     HTON_FILE_BASED ) {}
85
84
 
87
86
  { }
88
87
 
89
88
  virtual Cursor *create(TableShare &table,
90
 
                         drizzled::memory::Root *mem_root)
 
89
                         memory::Root *mem_root)
91
90
  {
92
91
    return new (mem_root) ha_myisam(*this, table);
93
92
  }
98
97
 
99
98
  int doCreateTable(Session *, const char *table_name,
100
99
                    Table& table_arg,
101
 
                    drizzled::message::Table&);
 
100
                    message::Table&);
102
101
 
103
102
  int doRenameTable(Session*, const char *from, const char *to);
104
103
 
109
108
                           const char *db,
110
109
                           const char *table_name,
111
110
                           const bool is_tmp,
112
 
                           drizzled::message::Table *table_proto);
 
111
                           message::Table *table_proto);
113
112
 
114
113
  /* Temp only engine, so do not return values. */
115
 
  void doGetTableNames(drizzled::CachedDirectory &, string& , set<string>&) { };
 
114
  void doGetTableNames(CachedDirectory &, string& , set<string>&) { };
116
115
 
117
116
  uint32_t max_supported_keys()          const { return MI_MAX_KEY; }
118
117
  uint32_t max_supported_key_length()    const { return MI_MAX_KEY_LENGTH; }
133
132
                                       const char *,
134
133
                                       const char *,
135
134
                                       const bool,
136
 
                                       drizzled::message::Table *table_proto)
 
135
                                       message::Table *table_proto)
137
136
{
138
137
  int error= ENOENT;
139
138
  ProtoCache::iterator iter;
198
197
  HA_KEYSEG *keyseg;
199
198
  TableShare *share= table_arg->s;
200
199
  uint32_t options= share->db_options_in_use;
201
 
  if (!(drizzled::memory::multi_malloc(false,
 
200
  if (!(memory::multi_malloc(false,
202
201
          recinfo_out, (share->fields * 2 + 2) * sizeof(MI_COLUMNDEF),
203
202
          keydef_out, share->keys * sizeof(MI_KEYDEF),
204
203
          &keyseg, (share->key_parts + share->keys) * sizeof(HA_KEYSEG),
452
451
}
453
452
 
454
453
 
455
 
extern "C" {
456
 
 
457
454
volatile int *killed_ptr(MI_CHECK *param)
458
455
{
459
456
  /* In theory Unsafe conversion, but should be ok for now */
525
522
  pthread_mutex_unlock(&file->s->intern_lock);
526
523
}
527
524
 
528
 
}
529
 
 
530
 
ha_myisam::ha_myisam(drizzled::plugin::StorageEngine &engine_arg,
 
525
ha_myisam::ha_myisam(plugin::StorageEngine &engine_arg,
531
526
                     TableShare &table_arg)
532
527
  : Cursor(engine_arg, table_arg),
533
528
  file(0),
535
530
  is_ordered(true)
536
531
{ }
537
532
 
538
 
Cursor *ha_myisam::clone(drizzled::memory::Root *mem_root)
 
533
Cursor *ha_myisam::clone(memory::Root *mem_root)
539
534
{
540
535
  ha_myisam *new_handler= static_cast <ha_myisam *>(Cursor::clone(mem_root));
541
536
  if (new_handler)
715
710
      {
716
711
        char buf[40];
717
712
        /* TODO: respect myisam_repair_threads variable */
718
 
        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));
719
714
        session->set_proc_info(buf);
720
715
        error = mi_repair_parallel(&param, file, fixed_name,
721
716
            param.testflag & T_QUICK);
788
783
    {
789
784
      char llbuff[22],llbuff2[22];
790
785
      mi_check_print_warning(&param,"Number of rows changed from %s to %s",
791
 
                             llstr(rows,llbuff),
792
 
                             llstr(file->state->records,llbuff2));
 
786
                             internal::llstr(rows,llbuff),
 
787
                             internal::llstr(file->state->records,llbuff2));
793
788
    }
794
789
  }
795
790
  else
1189
1184
int ha_myisam::rnd_pos(unsigned char *buf, unsigned char *pos)
1190
1185
{
1191
1186
  ha_statistic_increment(&SSV::ha_read_rnd_count);
1192
 
  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));
1193
1188
  table->status=error ? STATUS_NOT_FOUND: 0;
1194
1189
  return error;
1195
1190
}
1197
1192
 
1198
1193
void ha_myisam::position(const unsigned char *)
1199
1194
{
1200
 
  my_off_t row_position= mi_position(file);
1201
 
  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);
1202
1197
}
1203
1198
 
1204
1199
int ha_myisam::info(uint32_t flag)
1290
1285
     if table is symlinked (Ie;  Real name is not same as generated name)
1291
1286
   */
1292
1287
    data_file_name= index_file_name= 0;
1293
 
    fn_format(name_buff, file->filename, "", MI_NAME_DEXT,
 
1288
    internal::fn_format(name_buff, file->filename, "", MI_NAME_DEXT,
1294
1289
              MY_APPEND_EXT | MY_UNPACK_FILENAME);
1295
1290
    if (strcmp(name_buff, misam_info.data_file_name))
1296
1291
      data_file_name=misam_info.data_file_name;
1297
 
    fn_format(name_buff, file->filename, "", MI_NAME_IEXT,
 
1292
    internal::fn_format(name_buff, file->filename, "", MI_NAME_IEXT,
1298
1293
              MY_APPEND_EXT | MY_UNPACK_FILENAME);
1299
1294
    if (strcmp(name_buff, misam_info.index_file_name))
1300
1295
      index_file_name=misam_info.index_file_name;
1302
1297
  if (flag & HA_STATUS_ERRKEY)
1303
1298
  {
1304
1299
    errkey  = misam_info.errkey;
1305
 
    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);
1306
1301
  }
1307
1302
  if (flag & HA_STATUS_TIME)
1308
1303
    stats.update_time = misam_info.update_time;
1361
1356
 
1362
1357
int MyisamEngine::doCreateTable(Session *, const char *table_name,
1363
1358
                                Table& table_arg,
1364
 
                                drizzled::message::Table& create_proto)
 
1359
                                message::Table& create_proto)
1365
1360
{
1366
1361
  int error;
1367
1362
  uint32_t create_flags= 0, create_records;
1386
1381
  create_info.index_file_name=  NULL;
1387
1382
  create_info.language= share->table_charset->number;
1388
1383
 
1389
 
  if (create_proto.type() == drizzled::message::Table::TEMPORARY)
 
1384
  if (create_proto.type() == message::Table::TEMPORARY)
1390
1385
    create_flags|= HA_CREATE_TMP_TABLE;
1391
1386
  if (options & HA_OPTION_PACK_RECORD)
1392
1387
    create_flags|= HA_PACK_RECORD;
1393
1388
 
1394
 
  /* TODO: Check that the following fn_format is really needed */
1395
 
  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, "", "",
1396
1391
                             MY_UNPACK_FILENAME|MY_APPEND_EXT),
1397
1392
                   share->keys, keydef,
1398
1393
                   create_records, recinfo,
1503
1498
 
1504
1499
static MyisamEngine *engine= NULL;
1505
1500
 
1506
 
static int myisam_init(drizzled::plugin::Registry &registry)
 
1501
static int myisam_init(plugin::Registry &registry)
1507
1502
{
1508
1503
  int error;
1509
1504
  engine= new MyisamEngine(engine_name);
1524
1519
  return 0;
1525
1520
}
1526
1521
 
1527
 
static int myisam_deinit(drizzled::plugin::Registry &registry)
 
1522
static int myisam_deinit(plugin::Registry &registry)
1528
1523
{
1529
1524
  registry.remove(engine);
1530
1525
  delete engine;
1704
1699
                            N_("Default pointer size to be used for MyISAM tables."),
1705
1700
                            NULL, NULL, 6, 2, 7, 0);
1706
1701
 
1707
 
static drizzle_sys_var* system_variables[]= {
 
1702
static drizzle_sys_var* sys_variables[]= {
1708
1703
  DRIZZLE_SYSVAR(key_cache_block_size),
1709
1704
  DRIZZLE_SYSVAR(key_cache_size),
1710
1705
  DRIZZLE_SYSVAR(key_cache_division_limit),
1728
1723
  myisam_init, /* Plugin Init */
1729
1724
  myisam_deinit, /* Plugin Deinit */
1730
1725
  NULL,                       /* status variables                */
1731
 
  system_variables,           /* system variables */
 
1726
  sys_variables,           /* system variables */
1732
1727
  NULL                        /* config options                  */
1733
1728
}
1734
1729
DRIZZLE_DECLARE_PLUGIN_END;