119
119
: drizzled::plugin::StorageEngine(name_arg,
120
120
HTON_TEMPORARY_ONLY |
121
121
HTON_NO_AUTO_INCREMENT |
122
HTON_HAS_DATA_DICTIONARY |
123
HTON_SKIP_STORE_LOCK |
122
HTON_SKIP_STORE_LOCK),
125
123
tina_open_tables()
127
pthread_mutex_destroy(&tina_mutex);
127
130
virtual Cursor *create(TableShare &table,
128
131
drizzled::memory::Root *mem_root)
134
137
return ha_tina_exts;
137
int doCreateTable(Session *,
138
const char *table_name,
140
int doCreateTable(Session &,
142
drizzled::TableIdentifier &identifier,
140
143
drizzled::message::Table&);
142
145
int doGetTableDefinition(Session& session,
145
const char *table_name,
147
drizzled::message::Table *table_proto);
146
TableIdentifier &identifier,
147
drizzled::message::Table &table_message);
149
149
/* Temp only engine, so do not return values. */
150
void doGetTableNames(drizzled::CachedDirectory &, string& , set<string>&) { };
150
void doGetTableNames(drizzled::CachedDirectory &, SchemaIdentifier&, set<string>&) { };
152
int doDropTable(Session&, const string &table_path);
152
int doDropTable(Session&, TableIdentifier &identifier);
153
153
TinaShare *findOpenTable(const string table_name);
154
154
void addOpenTable(const string &table_name, TinaShare *);
155
155
void deleteOpenTable(const string &table_name);
158
158
uint32_t max_keys() const { return 0; }
159
159
uint32_t max_key_parts() const { return 0; }
160
160
uint32_t max_key_length() const { return 0; }
161
bool doDoesTableExist(Session& session, TableIdentifier &identifier);
162
int doRenameTable(Session&, TableIdentifier &from, TableIdentifier &to);
164
void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
165
drizzled::SchemaIdentifier &schema_identifier,
166
drizzled::TableIdentifiers &set_of_identifiers);
163
int Tina::doDropTable(Session&,
164
const string &table_path)
169
void Tina::doGetTableIdentifiers(drizzled::CachedDirectory&,
170
drizzled::SchemaIdentifier&,
171
drizzled::TableIdentifiers&)
175
int Tina::doRenameTable(Session &session,
176
TableIdentifier &from, TableIdentifier &to)
179
for (const char **ext= bas_ext(); *ext ; ext++)
181
if (rename_file_ext(from.getPath().c_str(), to.getPath().c_str(), *ext))
183
if ((error=errno) != ENOENT)
189
session.renameTableMessage(from, to);
194
bool Tina::doDoesTableExist(Session &session, TableIdentifier &identifier)
196
return session.doesTableMessageExist(identifier);
200
int Tina::doDropTable(Session &session,
201
TableIdentifier &identifier)
167
204
int enoent_or_zero= ENOENT; // Error if no file was deleted
168
205
char buff[FN_REFLEN];
169
ProtoCache::iterator iter;
171
207
for (const char **ext= bas_ext(); *ext ; ext++)
173
internal::fn_format(buff, table_path.c_str(), "", *ext,
174
MY_UNPACK_FILENAME|MY_APPEND_EXT);
209
internal::fn_format(buff, identifier.getPath().c_str(), "", *ext,
210
MY_UNPACK_FILENAME|MY_APPEND_EXT);
175
211
if (internal::my_delete_with_symlink(buff, MYF(0)))
177
213
if ((error= errno) != ENOENT)
217
int Tina::doGetTableDefinition(Session&,
222
drizzled::message::Table *table_proto)
248
int Tina::doGetTableDefinition(Session &session,
249
drizzled::TableIdentifier &identifier,
250
drizzled::message::Table &table_message)
225
ProtoCache::iterator iter;
227
pthread_mutex_lock(&proto_cache_mutex);
228
iter= proto_cache.find(path);
230
if (iter!= proto_cache.end())
233
table_proto->CopyFrom(((*iter).second));
236
pthread_mutex_unlock(&proto_cache_mutex);
252
if (session.getTableMessage(identifier, table_message))
242
259
static Tina *tina_engine= NULL;
244
static int tina_init_func(drizzled::plugin::Registry ®istry)
261
static int tina_init_func(drizzled::plugin::Context &context)
247
264
tina_engine= new Tina("CSV");
248
registry.add(tina_engine);
265
context.add(tina_engine);
250
267
pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST);
254
static int tina_done_func(drizzled::plugin::Registry ®istry)
256
registry.remove(tina_engine);
259
pthread_mutex_destroy(&tina_mutex);
265
273
TinaShare::TinaShare(const char *table_name_arg)
1385
1393
this (the database will call ::open() if it needs to).
1388
int Tina::doCreateTable(Session *, const char *table_name,
1396
int Tina::doCreateTable(Session &session,
1389
1397
Table& table_arg,
1390
drizzled::message::Table& create_proto)
1398
drizzled::TableIdentifier &identifier,
1399
drizzled::message::Table &create_proto)
1392
1401
char name_buff[FN_REFLEN];
1393
1402
int create_file;
1408
if ((create_file= internal::my_create(internal::fn_format(name_buff, table_name, "", CSM_EXT,
1409
MY_REPLACE_EXT|MY_UNPACK_FILENAME), 0,
1410
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
1417
if ((create_file= internal::my_create(internal::fn_format(name_buff, identifier.getPath().c_str(), "", CSM_EXT,
1418
MY_REPLACE_EXT|MY_UNPACK_FILENAME), 0,
1419
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
1413
1422
write_meta_file(create_file, 0, false);
1414
1423
internal::my_close(create_file, MYF(0));
1416
if ((create_file= internal::my_create(internal::fn_format(name_buff, table_name, "", CSV_EXT,
1417
MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
1418
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
1425
if ((create_file= internal::my_create(internal::fn_format(name_buff, identifier.getPath().c_str(), "", CSV_EXT,
1426
MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
1427
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
1421
1430
internal::my_close(create_file, MYF(0));
1423
pthread_mutex_lock(&proto_cache_mutex);
1424
proto_cache.insert(make_pair(table_name, create_proto));
1425
pthread_mutex_unlock(&proto_cache_mutex);
1432
session.storeTableMessage(identifier, create_proto);