~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/tableprototester/tableprototester.cc

  • Committer: Paweł Blokus
  • Date: 2010-06-09 20:36:51 UTC
  • mto: This revision was merged to the branch mainline in revision 1620.
  • Revision ID: pawel@pawel-desktop-20100609203651-mbq5x34bt9m3kv0o
minor style fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    table_definition_ext= TABLEPROTOTESTER_EXT;
58
58
  }
59
59
 
60
 
  virtual Cursor *create(Table &table)
 
60
  virtual Cursor *create(TableShare &table,
 
61
                         drizzled::memory::Root *mem_root)
61
62
  {
62
 
    return new TableProtoTesterCursor(*this, table);
 
63
    return new (mem_root) TableProtoTesterCursor(*this, table);
63
64
  }
64
65
 
65
66
  const char **bas_ext() const {
68
69
 
69
70
  int doCreateTable(Session&,
70
71
                    Table&,
71
 
                    const drizzled::TableIdentifier &identifier,
 
72
                    drizzled::TableIdentifier &identifier,
72
73
                    drizzled::message::Table&);
73
74
 
74
 
  int doDropTable(Session&, const drizzled::TableIdentifier &identifier);
 
75
  int doDropTable(Session&, drizzled::TableIdentifier &identifier);
75
76
 
76
77
  int doGetTableDefinition(Session &session,
77
 
                           const drizzled::TableIdentifier &identifier,
 
78
                           drizzled::TableIdentifier &identifier,
78
79
                           drizzled::message::Table &table_proto);
79
80
 
 
81
  void doGetTableNames(drizzled::CachedDirectory &directory,
 
82
                       SchemaIdentifier &,
 
83
                       set<string>& set_of_names)
 
84
  {
 
85
    (void)directory;
 
86
    set_of_names.insert("t1");
 
87
 
 
88
  }
 
89
 
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; }
91
101
            HA_KEYREAD_ONLY);
92
102
  }
93
103
 
94
 
  bool doDoesTableExist(Session &session, const drizzled::TableIdentifier &identifier);
 
104
  bool doDoesTableExist(Session &session, TableIdentifier &identifier);
95
105
 
96
 
  int doRenameTable(Session&, const drizzled::TableIdentifier&, const drizzled::TableIdentifier&)
 
106
  int doRenameTable(Session&, TableIdentifier&, TableIdentifier&)
97
107
  {
98
108
    return EPERM;
99
109
  }
100
110
 
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);
104
114
};
105
115
 
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)
109
119
{
110
120
  if (schema_identifier.compare("test"))
111
121
  {
112
122
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, "t1"));
113
123
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, "too_many_enum_values"));
114
 
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, "invalid_table_collation"));
115
124
  }
116
125
}
117
126
 
118
 
bool TableProtoTesterEngine::doDoesTableExist(Session&, const drizzled::TableIdentifier &identifier)
 
127
bool TableProtoTesterEngine::doDoesTableExist(Session&, TableIdentifier &identifier)
119
128
{
120
 
  if (not identifier.getPath().compare("test/t1"))
121
 
    return true;
122
 
  if (not identifier.getPath().compare("test/too_many_enum_values"))
123
 
    return true;
124
 
  if (not identifier.getPath().compare("test/invalid_table_collation"))
 
129
  if (strcmp(identifier.getPath().c_str(), "./test/t1") == 0)
 
130
    return true;
 
131
  if (strcmp(identifier.getPath().c_str(), "./test/too_many_enum_values") == 0)
125
132
    return true;
126
133
 
127
134
  return false;
128
135
}
129
136
 
130
137
TableProtoTesterCursor::TableProtoTesterCursor(drizzled::plugin::StorageEngine &engine_arg,
131
 
                                               Table &table_arg) :
 
138
                           TableShare &table_arg) :
132
139
  Cursor(engine_arg, table_arg)
133
140
{ }
134
141
 
144
151
 
145
152
int TableProtoTesterEngine::doCreateTable(Session&,
146
153
                                          Table&,
147
 
                                          const drizzled::TableIdentifier&,
 
154
                                          drizzled::TableIdentifier&,
148
155
                                          drizzled::message::Table&)
149
156
{
150
157
  return EEXIST;
151
158
}
152
159
 
153
160
 
154
 
int TableProtoTesterEngine::doDropTable(Session&, const drizzled::TableIdentifier&)
 
161
int TableProtoTesterEngine::doDropTable(Session&, drizzled::TableIdentifier&)
155
162
{
156
163
  return EPERM;
157
164
}
186
193
  table.mutable_engine()->set_name("tableprototester");
187
194
  table.set_creation_timestamp(0);
188
195
  table.set_update_timestamp(0);
 
196
  
189
197
 
190
198
  tableopts= table.mutable_options();
191
199
  tableopts->set_comment("Table with too many enum options");
192
 
  tableopts->set_collation("utf8_general_ci");
193
 
  tableopts->set_collation_id(45);
194
200
 
195
201
  {
196
202
    field= table.add_field();
208
214
 
209
215
}
210
216
 
211
 
static void fill_table_invalid_table_collation(message::Table &table)
212
 
{
213
 
  message::Table::Field *field;
214
 
  message::Table::TableOptions *tableopts;
215
 
 
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");
222
 
 
223
 
  tableopts= table.mutable_options();
224
 
  tableopts->set_comment("Invalid table collation ");
225
 
 
226
 
  {
227
 
    field= table.add_field();
228
 
    field->set_name("number");
229
 
    field->set_type(message::Table::Field::INTEGER);
230
 
  }
231
 
 
232
 
  tableopts->set_collation("pi_pi_pi");
233
 
  tableopts->set_collation_id(123456);
234
 
 
235
 
}
236
217
 
237
218
int TableProtoTesterEngine::doGetTableDefinition(Session&,
238
 
                                                 const drizzled::TableIdentifier &identifier,
 
219
                                                 drizzled::TableIdentifier &identifier,
239
220
                                                 drizzled::message::Table &table_proto)
240
221
{
241
 
  if (not identifier.getPath().compare("test/t1"))
 
222
  if (strcmp(identifier.getPath().c_str(), "./test/t1") == 0)
242
223
  {
243
224
    fill_table1(table_proto);
244
225
    return EEXIST;
245
226
  }
246
 
  else if (not identifier.getPath().compare("test/too_many_enum_values"))
 
227
  else if (strcmp(identifier.getPath().c_str(), "./test/too_many_enum_values")==0)
247
228
  {
248
229
    fill_table_too_many_enum_values(table_proto);
249
230
    return EEXIST;
250
231
  }
251
 
  else if (not identifier.getPath().compare("test/invalid_table_collation"))
252
 
  {
253
 
    fill_table_invalid_table_collation(table_proto);
254
 
    return EEXIST;
255
 
  }
256
232
  return ENOENT;
257
233
}
258
234
 
263
239
 
264
240
int TableProtoTesterCursor::doInsertRecord(unsigned char *)
265
241
{
266
 
  return(getTable()->next_number_field ? update_auto_increment() : 0);
 
242
  return(table->next_number_field ? update_auto_increment() : 0);
267
243
}
268
244
 
269
245
int TableProtoTesterCursor::doStartTableScan(bool)