142
137
int doCreateTable(Session *,
138
const char *table_name,
143
139
Table& table_arg,
144
drizzled::TableIdentifier &identifier,
145
140
drizzled::message::Table&);
147
142
int doGetTableDefinition(Session& session,
148
TableIdentifier &identifier,
149
drizzled::message::Table &table_message);
145
const char *table_name,
147
drizzled::message::Table *table_proto);
151
149
/* Temp only engine, so do not return values. */
152
150
void doGetTableNames(drizzled::CachedDirectory &, string& , set<string>&) { };
154
int doDropTable(Session&, TableIdentifier &identifier);
152
int doDropTable(Session&, const string &table_path);
155
153
TinaShare *findOpenTable(const string table_name);
156
154
void addOpenTable(const string &table_name, TinaShare *);
157
155
void deleteOpenTable(const string &table_name);
160
158
uint32_t max_keys() const { return 0; }
161
159
uint32_t max_key_parts() const { return 0; }
162
160
uint32_t max_key_length() const { return 0; }
163
bool doDoesTableExist(Session& session, TableIdentifier &identifier);
164
int doRenameTable(Session&, TableIdentifier &from, TableIdentifier &to);
168
int Tina::doRenameTable(Session &session,
169
TableIdentifier &from, TableIdentifier &to)
172
for (const char **ext= bas_ext(); *ext ; ext++)
174
if (rename_file_ext(from.getPath().c_str(), to.getPath().c_str(), *ext))
176
if ((error=errno) != ENOENT)
182
session.renameTableMessage(from, to);
187
bool Tina::doDoesTableExist(Session &session, TableIdentifier &identifier)
189
return session.doesTableMessageExist(identifier);
193
int Tina::doDropTable(Session &session,
194
TableIdentifier &identifier)
163
int Tina::doDropTable(Session&,
164
const string &table_path)
197
167
int enoent_or_zero= ENOENT; // Error if no file was deleted
198
168
char buff[FN_REFLEN];
169
ProtoCache::iterator iter;
200
171
for (const char **ext= bas_ext(); *ext ; ext++)
202
internal::fn_format(buff, identifier.getPath().c_str(), "", *ext,
203
MY_UNPACK_FILENAME|MY_APPEND_EXT);
173
internal::fn_format(buff, table_path.c_str(), "", *ext,
174
MY_UNPACK_FILENAME|MY_APPEND_EXT);
204
175
if (internal::my_delete_with_symlink(buff, MYF(0)))
206
177
if ((error= errno) != ENOENT)
211
182
error= enoent_or_zero;
214
session.removeTableMessage(identifier);
185
pthread_mutex_lock(&proto_cache_mutex);
186
iter= proto_cache.find(table_path.c_str());
188
if (iter!= proto_cache.end())
189
proto_cache.erase(iter);
190
pthread_mutex_unlock(&proto_cache_mutex);
241
int Tina::doGetTableDefinition(Session &session,
242
drizzled::TableIdentifier &identifier,
243
drizzled::message::Table &table_message)
217
int Tina::doGetTableDefinition(Session&,
222
drizzled::message::Table *table_proto)
245
if (session.getTableMessage(identifier, 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
242
static Tina *tina_engine= NULL;
254
static int tina_init_func(drizzled::plugin::Context &context)
244
static int tina_init_func(drizzled::plugin::Registry ®istry)
257
247
tina_engine= new Tina("CSV");
258
context.add(tina_engine);
248
registry.add(tina_engine);
260
250
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);
266
265
TinaShare::TinaShare(const char *table_name_arg)
1386
1385
this (the database will call ::open() if it needs to).
1389
int Tina::doCreateTable(Session *session,
1388
int Tina::doCreateTable(Session *, const char *table_name,
1390
1389
Table& table_arg,
1391
drizzled::TableIdentifier &identifier,
1392
drizzled::message::Table &create_proto)
1390
drizzled::message::Table& create_proto)
1394
1392
char name_buff[FN_REFLEN];
1395
1393
int create_file;
1410
if ((create_file= internal::my_create(internal::fn_format(name_buff, identifier.getPath().c_str(), "", CSM_EXT,
1411
MY_REPLACE_EXT|MY_UNPACK_FILENAME), 0,
1412
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
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)
1415
1413
write_meta_file(create_file, 0, false);
1416
1414
internal::my_close(create_file, MYF(0));
1418
if ((create_file= internal::my_create(internal::fn_format(name_buff, identifier.getPath().c_str(), "", CSV_EXT,
1419
MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
1420
O_RDWR | O_TRUNC,MYF(MY_WME))) < 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)
1423
1421
internal::my_close(create_file, MYF(0));
1425
session->storeTableMessage(identifier, create_proto);
1423
pthread_mutex_lock(&proto_cache_mutex);
1424
proto_cache.insert(make_pair(table_name, create_proto));
1425
pthread_mutex_unlock(&proto_cache_mutex);
1437
1437
"CSV storage engine",
1438
1438
PLUGIN_LICENSE_GPL,
1439
1439
tina_init_func, /* Plugin Init */
1440
tina_done_func, /* Plugin Deinit */
1440
1441
NULL, /* system variables */
1441
1442
NULL /* config options */