~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000-2006 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
17
18
/* class for the the heap handler */
19
20
#include <heap.h>
21
22
class ha_heap: public handler
23
{
24
  HP_INFO *file;
25
  HP_SHARE *internal_share;
26
  key_map btree_keys;
27
  /* number of records changed since last statistics update */
482 by Brian Aker
Remove uint.
28
  uint32_t    records_changed;
29
  uint32_t    key_stat_version;
280 by Brian Aker
Removed my_bool from heap engine.
30
  bool internal_table;
1 by brian
clean slate
31
public:
32
  ha_heap(handlerton *hton, TABLE_SHARE *table);
33
  ~ha_heap() {}
34
  handler *clone(MEM_ROOT *mem_root);
35
  const char *table_type() const
36
  {
357 by Brian Aker
flag cleanup
37
    return "MEMORY";
1 by brian
clean slate
38
  }
482 by Brian Aker
Remove uint.
39
  const char *index_type(uint32_t inx)
1 by brian
clean slate
40
  {
41
    return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
42
            "BTREE" : "HASH");
43
  }
244.1.1 by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns.
44
  enum row_type get_row_type() const;
1 by brian
clean slate
45
  const char **bas_ext() const;
46
  uint64_t table_flags() const
47
  {
48
    return (HA_FAST_KEY_READ | HA_NO_BLOBS | HA_NULL_IN_KEY |
49
            HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
50
            HA_REC_NOT_IN_SEQ | HA_NO_TRANSACTIONS |
1 by brian
clean slate
51
            HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT);
52
  }
482 by Brian Aker
Remove uint.
53
  uint32_t index_flags(uint32_t inx, uint32_t part __attribute__((unused)),
212.1.3 by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)).
54
                       bool all_parts __attribute__((unused))) const
1 by brian
clean slate
55
  {
56
    return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
57
            HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE :
58
            HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR);
59
  }
60
  const key_map *keys_to_use_for_scanning() { return &btree_keys; }
482 by Brian Aker
Remove uint.
61
  uint32_t max_supported_keys()          const { return MAX_KEY; }
62
  uint32_t max_supported_key_part_length() const { return MAX_KEY_LENGTH; }
1 by brian
clean slate
63
  double scan_time()
64
  { return (double) (stats.records+stats.deleted) / 20.0+10; }
482 by Brian Aker
Remove uint.
65
  double read_time(uint32_t index __attribute__((unused)),
66
                   uint32_t ranges __attribute__((unused)),
77.1.7 by Monty Taylor
Heap builds clean.
67
                   ha_rows rows)
1 by brian
clean slate
68
  { return (double) rows /  20.0+1; }
69
482 by Brian Aker
Remove uint.
70
  int open(const char *name, int mode, uint32_t test_if_locked);
1 by brian
clean slate
71
  int close(void);
72
  void set_keys_for_scanning(void);
481 by Brian Aker
Remove all of uchar.
73
  int write_row(unsigned char * buf);
74
  int update_row(const unsigned char * old_data, unsigned char * new_data);
75
  int delete_row(const unsigned char * buf);
1 by brian
clean slate
76
  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
77
                                  uint64_t nb_desired_values,
78
                                  uint64_t *first_value,
79
                                  uint64_t *nb_reserved_values);
481 by Brian Aker
Remove all of uchar.
80
  int index_read_map(unsigned char * buf, const unsigned char * key, key_part_map keypart_map,
1 by brian
clean slate
81
                     enum ha_rkey_function find_flag);
481 by Brian Aker
Remove all of uchar.
82
  int index_read_last_map(unsigned char *buf, const unsigned char *key, key_part_map keypart_map);
482 by Brian Aker
Remove uint.
83
  int index_read_idx_map(unsigned char * buf, uint32_t index, const unsigned char * key,
1 by brian
clean slate
84
                         key_part_map keypart_map,
85
                         enum ha_rkey_function find_flag);
481 by Brian Aker
Remove all of uchar.
86
  int index_next(unsigned char * buf);
87
  int index_prev(unsigned char * buf);
88
  int index_first(unsigned char * buf);
89
  int index_last(unsigned char * buf);
1 by brian
clean slate
90
  int rnd_init(bool scan);
481 by Brian Aker
Remove all of uchar.
91
  int rnd_next(unsigned char *buf);
92
  int rnd_pos(unsigned char * buf, unsigned char *pos);
93
  void position(const unsigned char *record);
1 by brian
clean slate
94
  int info(uint);
95
  int extra(enum ha_extra_function operation);
96
  int reset();
520.1.22 by Brian Aker
Second pass of thd cleanup
97
  int external_lock(Session *session, int lock_type);
1 by brian
clean slate
98
  int delete_all_rows(void);
482 by Brian Aker
Remove uint.
99
  int disable_indexes(uint32_t mode);
100
  int enable_indexes(uint32_t mode);
1 by brian
clean slate
101
  int indexes_are_disabled(void);
482 by Brian Aker
Remove uint.
102
  ha_rows records_in_range(uint32_t inx, key_range *min_key, key_range *max_key);
1 by brian
clean slate
103
  int delete_table(const char *from);
104
  void drop_table(const char *name);
105
  int rename_table(const char * from, const char * to);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
106
  int create(const char *name, Table *form, HA_CREATE_INFO *create_info);
1 by brian
clean slate
107
  void update_create_info(HA_CREATE_INFO *create_info);
108
520.1.22 by Brian Aker
Second pass of thd cleanup
109
  THR_LOCK_DATA **store_lock(Session *session, THR_LOCK_DATA **to,
1 by brian
clean slate
110
			     enum thr_lock_type lock_type);
481 by Brian Aker
Remove all of uchar.
111
  int cmp_ref(const unsigned char *ref1, const unsigned char *ref2)
1 by brian
clean slate
112
  {
113
    return memcmp(ref1, ref2, sizeof(HEAP_PTR));
114
  }
482 by Brian Aker
Remove uint.
115
  bool check_if_incompatible_data(HA_CREATE_INFO *info, uint32_t table_changes);
1 by brian
clean slate
116
private:
117
  void update_key_stats();
118
};