~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
#ifdef USE_PRAGMA_INTERFACE
18
#pragma interface			/* gcc class implementation */
19
#endif
20
21
/* class for the the heap handler */
22
23
#include <heap.h>
24
25
class ha_heap: public handler
26
{
27
  HP_INFO *file;
28
  HP_SHARE *internal_share;
29
  key_map btree_keys;
30
  /* number of records changed since last statistics update */
31
  uint    records_changed;
32
  uint    key_stat_version;
33
  my_bool internal_table;
34
public:
35
  ha_heap(handlerton *hton, TABLE_SHARE *table);
36
  ~ha_heap() {}
37
  handler *clone(MEM_ROOT *mem_root);
38
  const char *table_type() const
39
  {
40
    return (table->in_use->variables.sql_mode & MODE_MYSQL323) ?
41
           "HEAP" : "MEMORY";
42
  }
43
  const char *index_type(uint inx)
44
  {
45
    return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
46
            "BTREE" : "HASH");
47
  }
48
  /* Rows also use a fixed-size format */
49
  enum row_type get_row_type() const { return ROW_TYPE_FIXED; }
50
  const char **bas_ext() const;
51
  uint64_t table_flags() const
52
  {
53
    return (HA_FAST_KEY_READ | HA_NO_BLOBS | HA_NULL_IN_KEY |
54
            HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
55
            HA_REC_NOT_IN_SEQ | HA_CAN_INSERT_DELAYED | HA_NO_TRANSACTIONS |
56
            HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT);
57
  }
212.1.3 by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)).
58
  uint32_t index_flags(uint inx, uint part __attribute__((unused)),
59
                       bool all_parts __attribute__((unused))) const
1 by brian
clean slate
60
  {
61
    return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
62
            HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE :
63
            HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR);
64
  }
65
  const key_map *keys_to_use_for_scanning() { return &btree_keys; }
66
  uint max_supported_keys()          const { return MAX_KEY; }
67
  uint max_supported_key_part_length() const { return MAX_KEY_LENGTH; }
68
  double scan_time()
69
  { return (double) (stats.records+stats.deleted) / 20.0+10; }
212.1.3 by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)).
70
  double read_time(uint index __attribute__((unused)),
71
                   uint ranges __attribute__((unused)),
77.1.7 by Monty Taylor
Heap builds clean.
72
                   ha_rows rows)
1 by brian
clean slate
73
  { return (double) rows /  20.0+1; }
74
75
  int open(const char *name, int mode, uint test_if_locked);
76
  int close(void);
77
  void set_keys_for_scanning(void);
78
  int write_row(uchar * buf);
79
  int update_row(const uchar * old_data, uchar * new_data);
80
  int delete_row(const uchar * buf);
81
  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
82
                                  uint64_t nb_desired_values,
83
                                  uint64_t *first_value,
84
                                  uint64_t *nb_reserved_values);
85
  int index_read_map(uchar * buf, const uchar * key, key_part_map keypart_map,
86
                     enum ha_rkey_function find_flag);
87
  int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map);
88
  int index_read_idx_map(uchar * buf, uint index, const uchar * key,
89
                         key_part_map keypart_map,
90
                         enum ha_rkey_function find_flag);
91
  int index_next(uchar * buf);
92
  int index_prev(uchar * buf);
93
  int index_first(uchar * buf);
94
  int index_last(uchar * buf);
95
  int rnd_init(bool scan);
96
  int rnd_next(uchar *buf);
97
  int rnd_pos(uchar * buf, uchar *pos);
98
  void position(const uchar *record);
99
  int info(uint);
100
  int extra(enum ha_extra_function operation);
101
  int reset();
102
  int external_lock(THD *thd, int lock_type);
103
  int delete_all_rows(void);
104
  int disable_indexes(uint mode);
105
  int enable_indexes(uint mode);
106
  int indexes_are_disabled(void);
107
  ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
108
  int delete_table(const char *from);
109
  void drop_table(const char *name);
110
  int rename_table(const char * from, const char * to);
111
  int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
112
  void update_create_info(HA_CREATE_INFO *create_info);
113
114
  THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
115
			     enum thr_lock_type lock_type);
116
  int cmp_ref(const uchar *ref1, const uchar *ref2)
117
  {
118
    return memcmp(ref1, ref2, sizeof(HEAP_PTR));
119
  }
120
  bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
121
private:
122
  void update_key_stats();
123
};