~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/schema_engine/schema.h

  • Committer: Monty Taylor
  • Date: 2010-03-11 18:27:20 UTC
  • mfrom: (1333 staging)
  • mto: This revision was merged to the branch mainline in revision 1348.
  • Revision ID: mordred@inaugust.com-20100311182720-hd1h87y6cb1b1mp0
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2010 Brian Aker
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#ifndef PLUGIN_SCHEMA_ENGINE_SCHEMA_H
 
22
#define PLUGIN_SCHEMA_ENGINE_SCHEMA_H
 
23
 
 
24
#include <assert.h>
 
25
#include <drizzled/plugin/storage_engine.h>
 
26
#include <drizzled/data_home.h>
 
27
#include <drizzled/hash.h>
 
28
 
 
29
#include <pthread.h>
 
30
 
 
31
extern const drizzled::CHARSET_INFO *default_charset_info;
 
32
 
 
33
static const char *schema_exts[] = {
 
34
  NULL
 
35
};
 
36
 
 
37
class Schema : public drizzled::plugin::StorageEngine
 
38
{
 
39
  bool writeSchemaFile(const char *path, const drizzled::message::Schema &db);
 
40
  bool readTableFile(const std::string &path, drizzled::message::Table &table_message);
 
41
  bool readSchemaFile(const std::string &path, drizzled::message::Schema &schema);
 
42
 
 
43
  void prime();
 
44
 
 
45
  typedef drizzled::hash_map<std::string, drizzled::message::Schema> SchemaCache;
 
46
  SchemaCache schema_cache;
 
47
  bool schema_cache_filled;
 
48
 
 
49
  pthread_rwlock_t schema_lock;
 
50
 
 
51
public:
 
52
  Schema();
 
53
 
 
54
  ~Schema();
 
55
 
 
56
  int doCreateTable(drizzled::Session *,
 
57
                    const char *,
 
58
                    drizzled::Table&,
 
59
                    drizzled::message::Table&)
 
60
  {
 
61
    return EPERM;
 
62
  }
 
63
 
 
64
  int doDropTable(drizzled::Session&, const std::string &table_path);
 
65
 
 
66
  bool doCanCreateTable(const drizzled::TableIdentifier &identifier);
 
67
 
 
68
  drizzled::Cursor *create(drizzled::TableShare &,
 
69
                           drizzled::memory::Root *)
 
70
  {
 
71
    return NULL;
 
72
  }
 
73
 
 
74
  void doGetSchemaNames(std::set<std::string>& set_of_names);
 
75
  bool doGetSchemaDefinition(const std::string &schema_name, drizzled::message::Schema &proto);
 
76
 
 
77
  bool doCreateSchema(const drizzled::message::Schema &schema_message);
 
78
 
 
79
  bool doAlterSchema(const drizzled::message::Schema &schema_message);
 
80
 
 
81
  bool doDropSchema(const std::string &schema_name);
 
82
 
 
83
  int doGetTableDefinition(drizzled::Session& session,
 
84
                           const char *path,
 
85
                           const char *db,
 
86
                           const char *table_name,
 
87
                           const bool is_tmp,
 
88
                           drizzled::message::Table *table_proto);
 
89
 
 
90
  void doGetTableNames(drizzled::CachedDirectory &directory,
 
91
                       std::string &db_name,
 
92
                       std::set<std::string> &set_of_names);
 
93
 
 
94
  const char **bas_ext() const 
 
95
  {
 
96
    return schema_exts;
 
97
  }
 
98
};
 
99
 
 
100
#endif /* PLUGIN_SCHEMA_ENGINE_SCHEMA_H */