~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/tableprototester/tableprototester.cc

  • Committer: Brian Aker
  • Date: 2010-08-12 17:19:46 UTC
  • mfrom: (1701.1.1 turn-off-csv)
  • Revision ID: brian@tangent.org-20100812171946-n44naaqhg27gehlh
MErge Monty, remove CSV from auto-build

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
17
*/
18
18
 
19
 
#include <config.h>
 
19
#include "config.h"
 
20
#include <drizzled/table.h>
 
21
#include <drizzled/error.h>
 
22
#include "drizzled/internal/my_pthread.h"
20
23
 
21
24
#include "tableprototester.h"
22
25
 
25
28
#include <string>
26
29
#include <map>
27
30
#include <fstream>
 
31
#include <drizzled/message/table.pb.h>
 
32
#include "drizzled/internal/m_string.h"
28
33
 
29
 
#include <drizzled/error.h>
30
 
#include <drizzled/global_charset_info.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>
 
34
#include "drizzled/global_charset_info.h"
36
35
 
37
36
 
38
37
using namespace std;
58
57
    table_definition_ext= TABLEPROTOTESTER_EXT;
59
58
  }
60
59
 
61
 
  virtual Cursor *create(Table &table)
 
60
  virtual Cursor *create(TableShare &table)
62
61
  {
63
62
    return new TableProtoTesterCursor(*this, table);
64
63
  }
69
68
 
70
69
  int doCreateTable(Session&,
71
70
                    Table&,
72
 
                    const drizzled::identifier::Table &identifier,
 
71
                    const drizzled::TableIdentifier &identifier,
73
72
                    drizzled::message::Table&);
74
73
 
75
 
  int doDropTable(Session&, const drizzled::identifier::Table &identifier);
 
74
  int doDropTable(Session&, const drizzled::TableIdentifier &identifier);
76
75
 
77
76
  int doGetTableDefinition(Session &session,
78
 
                           const drizzled::identifier::Table &identifier,
 
77
                           const drizzled::TableIdentifier &identifier,
79
78
                           drizzled::message::Table &table_proto);
80
79
 
 
80
  void doGetTableNames(drizzled::CachedDirectory &directory,
 
81
                       const SchemaIdentifier &,
 
82
                       set<string>& set_of_names)
 
83
  {
 
84
    (void)directory;
 
85
    set_of_names.insert("t1");
 
86
 
 
87
  }
 
88
 
81
89
  /* The following defines can be increased if necessary */
82
90
  uint32_t max_supported_keys()          const { return 64; }
83
91
  uint32_t max_supported_key_length()    const { return 1000; }
92
100
            HA_KEYREAD_ONLY);
93
101
  }
94
102
 
95
 
  bool doDoesTableExist(Session &session, const drizzled::identifier::Table &identifier);
 
103
  bool doDoesTableExist(Session &session, const drizzled::TableIdentifier &identifier);
96
104
 
97
 
  int doRenameTable(Session&, const drizzled::identifier::Table&, const drizzled::identifier::Table&)
 
105
  int doRenameTable(Session&, const drizzled::TableIdentifier&, const drizzled::TableIdentifier&)
98
106
  {
99
 
    return HA_ERR_NO_SUCH_TABLE;
 
107
    return EPERM;
100
108
  }
101
109
 
102
110
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
103
 
                             const drizzled::identifier::Schema &schema_identifier,
104
 
                             drizzled::identifier::Table::vector &set_of_identifiers);
 
111
                             const drizzled::SchemaIdentifier &schema_identifier,
 
112
                             drizzled::TableIdentifiers &set_of_identifiers);
105
113
};
106
114
 
107
115
void TableProtoTesterEngine::doGetTableIdentifiers(drizzled::CachedDirectory&,
108
 
                                                   const drizzled::identifier::Schema &schema_identifier,
109
 
                                                   drizzled::identifier::Table::vector &set_of_identifiers)
 
116
                                                   const drizzled::SchemaIdentifier &schema_identifier,
 
117
                                                   drizzled::TableIdentifiers &set_of_identifiers)
