00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <drizzled/cursor.h>
00023 #include <drizzled/thr_lock.h>
00024
00025 typedef struct st_heap_info HP_INFO;
00026 typedef unsigned char *HEAP_PTR;
00027
00028 class ha_heap : public drizzled::Cursor
00029 {
00030 HP_INFO *file;
00031
00032 uint32_t records_changed;
00033 uint32_t key_stat_version;
00034 bool internal_table;
00035 public:
00036 ha_heap(drizzled::plugin::StorageEngine &engine, drizzled::Table &table);
00037 ~ha_heap() {}
00038 Cursor *clone(drizzled::memory::Root *mem_root);
00039
00040 const char *index_type(uint32_t inx);
00041
00042 double scan_time()
00043 { return (double) (stats.records+stats.deleted) / 20.0+10; }
00044 double read_time(uint32_t, uint32_t,
00045 drizzled::ha_rows rows)
00046 { return (double) rows / 20.0+1; }
00047
00048 int doOpen(const drizzled::identifier::Table &identifier, int mode, uint32_t test_if_locked);
00049 int close(void);
00050 void set_keys_for_scanning(void);
00051 int doInsertRecord(unsigned char * buf);
00052 int doUpdateRecord(const unsigned char * old_data, unsigned char * new_data);
00053 int doDeleteRecord(const unsigned char * buf);
00054 virtual void get_auto_increment(uint64_t offset, uint64_t increment,
00055 uint64_t nb_desired_values,
00056 uint64_t *first_value,
00057 uint64_t *nb_reserved_values);
00058 int index_read_map(unsigned char * buf, const unsigned char * key,
00059 drizzled::key_part_map keypart_map,
00060 enum drizzled::ha_rkey_function find_flag);
00061 int index_read_last_map(unsigned char *buf, const unsigned char *key,
00062 drizzled::key_part_map keypart_map);
00063 int index_read_idx_map(unsigned char * buf, uint32_t index,
00064 const unsigned char * key,
00065 drizzled::key_part_map keypart_map,
00066 enum drizzled::ha_rkey_function find_flag);
00067 int index_next(unsigned char * buf);
00068 int index_prev(unsigned char * buf);
00069 int index_first(unsigned char * buf);
00070 int index_last(unsigned char * buf);
00071 int doStartTableScan(bool scan);
00072 int rnd_next(unsigned char *buf);
00073 int rnd_pos(unsigned char * buf, unsigned char *pos);
00074 void position(const unsigned char *record);
00075 int info(uint);
00076 int extra(enum drizzled::ha_extra_function operation);
00077 int reset();
00078 int delete_all_rows(void);
00079 int disable_indexes(uint32_t mode);
00080 int enable_indexes(uint32_t mode);
00081 int indexes_are_disabled(void);
00082 drizzled::ha_rows records_in_range(uint32_t inx,
00083 drizzled::key_range *min_key,
00084 drizzled::key_range *max_key);
00085 void drop_table();
00086
00087 int cmp_ref(const unsigned char *ref1, const unsigned char *ref2);
00088 int reset_auto_increment(uint64_t value)
00089 {
00090 file->getShare()->auto_increment= value;
00091 return 0;
00092 }
00093 private:
00094 void update_key_stats();
00095 };
00096