~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/schema_engine/schema.h

  • Committer: Andrew Hutchings
  • Date: 2010-09-06 20:47:28 UTC
  • mto: (1747.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 1748.
  • Revision ID: andrew@linuxjedi.co.uk-20100906204728-8qjwkx638e5lsm1q
Timestamp cannot reliably store leap seconds, so don't try.  Leave that to datetime only

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <assert.h>
25
25
#include <drizzled/plugin/storage_engine.h>
 
26
#include <drizzled/data_home.h>
26
27
#include <boost/unordered_map.hpp>
27
 
#include <boost/thread/shared_mutex.hpp>
 
28
 
 
29
#include <pthread.h>
28
30
 
29
31
extern const drizzled::CHARSET_INFO *default_charset_info;
30
32
 
34
36
 
35
37
class Schema : public drizzled::plugin::StorageEngine
36
38
{
37
 
  bool writeSchemaFile(const drizzled::identifier::Schema &schema_identifier, const drizzled::message::Schema &db);
38
 
  bool readSchemaFile(const drizzled::identifier::Schema &schema_identifier, drizzled::message::Schema &schema);
39
 
  bool readSchemaFile(std::string filename, drizzled::message::Schema &schema);
 
39
  bool writeSchemaFile(const drizzled::SchemaIdentifier &schema_identifier, const drizzled::message::Schema &db);
 
40
  bool readSchemaFile(const std::string &schema_file_name, drizzled::message::Schema &schema);
40
41
 
41
42
  void prime();
42
 
  void startup(drizzled::Session &session);
43
43
 
44
 
  typedef boost::unordered_map<std::string, drizzled::message::schema::shared_ptr> SchemaCache;
 
44
  typedef boost::unordered_map<std::string, drizzled::message::Schema> SchemaCache;
45
45
  SchemaCache schema_cache;
46
46
  bool schema_cache_filled;
47
47
 
48
 
  boost::shared_mutex mutex;
 
48
  pthread_rwlock_t schema_lock;
49
49
 
50
50
public:
51
51
  Schema();
53
53
  ~Schema();
54
54
 
55
55
 
56
 
  drizzled::Cursor *create(drizzled::Table &)
 
56
  bool doCanCreateTable(const drizzled::TableIdentifier &identifier);
 
57
 
 
58
  drizzled::Cursor *create(drizzled::TableShare &)
57
59
  {
58
60
    return NULL;
59
61
  }
60
62
 
61
 
  void doGetSchemaIdentifiers(drizzled::identifier::Schema::vector &set_of_names);
62
 
  drizzled::message::schema::shared_ptr doGetSchemaDefinition(const drizzled::identifier::Schema&);
 
63
  void doGetSchemaIdentifiers(drizzled::SchemaIdentifiers &set_of_names);
 
64
  bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::Schema &proto);
63
65
 
64
66
  bool doCreateSchema(const drizzled::message::Schema &schema_message);
65
67
 
66
68
  bool doAlterSchema(const drizzled::message::Schema &schema_message);
67
69
 
68
 
  bool doDropSchema(const drizzled::identifier::Schema&);
 
70
  bool doDropSchema(const drizzled::SchemaIdentifier&);
69
71
 
70
72
  // Below are table methods that we don't implement (and don't need)
71
73
 
72
74
  int doGetTableDefinition(drizzled::Session&,
73
 
                           const drizzled::identifier::Table&,
 
75
                           const drizzled::TableIdentifier&,
74
76
                           drizzled::message::Table&)
75
77
  {
76
78
    return ENOENT;
77
79
  }
78
80
 
79
 
  bool doDoesTableExist(drizzled::Session&, const drizzled::identifier::Table&)
 
81
 
 
82
  void doGetTableNames(drizzled::CachedDirectory&,
 
83
                       const drizzled::SchemaIdentifier&,
 
84
                       std::set<std::string>&)
 
85
  {
 
86
  }
 
87
 
 
88
  bool doDoesTableExist(drizzled::Session&, const drizzled::TableIdentifier&)
80
89
  {
81
90
    return false;
82
91
  }
83
92
 
84
 
  int doRenameTable(drizzled::Session&, const drizzled::identifier::Table&, const drizzled::identifier::Table&)
 
93
  int doRenameTable(drizzled::Session&, const drizzled::TableIdentifier&, const drizzled::TableIdentifier&)
85
94
  {
86
 
    return drizzled::HA_ERR_NO_SUCH_TABLE;
 
95
    return EPERM;
87
96
  }
88
97
 
89
98
  int doCreateTable(drizzled::Session&,
90
99
                    drizzled::Table&,
91
 
                    const drizzled::identifier::Table&,
 
100
                    const drizzled::TableIdentifier&,
92
101
                    drizzled::message::Table&)
93
102
  {
94
 
    return drizzled::ER_TABLE_PERMISSION_DENIED;
 
103
    return EPERM;
95
104
  }
96
105
 
97
 
  int doDropTable(drizzled::Session&, const drizzled::identifier::Table&)
 
106
  int doDropTable(drizzled::Session&, const drizzled::TableIdentifier&)
98
107
  {
99
 
    return drizzled::HA_ERR_NO_SUCH_TABLE;
 
108
    return 0;
100
109
  }
101
110
 
102
111
  const char **bas_ext() const 
109
118
                          uint64_t *,
110
119
                          uint64_t *)
111
120
  {}
112
 
 
113
121
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
114
 
                             const drizzled::identifier::Schema &schema_identifier,
115
 
                             drizzled::identifier::Table::vector &set_of_identifiers);
 
122
                             const drizzled::SchemaIdentifier &schema_identifier,
 
123
                             drizzled::TableIdentifiers &set_of_identifiers);
116
124
};
117
125
 
118
126
#endif /* PLUGIN_SCHEMA_ENGINE_SCHEMA_H */