110
118
{
111
119
  if (schema_identifier.compare("test"))
112
120
  {
113
 
    set_of_identifiers.push_back(identifier::Table(schema_identifier, "t1"));
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
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, "t1"));
 
122
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, "too_many_enum_values"));
 
123
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, "invalid_table_collation"));
116
124
  }
117
125
}
118
126
 
119
 
bool TableProtoTesterEngine::doDoesTableExist(Session&, const drizzled::identifier::Table &identifier)
 
127
bool TableProtoTesterEngine::doDoesTableExist(Session&, const drizzled::TableIdentifier &identifier)
120
128
{
121
 
  if (not identifier.getPath().compare("test/t1"))
122
 
    return true;
123
 
  if (not identifier.getPath().compare("test/too_many_enum_values"))
124
 
    return true;
125
 
  if (not identifier.getPath().compare("test/invalid_table_collation"))
 
129
  if (not identifier.getPath().compare("./test/t1"))
 
130
    return true;
 
131
  if (not identifier.getPath().compare("./test/too_many_enum_values"))
 
132
    return true;
 
133
  if (not identifier.getPath().compare("./test/invalid_table_collation"))
126
134
    return true;
127
135
 
128
136
  return false;
129
137
}
130
138
 
131
139
TableProtoTesterCursor::TableProtoTesterCursor(drizzled::plugin::StorageEngine &engine_arg,
132
 
                                               Table &table_arg) :
 
140
                           TableShare &table_arg) :
133
141
  Cursor(engine_arg, table_arg)
134
142
{ }
135
143
 
145
153
 
146
154
int TableProtoTesterEngine::doCreateTable(Session&,
147
155
                                          Table&,
148
 
                                          const drizzled::identifier::Table&,
 
156
                                          const drizzled::TableIdentifier&,
149
157
                                          drizzled::message::Table&)
150
158
{
151
159
  return EEXIST;
152
160
}
153
161
 
154
162
 
155
 
int TableProtoTesterEngine::doDropTable(Session&, const drizzled::identifier::Table&)
 
163
int TableProtoTesterEngine::doDropTable(Session&, const drizzled::TableIdentifier&)
156
164
{
157
 
  return HA_ERR_NO_SUCH_TABLE;
 
165
  return EPERM;
158
166
}
159
167
 
160
168
static void fill_table1(message::Table &table)
236
244
}
237
245
 
238
246
int TableProtoTesterEngine::doGetTableDefinition(Session&,
239
 
                                                 const drizzled::identifier::Table &identifier,
 
247
                                                 const drizzled::TableIdentifier &identifier,
240
248
                                                 drizzled::message::Table &table_proto)
241
249
{
242
 
  if (not identifier.getPath().compare("test/t1"))
 
250
  if (not identifier.getPath().compare("./test/t1"))
243
251
  {
244
252
    fill_table1(table_proto);
245
253
    return EEXIST;
246
254
  }
247
 
  else if (not identifier.getPath().compare("test/too_many_enum_values"))
 
255
  else if (not identifier.getPath().compare("./test/too_many_enum_values"))
248
256
  {
249
257
    fill_table_too_many_enum_values(table_proto);
250
258
    return EEXIST;
251
259
  }
252
 
  else if (not identifier.getPath().compare("test/invalid_table_collation"))
 
260
  else if (not identifier.getPath().compare("./test/invalid_table_collation"))
253
261
  {
254
262
    fill_table_invalid_table_collation(table_proto);
255
263
    return EEXIST;
264
272
 
265
273
int TableProtoTesterCursor::doInsertRecord(unsigned char *)
266
274
{
267
 
  return(getTable()->next_number_field ? update_auto_increment() : 0);
 
275
  return(table->next_number_field ? update_auto_increment() : 0);
268
276
}
269
277
 
270
278
int TableProtoTesterCursor::doStartTableScan(bool)
365
373
  "Used to test rest of server with various table proto messages",
366
374
  PLUGIN_LICENSE_GPL,
367
375
  tableprototester_init,     /* Plugin Init */
368
 
  NULL,               /* depends */
 
376
  NULL,               /* system variables */
369
377
  NULL                /* config options   */
370
378
}
371
379
DRIZZLE_DECLARE_PLUGIN_END;