21 #include "tableprototester.h"
29 #include <drizzled/error.h>
30 #include <drizzled/charset.h>
31 #include <drizzled/internal/m_string.h>
32 #include <drizzled/internal/my_pthread.h>
33 #include <drizzled/message/table.h>
34 #include <drizzled/plugin/storage_engine.h>
35 #include <drizzled/table.h>
39 using namespace google;
40 using namespace drizzled;
42 #define TABLEPROTOTESTER_EXT ".TBT"
44 static const char *TableProtoTesterCursor_exts[] = {
54 HTON_CAN_INDEX_BLOBS |
55 HTON_SKIP_STORE_LOCK |
58 table_definition_ext= TABLEPROTOTESTER_EXT;
67 return TableProtoTesterCursor_exts;
77 int doGetTableDefinition(
Session &session,
82 uint32_t max_supported_keys()
const {
return 64; }
83 uint32_t max_supported_key_length()
const {
return 1000; }
84 uint32_t max_supported_key_part_length()
const {
return 1000; }
86 uint32_t index_flags(
enum ha_key_alg)
const
88 return (HA_READ_NEXT |
99 return HA_ERR_NO_SUCH_TABLE;
104 drizzled::identifier::table::vector &set_of_identifiers);
109 drizzled::identifier::table::vector &set_of_identifiers)
111 if (schema_identifier.compare(
"test"))
114 set_of_identifiers.push_back(
identifier::Table(schema_identifier,
"too_many_enum_values"));
115 set_of_identifiers.push_back(
identifier::Table(schema_identifier,
"invalid_table_collation"));
121 if (not identifier.getPath().compare(
"local/test/t1"))
123 if (not identifier.getPath().compare(
"local/test/too_many_enum_values"))
125 if (not identifier.getPath().compare(
"local/test/invalid_table_collation"))
133 Cursor(engine_arg, table_arg)
136 int TableProtoTesterCursor::open(
const char *,
int, uint32_t)
141 int TableProtoTesterCursor::close(
void)
146 int TableProtoTesterEngine::doCreateTable(
Session&,
157 return HA_ERR_NO_SUCH_TABLE;
165 table.set_name(
"t1");
166 table.set_type(message::Table::INTERNAL);
168 tableopts= table.mutable_options();
169 tableopts->set_comment(
"Table without a StorageEngine message");
172 field= table.add_field();
173 field->set_name(
"number");
174 field->set_type(message::Table::Field::INTEGER);
179 static void fill_table_too_many_enum_values(
message::Table &table)
184 table.set_schema(
"test");
185 table.set_name(
"too_many_enum_values");
186 table.set_type(message::Table::STANDARD);
187 table.mutable_engine()->set_name(
"tableprototester");
188 table.set_creation_timestamp(0);
189 table.set_update_timestamp(0);
191 tableopts= table.mutable_options();
192 tableopts->set_comment(
"Table with too many enum options");
193 tableopts->set_collation(
"utf8_general_ci");
194 tableopts->set_collation_id(45);
197 field= table.add_field();
198 field->set_name(
"many_values");
199 field->set_type(message::Table::Field::ENUM);
202 for(
int i=0; i<70000; i++)
204 char enum_value[100];
205 snprintf(enum_value,
sizeof(enum_value),
"a%d", i);
206 field_options->add_field_value(enum_value);
212 static void fill_table_invalid_table_collation(
message::Table &table)
217 table.set_name(
"invalid_table_collation");
218 table.set_type(message::Table::STANDARD);
219 table.set_schema(
"test");
220 table.set_creation_timestamp(0);
221 table.set_update_timestamp(0);
222 table.mutable_engine()->set_name(
"tableprototester");
224 tableopts= table.mutable_options();
225 tableopts->set_comment(
"Invalid table collation ");
228 field= table.add_field();
229 field->set_name(
"number");
230 field->set_type(message::Table::Field::INTEGER);
233 tableopts->set_collation(
"pi_pi_pi");
234 tableopts->set_collation_id(123456);
238 int TableProtoTesterEngine::doGetTableDefinition(
Session&,
242 if (not identifier.getPath().compare(
"local/test/t1"))
244 fill_table1(table_proto);
247 else if (not identifier.getPath().compare(
"local/test/too_many_enum_values"))
249 fill_table_too_many_enum_values(table_proto);
252 else if (not identifier.getPath().compare(
"local/test/invalid_table_collation"))
254 fill_table_invalid_table_collation(table_proto);
260 const char *TableProtoTesterCursor::index_type(uint32_t)
265 int TableProtoTesterCursor::doInsertRecord(
unsigned char *)
267 return(getTable()->next_number_field ? update_auto_increment() : 0);
276 int TableProtoTesterCursor::rnd_next(
unsigned char *)
278 return(HA_ERR_END_OF_FILE);
282 int TableProtoTesterCursor::rnd_pos(
unsigned char *,
unsigned char *)
289 void TableProtoTesterCursor::position(
const unsigned char *)
296 int TableProtoTesterCursor::info(uint32_t flag)
298 memset(&stats, 0,
sizeof(stats));
299 if (flag & HA_STATUS_AUTO)
300 stats.auto_increment_value= 1;
306 key_part_map,
enum ha_rkey_function)
308 return(HA_ERR_END_OF_FILE);
313 key_part_map,
enum ha_rkey_function)
315 return(HA_ERR_END_OF_FILE);
321 return(HA_ERR_END_OF_FILE);
325 int TableProtoTesterCursor::index_next(
unsigned char *)
327 return(HA_ERR_END_OF_FILE);
331 int TableProtoTesterCursor::index_prev(
unsigned char *)
333 return(HA_ERR_END_OF_FILE);
337 int TableProtoTesterCursor::index_first(
unsigned char *)
339 return(HA_ERR_END_OF_FILE);
343 int TableProtoTesterCursor::index_last(
unsigned char *)
345 return(HA_ERR_END_OF_FILE);
354 context.add(tableprototester_engine);
359 DRIZZLE_DECLARE_PLUGIN
365 N_(
"StorageEngine module for testing table proto messages"),
367 tableprototester_init,
371 DRIZZLE_DECLARE_PLUGIN_END;