Drizzled Public API Documentation

ha_pbms.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-05-20
00023  *
00024  * H&G2JCtL
00025  *
00026  * Table handler.
00027  *
00028  */
00029 #pragma once
00030 #ifndef __HA_PBMS_H__
00031 #define __HA_PBMS_H__
00032 
00033 #include "defs_ms.h"
00034 #include "engine_ms.h"
00035 
00036 #ifdef USE_PRAGMA_INTERFACE
00037 #pragma interface     /* gcc class implementation */
00038 #endif
00039 
00040 #if MYSQL_VERSION_ID >= 50120
00041 #define byte uchar
00042 #endif
00043 
00044 #ifdef DRIZZLED
00045 #include <drizzled/cursor.h>
00046 #include <drizzled/thr_lock.h>
00047 
00048 class PBMSStorageEngine;
00049 #define handlerton PBMSStorageEngine
00050 #define handler Cursor
00051 
00052 using namespace drizzled;
00053 
00054 #else
00055 extern handlerton   *pbms_hton;
00056 #endif
00057 
00058 class MSOpenSystemTable;
00059 
00060 class ha_pbms: public handler
00061 {
00062   THR_LOCK_DATA   ha_lock;      
00063   MSOpenSystemTable *ha_open_tab;
00064   int         ha_error;
00065   PBMSResultRec   ha_result;
00066   //MS_SHARE      *ha_share;    ///< Shared lock info
00067 
00068 public:
00069 #ifdef DRIZZLED
00070   ha_pbms(handlerton *hton, Table& table_arg);
00071 #else
00072   ha_pbms(handlerton *hton, TABLE_SHARE *table_arg);
00073 #endif
00074   ~ha_pbms() { }
00075 
00076   const char *table_type() const { return "PBMS"; }
00077 
00078   const char *index_type(uint inx) { UNUSED(inx); return "NONE"; }
00079 
00080 #ifndef DRIZZLED
00081   const char **bas_ext() const;
00082 
00083   MX_TABLE_TYPES_T table_flags() const;
00084 #endif
00085 
00086   MX_ULONG_T index_flags(uint inx, uint part , bool all_parts ) const 
00087   { 
00088     UNUSED(inx); 
00089     UNUSED(part); 
00090     UNUSED(all_parts); 
00091     return (HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | HA_KEYREAD_ONLY); 
00092   }
00093   uint  max_supported_keys()      const { return 512; }
00094   uint  max_supported_key_length()    const { return 1024; }
00095   uint  max_supported_key_part_length() const { return 1024; }
00096 
00097   int open(const char *name, int mode, uint test_if_locked);
00098   void drop_table(const char *name) {UNUSED(name);}
00099 
00100   int close(void);
00101 #ifdef DRIZZLED
00102   int   doInsertRecord(byte * buf);
00103   int   doUpdateRecord(const byte * old_data, byte * new_data);
00104   int   doDeleteRecord(const byte * buf);
00105 
00106 #else
00107   int write_row(unsigned char * buf);
00108   int update_row(const unsigned char * old_data, unsigned char * new_data);
00109   int delete_row(const unsigned char * buf);
00110 #endif
00111 
00112   /* Sequential scan functions: */
00113 #ifdef DRIZZLED
00114   int doStartTableScan(bool scan);
00115 #else
00116   int rnd_init(bool scan);
00117 #endif
00118   int rnd_next(byte *buf);
00119   int rnd_pos(byte * buf, byte *pos);
00120   void position(const byte *record);
00121   int info(uint);
00122 
00123 #ifdef PBMS_HAS_KEYS
00124   /* Index access functions: */
00125   int   index_init(uint idx, bool sorted);
00126   int   index_end();
00127   int   index_read(byte * buf, const byte * key,
00128                  uint key_len, enum ha_rkey_function find_flag);
00129   int   index_read_idx(byte * buf, uint idx, const byte * key,
00130                      uint key_len, enum ha_rkey_function find_flag);
00131   int   index_next(byte * buf);
00132   int   index_prev(byte * buf);
00133   int   index_first(byte * buf);
00134   int   index_last(byte * buf);
00135   int   index_read_last(byte * buf, const byte * key, uint key_len);
00136 #endif
00137   
00138   int   external_lock(THD *thd, int lock_type);
00139 #ifndef DRIZZLED
00140   int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
00141 #endif
00142   void get_auto_increment(uint64_t, uint64_t,
00143                           uint64_t,
00144                           uint64_t *,
00145                           uint64_t *)
00146   {}
00147 
00148   THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type);
00149 
00150   bool get_error_message(int error, String *buf);
00151 
00152 };
00153 
00154 #endif
00155