~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/tableprototester/tableprototester.cc

  • Committer: Brian Aker
  • Date: 2010-10-20 20:26:18 UTC
  • mfrom: (1859.2.13 refactor)
  • Revision ID: brian@tangent.org-20101020202618-9222n39lm329urv5
Merge for Brian 

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
*/
18
18
 
19
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
 
81
80
  /* The following defines can be increased if necessary */
92
91
            HA_KEYREAD_ONLY);
93
92
  }
94
93
 
95
 
  bool doDoesTableExist(Session &session, const drizzled::identifier::Table &identifier);
 
94
  bool doDoesTableExist(Session &session, const drizzled::TableIdentifier &identifier);
96
95
 
97
 
  int doRenameTable(Session&, const drizzled::identifier::Table&, const drizzled::identifier::Table&)
 
96
  int doRenameTable(Session&, const drizzled::TableIdentifier&, const drizzled::TableIdentifier&)
98
97
  {
99
 
    return HA_ERR_NO_SUCH_TABLE;
 
98
    return EPERM;
100
99
  }
101
100
 
102
101
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
103
 
                             const drizzled::identifier::Schema &schema_identifier,
104
 
                             drizzled::identifier::Table::vector &set_of_identifiers);
 
102
                             const drizzled::SchemaIdentifier &schema_identifier,
 
103
                             drizzled::TableIdentifiers &set_of_identifiers);
105
104
};
106
105
 
107
106
void TableProtoTesterEngine::doGetTableIdentifiers(drizzled::CachedDirectory&,
108
 
                                                   const drizzled::identifier::Schema &schema_identifier,
109
 
                                                   drizzled::identifier::Table::vector &set_of_identifiers)
 
107
                                                   const drizzled::SchemaIdentifier &schema_identifier,
 
108
                                                   drizzled::TableIdentifiers &set_of_identifiers)
110
109
{
111
110
  if (schema_identifier.compare("test"))
112
111
  {
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"));
 
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"));
116
115
  }
117
116
}
118
117
 
119
 
bool TableProtoTesterEngine::doDoesTableExist(Session&, const drizzled::identifier::Table &identifier)
 
118
bool TableProtoTesterEngine::doDoesTableExist(Session&, const drizzled::TableIdentifier &identifier)
120
119
{
121
120
  if (not identifier.getPath().compare("test/t1"))
122
121
    return true;
129
128
}
130
129
 
131
130
TableProtoTesterCursor::TableProtoTesterCursor(drizzled::plugin::StorageEngine &engine_arg,
132
 
                                               Table &table_arg) :
 
131
                           TableShare &table_arg) :
133
132
  Cursor(engine_arg, table_arg)
134
133
{ }
135
134
 
145
144
 
146
145
int TableProtoTesterEngine::doCreateTable(Session&,
147
146
                                          Table&,
148
 
                                          const drizzled::identifier::Table&,
 
147
                                          const drizzled::TableIdentifier&,
149
148
                                          drizzled::message::Table&)
150
149
{
151
150
  return EEXIST;
152
151
}
153
152
 
154
153
 
155
 
int TableProtoTesterEngine::doDropTable(Session&, const drizzled::identifier::Table&)
 
154
int TableProtoTesterEngine::doDropTable(Session&, const drizzled::TableIdentifier&)
156
155
{
157
 
  return HA_ERR_NO_SUCH_TABLE;
 
156
  return EPERM;
158
157
}
159
158
 
160
159
static void fill_table1(message::Table &table)
236
235
}
237
236
 
238
237
int TableProtoTesterEngine::doGetTableDefinition(Session&,
239
 
                                                 const drizzled::identifier::Table &identifier,
 
238
                                                 const drizzled::TableIdentifier &identifier,
240
239
                                                 drizzled::message::Table &table_proto)
241
240
{
242
241
  if (not identifier.getPath().compare("test/t1"))
264
263
 
265
264
int TableProtoTesterCursor::doInsertRecord(unsigned char *)
266
265
{
267
 
  return(getTable()->next_number_field ? update_auto_increment() : 0);
 
266
  return(table->next_number_field ? update_auto_increment() : 0);
268
267
}
269
268
 
270
269
int TableProtoTesterCursor::doStartTableScan(bool)
365
364
  "Used to test rest of server with various table proto messages",
366
365
  PLUGIN_LICENSE_GPL,
367
366
  tableprototester_init,     /* Plugin Init */
368
 
  NULL,               /* depends */
 
367
  NULL,               /* system variables */
369
368
  NULL                /* config options   */
370
369
}
371
370
DRIZZLE_DECLARE_PLUGIN_END;