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_st *default_charset_info;
00029 
00030 class Schema : public drizzled::plugin::StorageEngine
00031 {
00032   bool writeSchemaFile(const drizzled::identifier::Schema &schema_identifier, const drizzled::message::Schema &db);
00033   bool readSchemaFile(const drizzled::identifier::Schema &schema_identifier, drizzled::message::Schema &schema);
00034   bool readSchemaFile(std::string filename, drizzled::message::Schema &schema);
00035 
00036   void prime();
00037 
00038   typedef boost::unordered_map<std::string, drizzled::message::schema::shared_ptr> SchemaCache;
00039   SchemaCache schema_cache;
00040   bool schema_cache_filled;
00041 
00042   boost::shared_mutex mutex;
00043 
00044 public:
00045   Schema();
00046 
00047   drizzled::Cursor* create(drizzled::Table&)
00048   {
00049     return NULL;
00050   }
00051 
00052   void doGetSchemaIdentifiers(drizzled::identifier::schema::vector&);
00053   drizzled::message::schema::shared_ptr doGetSchemaDefinition(const drizzled::identifier::Schema&);
00054 
00055   bool doCreateSchema(const drizzled::message::Schema&);
00056 
00057   bool doAlterSchema(const drizzled::message::Schema&);
00058 
00059   bool doDropSchema(const drizzled::identifier::Schema&);
00060 
00061   // Below are table methods that we don't implement (and don't need)
00062 
00063   int doGetTableDefinition(drizzled::Session&,
00064                            const drizzled::identifier::Table&,
00065                            drizzled::message::Table&)
00066   {
00067     return ENOENT;
00068   }
00069 
00070   bool doDoesTableExist(drizzled::Session&, const drizzled::identifier::Table&)
00071   {
00072     return false;
00073   }
00074 
00075   int doRenameTable(drizzled::Session&, const drizzled::identifier::Table&, const drizzled::identifier::Table&)
00076   {
00077     return drizzled::HA_ERR_NO_SUCH_TABLE;
00078   }
00079 
00080   int doCreateTable(drizzled::Session&,
00081                     drizzled::Table&,
00082                     const drizzled::identifier::Table&,
00083                     const drizzled::message::Table&)
00084   {
00085     return drizzled::ER_TABLE_PERMISSION_DENIED;
00086   }
00087 
00088   int doDropTable(drizzled::Session&, const drizzled::identifier::Table&)
00089   {
00090     return drizzled::HA_ERR_NO_SUCH_TABLE;
00091   }
00092 
00093   const char** bas_ext() const;
00094 
00095   void get_auto_increment(uint64_t, uint64_t,
00096                           uint64_t,
00097                           uint64_t *,
00098                           uint64_t *)
00099   {}
00100 
00101   void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
00102                              const drizzled::identifier::Schema &schema_identifier,
00103                              drizzled::identifier::table::vector &set_of_identifiers);
00104 };
00105