Drizzled Public API Documentation

schema.h
00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Brian Aker
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #pragma once
00022 
00023 #include <assert.h>
00024 #include <drizzled/plugin/storage_engine.h>
00025 #include <boost/unordered_map.hpp>
00026 #include <boost/thread/shared_mutex.hpp>
00027 
00028 extern const drizzled::CHARSET_INFO *default_charset_info;
00029 
00030 static const char *schema_exts[] = {
00031   NULL
00032 };
00033 
00034 class Schema : public drizzled::plugin::StorageEngine
00035 {
00036   bool writeSchemaFile(const drizzled::identifier::Schema &schema_identifier, const drizzled::message::Schema &db);
00037   bool readSchemaFile(const drizzled::identifier::Schema &schema_identifier, drizzled::message::Schema &schema);
00038   bool readSchemaFile(std::string filename, drizzled::message::Schema &schema);
00039 
00040   void prime();
00041   void startup(drizzled::Session &session);
00042 
00043   typedef boost::unordered_map<std::string, drizzled::message::schema::shared_ptr> SchemaCache;
00044   SchemaCache schema_cache;
00045   bool schema_cache_filled;
00046 
00047   boost::shared_mutex mutex;
00048 
00049 public:
00050   Schema();
00051 
00052   ~Schema();
00053 
00054 
00055   drizzled::Cursor *create(drizzled::Table &)
00056   {
00057     return NULL;
00058   }
00059 
00060   void doGetSchemaIdentifiers(drizzled::identifier::Schema::vector &set_of_names);
00061   drizzled::message::schema::shared_ptr doGetSchemaDefinition(const drizzled::identifier::Schema&);
00062 
00063   bool doCreateSchema(const drizzled::message::Schema &schema_message);
00064 
00065   bool doAlterSchema(const drizzled::message::Schema &schema_message);
00066 
00067   bool doDropSchema(const drizzled::identifier::Schema&);
00068 
00069   // Below are table methods that we don't implement (and don't need)
00070 
00071   int doGetTableDefinition(drizzled::Session&,
00072                            const drizzled::identifier::Table&,
00073                            drizzled::message::Table&)
00074   {
00075     return ENOENT;
00076   }
00077 
00078   bool doDoesTableExist(drizzled::Session&, const drizzled::identifier::Table&)
00079   {
00080     return false;
00081   }
00082 
00083   int doRenameTable(drizzled::Session&, const drizzled::identifier::Table&, const drizzled::identifier::Table&)
00084   {
00085     return drizzled::HA_ERR_NO_SUCH_TABLE;
00086   }
00087 
00088   int doCreateTable(drizzled::Session&,
00089                     drizzled::Table&,
00090                     const drizzled::identifier::Table&,
00091                     const drizzled::message::Table&)
00092   {
00093     return drizzled::ER_TABLE_PERMISSION_DENIED;
00094   }
00095 
00096   int doDropTable(drizzled::Session&, const drizzled::identifier::Table&)
00097   {
00098     return drizzled::HA_ERR_NO_SUCH_TABLE;
00099   }
00100 
00101   const char **bas_ext() const 
00102   {
00103     return schema_exts;
00104   }
00105 
00106   void get_auto_increment(uint64_t, uint64_t,
00107                           uint64_t,
00108                           uint64_t *,
00109                           uint64_t *)
00110   {}
00111 
00112   void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
00113                              const drizzled::identifier::Schema &schema_identifier,
00114                              drizzled::identifier::Table::vector &set_of_identifiers);
00115 };
00116