Drizzled Public API Documentation

engine_ms.h

00001 /* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
00002  *
00003  * PrimeBase Media Stream for MySQL
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  *
00019  * Original author: Paul McCullagh
00020  * Continued development: Barry Leslie
00021  *
00022  * 2007-07-20
00023  *
00024  * H&G2JCtL
00025  *
00026  * Engine interface
00027  *
00028  */
00029 
00030 #pragma once
00031 #ifndef __ENGINE_MS_H__
00032 #define __ENGINE_MS_H__
00033 
00034 #include "defs_ms.h"
00035 #include "pbms.h"
00036 
00037 class MSOpenTable;
00038 
00039 #ifdef DRIZZLED
00040 namespace drizzled
00041 {
00042 class Session;
00043 } /* namespace drizzled */
00044 #else
00045 class THD;
00046 #endif
00047 
00048 class MSEngine : public CSObject {
00049 public:
00050   
00051 #ifdef DRIZZLED
00052   static int startUp(PBMSResultPtr ) { return 0;}
00053   static void shutDown() {}
00054 #else
00055   static int startUp(PBMSResultPtr result);
00056 
00057   static void shutDown();
00058 
00059   static const PBMSEnginePtr getEngineInfoAt(int indx);
00060 #endif
00061   
00062   static int exceptionToResult(CSException *e, PBMSResultPtr result);
00063   static int errorResult(const char *func, const char *file, int line, int err, const char *message, PBMSResultPtr result);
00064   static int osErrorResult(const char *func, const char *file, int line, int err, PBMSResultPtr result);
00065   static int enterConnectionNoThd(CSThread **r_self, PBMSResultPtr result);
00066   static int enterConnection(THD *thd, CSThread **r_self, PBMSResultPtr result, bool doCreate);
00067   static void exitConnection();
00068   static void closeConnection(THD* thd);
00069 
00070   static int32_t  dropDatabase(const char *db_name, PBMSResultPtr result);
00071   static int32_t  createBlob(const char *db_name, const char *tab_name, char *blob, size_t blob_len, PBMSBlobURLPtr blob_url, PBMSResultPtr result);
00072   static int32_t  referenceBlob(const char *db_name, const char *tab_name, PBMSBlobURLPtr  ret_blob_url, char *blob_url, uint16_t col_index, PBMSResultPtr result);
00073   static int32_t  dereferenceBlob(const char *db_name, const char *tab_name, char *blob_url, PBMSResultPtr result);
00074   static int32_t  dropTable(const char *db_name, const char *tab_name, PBMSResultPtr result);
00075   static int32_t  renameTable(const char *from_db_name, const char *from_table, const char *to_db_name, const char *to_table, PBMSResultPtr result);
00076   static void   callCompleted(bool ok);
00077   
00078   static bool couldBeURL(const char *url, size_t length);
00079   
00080   private:
00081   static bool try_createBlob(CSThread *self, const char *db_name, const char *tab_name, char *blob, size_t blob_len, PBMSBlobURLPtr blob_url);
00082   static bool try_referenceBlob(CSThread *self, const char *db_name, const char *tab_name, PBMSBlobURLPtr ret_blob_url, char *blob_url, uint16_t col_index);
00083   static bool try_dereferenceBlob(CSThread *self, const char *db_name, const char *tab_name, char *blob_url);
00084   static bool try_dropDatabase(CSThread *self, const char *db_name);
00085   static bool try_dropTable(CSThread *self, const char *db_name, const char *tab_name);
00086   static bool try_renameTable(CSThread *self, const char *from_db_name, const char *from_table, const char *to_db_name, const char *to_table);
00087   
00088   static MSOpenTable *openTable(const char *db_name, const char *tab_name, bool create);
00089   static bool renameTable(const char *db_name, const char *from_table, const char *to_db_name, const char *to_table);
00090   static void completeRenameTable(struct UnDoInfo *info, bool ok);
00091 };
00092 
00093 #endif