70
69
class MyisamEngine : public plugin::StorageEngine
73
MyisamEngine(const MyisamEngine&);
74
MyisamEngine& operator=(const MyisamEngine&);
76
explicit MyisamEngine(string name_arg) :
77
plugin::StorageEngine(name_arg,
78
HTON_HAS_DATA_DICTIONARY |
79
HTON_CAN_INDEX_BLOBS |
80
HTON_STATS_RECORDS_IS_EXACT |
86
HTON_SKIP_STORE_LOCK |
89
pthread_mutex_init(&THR_LOCK_myisam,MY_MUTEX_INIT_FAST);
92
virtual ~MyisamEngine()
94
pthread_mutex_destroy(&THR_LOCK_myisam);
95
end_key_cache(dflt_key_cache, 1); // Can never fail
97
mi_panic(HA_PANIC_CLOSE);
72
MyisamEngine(string name_arg)
73
: plugin::StorageEngine(name_arg,
74
HTON_HAS_DATA_DICTIONARY |
75
HTON_CAN_INDEX_BLOBS |
76
HTON_STATS_RECORDS_IS_EXACT |
82
HTON_SKIP_STORE_LOCK |
100
88
virtual Cursor *create(TableShare &table,
101
89
memory::Root *mem_root)
107
95
return ha_myisam_exts;
110
int doCreateTable(Session *,
98
int doCreateTable(Session *, const char *table_name,
112
drizzled::TableIdentifier &identifier,
113
100
message::Table&);
115
int doRenameTable(Session&, TableIdentifier &from, TableIdentifier &to);
102
int doRenameTable(Session*, const char *from, const char *to);
117
int doDropTable(Session&, drizzled::TableIdentifier &identifier);
104
int doDropTable(Session&, const string &table_name);
119
106
int doGetTableDefinition(Session& session,
120
drizzled::TableIdentifier &identifier,
121
message::Table &table_message);
109
const char *table_name,
111
message::Table *table_proto);
123
113
/* Temp only engine, so do not return values. */
124
114
void doGetTableNames(CachedDirectory &, string& , set<string>&) { };
136
126
HA_KEYREAD_ONLY);
138
bool doDoesTableExist(Session& session, TableIdentifier &identifier);
141
bool MyisamEngine::doDoesTableExist(Session &session, TableIdentifier &identifier)
143
return session.doesTableMessageExist(identifier);
146
int MyisamEngine::doGetTableDefinition(Session &session,
147
drizzled::TableIdentifier &identifier,
148
message::Table &table_message)
150
if (session.getTableMessage(identifier, table_message))
130
int MyisamEngine::doGetTableDefinition(Session&,
135
message::Table *table_proto)
138
ProtoCache::iterator iter;
140
pthread_mutex_lock(&proto_cache_mutex);
141
iter= proto_cache.find(path);
143
if (iter!= proto_cache.end())
146
table_proto->CopyFrom(((*iter).second));
149
pthread_mutex_unlock(&proto_cache_mutex);
676
675
return(HA_ADMIN_FAILED);
679
param.db_name= table->s->getSchemaName();
678
param.db_name= table->s->db.str;
680
679
param.table_name= table->alias;
681
680
param.tmpfile_createflag = O_RDWR | O_TRUNC;
682
681
param.using_global_keycache = 1;
1224
1223
stats.block_size= myisam_key_cache_block_size; /* record block size */
1226
1225
/* Update share */
1227
if (share->tmp_table == message::Table::STANDARD)
1226
if (share->tmp_table == STANDARD_TABLE)
1228
1227
pthread_mutex_lock(&share->mutex);
1229
1228
set_prefix(share->keys_in_use, share->keys);
1278
1277
memcpy(table->key_info[0].rec_per_key,
1279
1278
misam_info.rec_per_key,
1280
1279
sizeof(table->key_info[0].rec_per_key)*share->key_parts);
1281
if (share->tmp_table == message::Table::STANDARD)
1280
if (share->tmp_table == STANDARD_TABLE)
1282
1281
pthread_mutex_unlock(&share->mutex);
1331
1330
return mi_delete_all_rows(file);
1334
int MyisamEngine::doDropTable(Session &session,
1335
drizzled::TableIdentifier &identifier)
1333
int MyisamEngine::doDropTable(Session&, const string &table_path)
1337
session.removeTableMessage(identifier);
1339
return mi_delete_table(identifier.getPath().c_str());
1335
ProtoCache::iterator iter;
1337
pthread_mutex_lock(&proto_cache_mutex);
1338
iter= proto_cache.find(table_path.c_str());
1340
if (iter!= proto_cache.end())
1341
proto_cache.erase(iter);
1343
pthread_mutex_unlock(&proto_cache_mutex);
1345
return mi_delete_table(table_path.c_str());
1348
1354
F_UNLCK : F_EXTRA_LCK));
1351
int MyisamEngine::doCreateTable(Session *session,
1357
int MyisamEngine::doCreateTable(Session *, const char *table_name,
1352
1358
Table& table_arg,
1353
drizzled::TableIdentifier &identifier,
1354
1359
message::Table& create_proto)
1382
1387
create_flags|= HA_PACK_RECORD;
1384
1389
/* TODO: Check that the following internal::fn_format is really needed */
1385
error= mi_create(internal::fn_format(buff, identifier.getPath().c_str(), "", "",
1386
MY_UNPACK_FILENAME|MY_APPEND_EXT),
1390
error= mi_create(internal::fn_format(buff, table_name, "", "",
1391
MY_UNPACK_FILENAME|MY_APPEND_EXT),
1387
1392
share->keys, keydef,
1388
1393
create_records, recinfo,
1389
1394
0, (MI_UNIQUEDEF*) 0,
1390
1395
&create_info, create_flags);
1391
1396
free((unsigned char*) recinfo);
1393
session->storeTableMessage(identifier, create_proto);
1398
pthread_mutex_lock(&proto_cache_mutex);
1399
proto_cache.insert(make_pair(table_name, create_proto));
1400
pthread_mutex_unlock(&proto_cache_mutex);
1399
int MyisamEngine::doRenameTable(Session &session, TableIdentifier &from, TableIdentifier &to)
1406
int MyisamEngine::doRenameTable(Session*,
1407
const char *from, const char *to)
1401
session.renameTableMessage(from, to);
1403
return mi_rename(from.getPath().c_str(), to.getPath().c_str());
1409
return mi_rename(from,to);
1493
1499
static MyisamEngine *engine= NULL;
1495
static int myisam_init(plugin::Context &context)
1501
static int myisam_init(plugin::Registry ®istry)
1497
1504
engine= new MyisamEngine(engine_name);
1498
context.add(engine);
1505
registry.add(engine);
1507
pthread_mutex_init(&THR_LOCK_myisam,MY_MUTEX_INIT_FAST);
1500
1509
/* call ha_init_key_cache() on all key caches to init them */
1501
int error= init_key_cache(dflt_key_cache,
1502
myisam_key_cache_block_size,
1503
myisam_key_cache_size,
1504
myisam_key_cache_division_limit,
1505
myisam_key_cache_age_threshold);
1510
error= init_key_cache(dflt_key_cache,
1511
myisam_key_cache_block_size,
1512
myisam_key_cache_size,
1513
myisam_key_cache_division_limit,
1514
myisam_key_cache_age_threshold);
1507
1516
if (error == 0)
1508
1517
exit(1); /* Memory Allocation Failure */
1522
static int myisam_deinit(plugin::Registry ®istry)
1524
registry.remove(engine);
1527
pthread_mutex_destroy(&THR_LOCK_myisam);
1528
end_key_cache(dflt_key_cache, 1); // Can never fail
1530
return mi_panic(HA_PANIC_CLOSE);
1514
1533
static void sys_var_key_cache_size_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1702
1721
"Default engine as of MySQL 3.23 with great performance",
1703
1722
PLUGIN_LICENSE_GPL,
1704
1723
myisam_init, /* Plugin Init */
1724
myisam_deinit, /* Plugin Deinit */
1705
1725
sys_variables, /* system variables */
1706
1726
NULL /* config options */