Drizzled Public API Documentation

haildb_engine.h
00001 /*
00002   Copyright (C) 2010 Stewart Smith
00003 
00004   This program is free software; you can redistribute it and/or
00005   modify it under the terms of the GNU General Public License
00006   as published by the Free Software Foundation; either version 2
00007   of the License, or (at your option) any later version.
00008 
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details.
00013 
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017 */
00018 
00019 #pragma once
00020 
00021 #include <drizzled/cursor.h>
00022 #include <drizzled/atomics.h>
00023 
00024 class HailDBTableShare
00025 {
00026 public:
00027   HailDBTableShare(const char* name, bool hidden_primary_key);
00028 
00029   drizzled::THR_LOCK lock;
00030   int use_count;
00031   std::string table_name;
00032 
00033   drizzled::atomic<uint64_t> auto_increment_value;
00034   drizzled::atomic<uint64_t> hidden_pkey_auto_increment_value;
00035   bool has_hidden_primary_key;
00036 };
00037 
00038 class HailDBCursor: public drizzled::Cursor
00039 {
00040 public:
00041   HailDBCursor(drizzled::plugin::StorageEngine &engine, drizzled::Table &table_arg);
00042   ~HailDBCursor()
00043   {}
00044 
00045   /*
00046     The name of the index type that will be used for display
00047     don't implement this method unless you really have indexes
00048   */
00049   const char *index_type(uint32_t key_number);
00050   uint32_t index_flags(uint32_t inx) const;
00051   int open(const char *name, int mode, uint32_t test_if_locked);
00052   int close(void);
00053   int external_lock(drizzled::Session* session, int lock_type);
00054   int doInsertRecord(unsigned char * buf);
00055   int doStartTableScan(bool scan);
00056   int rnd_next(unsigned char *buf);
00057   int doEndTableScan();
00058   int rnd_pos(unsigned char * buf, unsigned char *pos);
00059 
00060   int doStartIndexScan(uint32_t, bool);
00061   int index_read(unsigned char *buf, const unsigned char *key_ptr,
00062                  uint32_t key_len, drizzled::ha_rkey_function find_flag);
00063 
00064   int haildb_index_read(unsigned char *buf,
00065                         const unsigned char *key_ptr,
00066                         uint32_t key_len,
00067                         drizzled::ha_rkey_function find_flag,
00068                         bool allocate_blobs);
00069 
00070   uint32_t calculate_key_len(uint32_t key_position,
00071                              drizzled::key_part_map keypart_map_arg);
00072   int haildb_index_read_map(unsigned char * buf,
00073                             const unsigned char *key,
00074                             drizzled::key_part_map keypart_map,
00075                             drizzled::ha_rkey_function find_flag,
00076                             bool allocate_blobs);
00077   int index_read_idx_map(unsigned char * buf,
00078                          uint32_t index,
00079                          const unsigned char * key,
00080                          drizzled::key_part_map keypart_map,
00081                          drizzled::ha_rkey_function find_flag);
00082 
00083   int index_next(unsigned char * buf);
00084   int doEndIndexScan();
00085   int index_prev(unsigned char * buf);
00086   int index_first(unsigned char * buf);
00087   int index_last(unsigned char * buf);
00088   void position(const unsigned char *record);
00089   int info(uint32_t flag);
00090   double scan_time();
00091   int doDeleteRecord(const unsigned char *);
00092   int delete_all_rows(void);
00093   int doUpdateRecord(const unsigned char * old_data, unsigned char * new_data);
00094   int extra(drizzled::ha_extra_function operation);
00095 
00096   HailDBTableShare *get_share(const char *table_name,
00097                               bool has_hidden_primary_key,
00098                               int *rc);
00099   int free_share();
00100 
00101   HailDBTableShare *share;
00102   drizzled::THR_LOCK_DATA lock;  /* lock for store_lock. this is ass. */
00103   drizzled::THR_LOCK_DATA **store_lock(drizzled::Session *,
00104                                        drizzled::THR_LOCK_DATA **to,
00105                                        drizzled::thr_lock_type);
00106 
00107   uint64_t getInitialAutoIncrementValue();
00108   uint64_t getHiddenPrimaryKeyInitialAutoIncrementValue();
00109 
00110   void get_auto_increment(uint64_t ,
00111                           uint64_t ,
00112                           uint64_t ,
00113                           uint64_t *first_value,
00114                           uint64_t *nb_reserved_values);
00115 
00116   int reset();
00117   int analyze(drizzled::Session* session);
00118 
00119 private:
00120   ib_id_t table_id;
00121   ib_crsr_t cursor;
00122   ib_tpl_t tuple;
00123   bool advance_cursor;
00124   ib_lck_mode_t ib_lock_mode;
00125   bool cursor_is_sec_index;
00126 
00127   bool write_can_replace;
00128   uint64_t hidden_autoinc_pkey_position;
00129   drizzled::memory::Root *blobroot;
00130 
00131   bool in_table_scan;
00132 };
00133 
00134 int get_haildb_system_table_message(const char* table_name, drizzled::message::Table *table_message);
00135