57
57
table_definition_ext= TABLEPROTOTESTER_EXT;
60
virtual Cursor *create(Table &table)
60
virtual Cursor *create(TableShare &table,
61
drizzled::memory::Root *mem_root)
62
return new TableProtoTesterCursor(*this, table);
63
return new (mem_root) TableProtoTesterCursor(*this, table);
65
66
const char **bas_ext() const {
69
70
int doCreateTable(Session&,
71
const drizzled::TableIdentifier &identifier,
72
drizzled::TableIdentifier &identifier,
72
73
drizzled::message::Table&);
74
int doDropTable(Session&, const drizzled::TableIdentifier &identifier);
75
int doDropTable(Session&, drizzled::TableIdentifier &identifier);
76
77
int doGetTableDefinition(Session &session,
77
const drizzled::TableIdentifier &identifier,
78
drizzled::TableIdentifier &identifier,
78
79
drizzled::message::Table &table_proto);
81
void doGetTableNames(drizzled::CachedDirectory &directory,
83
set<string>& set_of_names)
86
set_of_names.insert("t1");
80
90
/* The following defines can be increased if necessary */
81
91
uint32_t max_supported_keys() const { return 64; }
82
92
uint32_t max_supported_key_length() const { return 1000; }
94
bool doDoesTableExist(Session &session, const drizzled::TableIdentifier &identifier);
104
bool doDoesTableExist(Session &session, TableIdentifier &identifier);
96
int doRenameTable(Session&, const drizzled::TableIdentifier&, const drizzled::TableIdentifier&)
106
int doRenameTable(Session&, TableIdentifier&, TableIdentifier&)
101
111
void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
102
const drizzled::SchemaIdentifier &schema_identifier,
103
drizzled::TableIdentifier::vector &set_of_identifiers);
112
drizzled::SchemaIdentifier &schema_identifier,
113
drizzled::TableIdentifiers &set_of_identifiers);
106
116
void TableProtoTesterEngine::doGetTableIdentifiers(drizzled::CachedDirectory&,
107
const drizzled::SchemaIdentifier &schema_identifier,
108
drizzled::TableIdentifier::vector &set_of_identifiers)
117
drizzled::SchemaIdentifier &schema_identifier,
118
drizzled::TableIdentifiers &set_of_identifiers)
110
if (schema_identifier.compare("test"))
112
set_of_identifiers.push_back(TableIdentifier(schema_identifier, "t1"));
113
set_of_identifiers.push_back(TableIdentifier(schema_identifier, "too_many_enum_values"));
114
set_of_identifiers.push_back(TableIdentifier(schema_identifier, "invalid_table_collation"));
120
set_of_identifiers.push_back(TableIdentifier(schema_identifier, "t1"));
118
bool TableProtoTesterEngine::doDoesTableExist(Session&, const drizzled::TableIdentifier &identifier)
123
bool TableProtoTesterEngine::doDoesTableExist(Session&, TableIdentifier &identifier)
120
if (not identifier.getPath().compare("test/t1"))
122
if (not identifier.getPath().compare("test/too_many_enum_values"))
124
if (not identifier.getPath().compare("test/invalid_table_collation"))
125
if (strcmp(identifier.getPath().c_str(), "./test/t1") == 0)
130
131
TableProtoTesterCursor::TableProtoTesterCursor(drizzled::plugin::StorageEngine &engine_arg,
132
TableShare &table_arg) :
132
133
Cursor(engine_arg, table_arg)
145
146
int TableProtoTesterEngine::doCreateTable(Session&,
147
const drizzled::TableIdentifier&,
148
drizzled::TableIdentifier&,
148
149
drizzled::message::Table&)
154
int TableProtoTesterEngine::doDropTable(Session&, const drizzled::TableIdentifier&)
155
int TableProtoTesterEngine::doDropTable(Session&, drizzled::TableIdentifier&)
178
static void fill_table_too_many_enum_values(message::Table &table)
180
message::Table::Field *field;
181
message::Table::TableOptions *tableopts;
183
table.set_schema("test");
184
table.set_name("too_many_enum_values");
185
table.set_type(message::Table::STANDARD);
186
table.mutable_engine()->set_name("tableprototester");
187
table.set_creation_timestamp(0);
188
table.set_update_timestamp(0);
190
tableopts= table.mutable_options();
191
tableopts->set_comment("Table with too many enum options");
192
tableopts->set_collation("utf8_general_ci");
193
tableopts->set_collation_id(45);
196
field= table.add_field();
197
field->set_name("many_values");
198
field->set_type(message::Table::Field::ENUM);
200
message::Table::Field::EnumerationValues *field_options= field->mutable_enumeration_values();
201
for(int i=0; i<70000; i++)
203
char enum_value[100];
204
snprintf(enum_value, sizeof(enum_value), "a%d", i);
205
field_options->add_field_value(enum_value);
211
static void fill_table_invalid_table_collation(message::Table &table)
213
message::Table::Field *field;
214
message::Table::TableOptions *tableopts;
216
table.set_name("invalid_table_collation");
217
table.set_type(message::Table::STANDARD);
218
table.set_schema("test");
219
table.set_creation_timestamp(0);
220
table.set_update_timestamp(0);
221
table.mutable_engine()->set_name("tableprototester");
223
tableopts= table.mutable_options();
224
tableopts->set_comment("Invalid table collation ");
227
field= table.add_field();
228
field->set_name("number");
229
field->set_type(message::Table::Field::INTEGER);
232
tableopts->set_collation("pi_pi_pi");
233
tableopts->set_collation_id(123456);
237
178
int TableProtoTesterEngine::doGetTableDefinition(Session&,
238
const drizzled::TableIdentifier &identifier,
179
drizzled::TableIdentifier &identifier,
239
180
drizzled::message::Table &table_proto)
241
if (not identifier.getPath().compare("test/t1"))
182
if (strcmp(identifier.getPath().c_str(), "./test/t1") == 0)
243
184
fill_table1(table_proto);
246
else if (not identifier.getPath().compare("test/too_many_enum_values"))
248
fill_table_too_many_enum_values(table_proto);
251
else if (not identifier.getPath().compare("test/invalid_table_collation"))
253
fill_table_invalid_table_collation(table_proto);