61
62
MyisamEngine(string name_arg)
62
63
: drizzled::plugin::StorageEngine(name_arg,
63
64
HTON_CAN_RECREATE |
65
HTON_HAS_DATA_DICTIONARY |
64
66
HTON_TEMPORARY_ONLY |
65
67
HTON_FILE_BASED ) {}
67
72
virtual Cursor *create(TableShare *table,
68
73
MEM_ROOT *mem_root)
74
79
return ha_myisam_exts;
77
int createTableImplementation(Session *, const char *table_name,
79
HA_CREATE_INFO *ha_create_info,
80
drizzled::message::Table*);
82
int renameTableImplementation(Session*, const char *from, const char *to);
84
int deleteTableImplementation(Session*, const string table_name);
82
int doCreateTable(Session *, const char *table_name,
84
HA_CREATE_INFO& ha_create_info,
85
drizzled::message::Table&);
87
int doRenameTable(Session*, const char *from, const char *to);
89
int doDropTable(Session&, const string table_name);
91
int doGetTableDefinition(Session& session,
94
const char *table_name,
96
drizzled::message::Table *table_proto);
98
/* Temp only engine, so do not return values. */
99
void doGetTableNames(CachedDirectory &, string& , set<string>&) { };
103
int MyisamEngine::doGetTableDefinition(Session&,
108
drizzled::message::Table *table_proto)
111
ProtoCache::iterator iter;
113
pthread_mutex_lock(&proto_cache_mutex);
114
iter= proto_cache.find(path);
116
if (iter!= proto_cache.end())
119
table_proto->CopyFrom(((*iter).second));
122
pthread_mutex_unlock(&proto_cache_mutex);
88
128
Convert to push_Warnings if you ever care about this, otherwise, it is a no-op.
1278
1318
return mi_delete_all_rows(file);
1281
int MyisamEngine::deleteTableImplementation(Session*, const string table_name)
1321
int MyisamEngine::doDropTable(Session&, const string table_path)
1283
return mi_delete_table(table_name.c_str());
1323
ProtoCache::iterator iter;
1325
pthread_mutex_lock(&proto_cache_mutex);
1326
iter= proto_cache.find(table_path.c_str());
1328
if (iter!= proto_cache.end())
1329
proto_cache.erase(iter);
1331
pthread_mutex_unlock(&proto_cache_mutex);
1333
return mi_delete_table(table_path.c_str());
1306
int MyisamEngine::createTableImplementation(Session *, const char *table_name,
1308
HA_CREATE_INFO *ha_create_info,
1309
drizzled::message::Table* create_proto)
1356
int MyisamEngine::doCreateTable(Session *, const char *table_name,
1358
HA_CREATE_INFO& ha_create_info,
1359
drizzled::message::Table& create_proto)
1312
1362
uint32_t create_flags= 0, create_records;
1314
1364
MI_KEYDEF *keydef;
1315
1365
MI_COLUMNDEF *recinfo;
1316
1366
MI_CREATE_INFO create_info;
1317
TableShare *share= table_arg->s;
1367
TableShare *share= table_arg.s;
1318
1368
uint32_t options= share->db_options_in_use;
1319
if ((error= table2myisam(table_arg, &keydef, &recinfo, &create_records)))
1369
if ((error= table2myisam(&table_arg, &keydef, &recinfo, &create_records)))
1321
1371
memset(&create_info, 0, sizeof(create_info));
1322
create_info.max_rows= create_proto->options().max_rows();
1323
create_info.reloc_rows= create_proto->options().min_rows();
1372
create_info.max_rows= create_proto.options().max_rows();
1373
create_info.reloc_rows= create_proto.options().min_rows();
1324
1374
create_info.with_auto_increment= share->next_number_key_offset == 0;
1325
create_info.auto_increment= (ha_create_info->auto_increment_value ?
1326
ha_create_info->auto_increment_value -1 :
1375
create_info.auto_increment= (ha_create_info.auto_increment_value ?
1376
ha_create_info.auto_increment_value -1 :
1328
create_info.data_file_length= (create_proto->options().max_rows() *
1329
create_proto->options().avg_row_length());
1378
create_info.data_file_length= (create_proto.options().max_rows() *
1379
create_proto.options().avg_row_length());
1330
1380
create_info.data_file_name= NULL;
1331
1381
create_info.index_file_name= NULL;
1332
1382
create_info.language= share->table_charset->number;
1334
if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE)
1384
if (ha_create_info.options & HA_LEX_CREATE_TMP_TABLE)
1335
1385
create_flags|= HA_CREATE_TMP_TABLE;
1336
if (ha_create_info->options & HA_CREATE_KEEP_FILES)
1386
if (ha_create_info.options & HA_CREATE_KEEP_FILES)
1337
1387
create_flags|= HA_CREATE_KEEP_FILES;
1338
1388
if (options & HA_OPTION_PACK_RECORD)
1339
1389
create_flags|= HA_PACK_RECORD;
1346
1396
0, (MI_UNIQUEDEF*) 0,
1347
1397
&create_info, create_flags);
1348
1398
free((unsigned char*) recinfo);
1400
pthread_mutex_lock(&proto_cache_mutex);
1401
proto_cache.insert(make_pair(table_name, create_proto));
1402
pthread_mutex_unlock(&proto_cache_mutex);
1353
int MyisamEngine::renameTableImplementation(Session*,
1354
const char *from, const char *to)
1408
int MyisamEngine::doRenameTable(Session*,
1409
const char *from, const char *to)
1356
1411
return mi_rename(from,to);