137
class ArchiveTableNameIterator: public drizzled::plugin::TableNameIteratorImplementation
141
uint32_t current_entry;
144
ArchiveTableNameIterator(const std::string &database)
145
: drizzled::plugin::TableNameIteratorImplementation(database), dirp(NULL), current_entry(-1)
148
~ArchiveTableNameIterator();
150
int next(std::string *name);
154
ArchiveTableNameIterator::~ArchiveTableNameIterator()
160
int ArchiveTableNameIterator::next(string *name)
162
char uname[NAME_LEN + 1];
165
uint32_t file_name_len;
166
const char *wild= NULL;
171
char path[FN_REFLEN];
173
build_table_filename(path, sizeof(path), db.c_str(), "", false);
174
dirp = my_dir(path,MYF(dir ? MY_WANT_STAT : 0));
177
if (my_errno == ENOENT)
178
my_error(ER_BAD_DB_ERROR, MYF(ME_BELL+ME_WAITTANG), db.c_str());
180
my_error(ER_CANT_READ_DIR, MYF(ME_BELL+ME_WAITTANG), path, my_errno);
190
if (current_entry == dirp->number_off_files)
197
file= dirp->dir_entry + current_entry;
199
ext= strchr(file->name, '.');
203
if (my_strcasecmp(system_charset_info, ext, ARZ) ||
204
is_prefix(file->name, TMP_FILE_PREFIX))
208
file_name_len= filename_to_tablename(file->name, uname, sizeof(uname));
210
uname[file_name_len]= '\0';
212
if (wild && wild_compare(uname, wild, 0))
221
137
class ArchiveEngine : public drizzled::plugin::StorageEngine
224
140
ArchiveEngine(const string &name_arg)
225
141
: drizzled::plugin::StorageEngine(name_arg,
227
| HTON_HAS_DATA_DICTIONARY) {}
143
| HTON_HAS_DATA_DICTIONARY)
145
table_definition_ext= ARZ;
229
148
virtual Cursor *create(TableShare *table,
230
149
MEM_ROOT *mem_root)
236
155
return ha_archive_exts;
239
int createTableImplementation(Session *session, const char *table_name,
240
Table *table_arg, HA_CREATE_INFO *create_info,
241
drizzled::message::Table* proto);
243
int getTableProtoImplementation(const char* path,
244
drizzled::message::Table *table_proto);
246
drizzled::plugin::TableNameIteratorImplementation* tableNameIterator(const std::string &database)
248
return new ArchiveTableNameIterator(database);
158
int doCreateTable(Session *session, const char *table_name,
159
Table& table_arg, HA_CREATE_INFO& create_info,
160
drizzled::message::Table& proto);
162
int doGetTableDefinition(Session& session,
165
const char *table_name,
167
drizzled::message::Table *table_proto);
169
void doGetTableNames(CachedDirectory &directory, string& , set<string>& set_of_names);
171
int doDropTable(Session&, const string table_path);
252
int ArchiveEngine::getTableProtoImplementation(const char* path,
253
drizzled::message::Table *table_proto)
175
void ArchiveEngine::doGetTableNames(CachedDirectory &directory,
177
set<string>& set_of_names)
179
CachedDirectory::Entries entries= directory.getEntries();
181
for (CachedDirectory::Entries::iterator entry_iter= entries.begin();
182
entry_iter != entries.end(); ++entry_iter)
184
CachedDirectory::Entry *entry= *entry_iter;
185
string *filename= &entry->filename;
187
assert(filename->size());
189
const char *ext= strchr(filename->c_str(), '.');
191
if (ext == NULL || my_strcasecmp(system_charset_info, ext, ARZ) ||
192
is_prefix(filename->c_str(), TMP_FILE_PREFIX))
196
char uname[NAME_LEN + 1];
197
uint32_t file_name_len;
199
file_name_len= filename_to_tablename(filename->c_str(), uname, sizeof(uname));
200
// TODO: Remove need for memory copy here
201
uname[file_name_len - sizeof(ARZ) + 1]= '\0'; // Subtract ending, place NULL
202
set_of_names.insert(uname);
208
int ArchiveEngine::doDropTable(Session&,
209
const string table_path)
212
char buff[FN_REFLEN];
214
fn_format(buff, table_path.c_str(), "", ARZ,
215
MY_UNPACK_FILENAME|MY_APPEND_EXT);
216
if (my_delete_with_symlink(buff, MYF(0)))
218
if (my_errno != ENOENT)
227
int ArchiveEngine::doGetTableDefinition(Session&,
232
drizzled::message::Table *table_proto)
255
234
struct stat stat_info;
647
int ArchiveEngine::createTableImplementation(Session *,
648
const char *table_name,
650
HA_CREATE_INFO *create_info,
651
drizzled::message::Table *proto)
626
int ArchiveEngine::doCreateTable(Session *,
627
const char *table_name,
629
HA_CREATE_INFO& create_info,
630
drizzled::message::Table& proto)
653
632
char name_buff[FN_REFLEN];
656
635
uint64_t auto_increment_value;
657
636
string serialized_proto;
659
auto_increment_value= create_info->auto_increment_value;
638
auto_increment_value= create_info.auto_increment_value;
661
for (uint32_t key= 0; key < table_arg->sizeKeys(); key++)
640
for (uint32_t key= 0; key < table_arg.sizeKeys(); key++)
663
KEY *pos= table_arg->key_info+key;
642
KEY *pos= table_arg.key_info+key;
664
643
KEY_PART_INFO *key_part= pos->key_part;
665
644
KEY_PART_INFO *key_part_end= key_part + pos->key_parts;
693
proto->SerializeToString(&serialized_proto);
672
proto.SerializeToString(&serialized_proto);
695
674
if (azwrite_frm(&create_stream, serialized_proto.c_str(),
696
675
serialized_proto.length()))
699
if (proto->options().has_comment())
678
if (proto.options().has_comment())
701
680
int write_length;
703
682
write_length= azwrite_comment(&create_stream,
704
proto->options().comment().c_str(),
705
proto->options().comment().length());
683
proto.options().comment().c_str(),
684
proto.options().comment().length());
707
686
if (write_length < 0)