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 myisam handler */
|
|
22 |
||
23 |
#include <myisam.h> |
|
24 |
#include <ft_global.h> |
|
25 |
||
26 |
#define HA_RECOVER_NONE 0 /* No automatic recover */ |
|
27 |
#define HA_RECOVER_DEFAULT 1 /* Automatic recover active */ |
|
28 |
#define HA_RECOVER_BACKUP 2 /* Make a backupfile on recover */ |
|
29 |
#define HA_RECOVER_FORCE 4 /* Recover even if we loose rows */ |
|
30 |
#define HA_RECOVER_QUICK 8 /* Don't check rows in data file */ |
|
31 |
||
32 |
extern ulong myisam_sort_buffer_size; |
|
33 |
extern TYPELIB myisam_recover_typelib; |
|
34 |
extern ulong myisam_recover_options; |
|
35 |
||
36 |
C_MODE_START
|
|
37 |
my_bool index_cond_func_myisam(void *arg); |
|
38 |
C_MODE_END
|
|
39 |
||
40 |
class ha_myisam: public handler |
|
41 |
{
|
|
42 |
MI_INFO *file; |
|
43 |
uint64_t int_table_flags; |
|
44 |
char *data_file_name, *index_file_name; |
|
45 |
bool can_enable_indexes; |
|
46 |
int repair(THD *thd, MI_CHECK ¶m, bool optimize); |
|
47 |
||
48 |
public: |
|
49 |
ha_myisam(handlerton *hton, TABLE_SHARE *table_arg); |
|
50 |
~ha_myisam() {} |
|
51 |
handler *clone(MEM_ROOT *mem_root); |
|
52 |
const char *table_type() const { return "MyISAM"; } |
|
53 |
const char *index_type(uint key_number); |
|
54 |
const char **bas_ext() const; |
|
55 |
uint64_t table_flags() const { return int_table_flags; } |
|
56 |
int index_init(uint idx, bool sorted); |
|
57 |
int index_end(); |
|
58 |
ulong index_flags(uint inx, uint part, bool all_parts) const |
|
59 |
{
|
|
60 |
return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? |
|
61 |
0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | |
|
62 |
HA_READ_ORDER | HA_KEYREAD_ONLY | |
|
63 |
(keys_with_parts.is_set(inx)?0:HA_DO_INDEX_COND_PUSHDOWN)); |
|
64 |
}
|
|
65 |
uint max_supported_keys() const { return MI_MAX_KEY; } |
|
66 |
uint max_supported_key_length() const { return MI_MAX_KEY_LENGTH; } |
|
67 |
uint max_supported_key_part_length() const { return MI_MAX_KEY_LENGTH; } |
|
68 |
uint checksum() const; |
|
69 |
||
70 |
int open(const char *name, int mode, uint test_if_locked); |
|
71 |
int close(void); |
|
72 |
int write_row(uchar * buf); |
|
73 |
int update_row(const uchar * old_data, uchar * new_data); |
|
74 |
int delete_row(const uchar * buf); |
|
75 |
int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, |
|
76 |
enum ha_rkey_function find_flag); |
|
77 |
int index_read_idx_map(uchar *buf, uint index, const uchar *key, |
|
78 |
key_part_map keypart_map, |
|
79 |
enum ha_rkey_function find_flag); |
|
80 |
int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map); |
|
81 |
int index_next(uchar * buf); |
|
82 |
int index_prev(uchar * buf); |
|
83 |
int index_first(uchar * buf); |
|
84 |
int index_last(uchar * buf); |
|
85 |
int index_next_same(uchar *buf, const uchar *key, uint keylen); |
|
86 |
int ft_init() |
|
87 |
{
|
|
88 |
if (!ft_handler) |
|
89 |
return 1; |
|
90 |
ft_handler->please->reinit_search(ft_handler); |
|
91 |
return 0; |
|
92 |
}
|
|
93 |
FT_INFO *ft_init_ext(uint flags, uint inx,String *key) |
|
94 |
{
|
|
95 |
return ft_init_search(flags,file,inx, |
|
96 |
(uchar *)key->ptr(), key->length(), key->charset(), |
|
97 |
table->record[0]); |
|
98 |
}
|
|
99 |
int ft_read(uchar *buf); |
|
100 |
int rnd_init(bool scan); |
|
101 |
int rnd_next(uchar *buf); |
|
102 |
int rnd_pos(uchar * buf, uchar *pos); |
|
103 |
int restart_rnd_next(uchar *buf, uchar *pos); |
|
104 |
void position(const uchar *record); |
|
105 |
int info(uint); |
|
106 |
int extra(enum ha_extra_function operation); |
|
107 |
int extra_opt(enum ha_extra_function operation, ulong cache_size); |
|
108 |
int reset(void); |
|
109 |
int external_lock(THD *thd, int lock_type); |
|
110 |
int delete_all_rows(void); |
|
111 |
int disable_indexes(uint mode); |
|
112 |
int enable_indexes(uint mode); |
|
113 |
int indexes_are_disabled(void); |
|
114 |
void start_bulk_insert(ha_rows rows); |
|
115 |
int end_bulk_insert(); |
|
116 |
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); |
|
117 |
void update_create_info(HA_CREATE_INFO *create_info); |
|
118 |
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); |
|
119 |
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, |
|
120 |
enum thr_lock_type lock_type); |
|
121 |
virtual void get_auto_increment(uint64_t offset, uint64_t increment, |
|
122 |
uint64_t nb_desired_values, |
|
123 |
uint64_t *first_value, |
|
124 |
uint64_t *nb_reserved_values); |
|
125 |
int rename_table(const char * from, const char * to); |
|
126 |
int delete_table(const char *name); |
|
127 |
int check(THD* thd, HA_CHECK_OPT* check_opt); |
|
128 |
int analyze(THD* thd,HA_CHECK_OPT* check_opt); |
|
129 |
int repair(THD* thd, HA_CHECK_OPT* check_opt); |
|
130 |
bool check_and_repair(THD *thd); |
|
131 |
bool is_crashed() const; |
|
132 |
bool auto_repair() const { return myisam_recover_options != 0; } |
|
133 |
int optimize(THD* thd, HA_CHECK_OPT* check_opt); |
|
134 |
int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt); |
|
135 |
int preload_keys(THD* thd, HA_CHECK_OPT* check_opt); |
|
136 |
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); |
|
137 |
#ifdef HAVE_QUERY_CACHE
|
|
138 |
my_bool register_query_cache_table(THD *thd, char *table_key, |
|
139 |
uint key_length, |
|
140 |
qc_engine_callback
|
|
141 |
*engine_callback, |
|
142 |
uint64_t *engine_data); |
|
143 |
#endif
|
|
144 |
MI_INFO *file_ptr(void) |
|
145 |
{
|
|
146 |
return file; |
|
147 |
}
|
|
148 |
int read_range_first(const key_range *start_key, const key_range *end_key, |
|
149 |
bool eq_range_arg, bool sorted); |
|
150 |
int read_range_next(); |
|
151 |
public: |
|
152 |
/**
|
|
153 |
* Multi Range Read interface
|
|
154 |
*/
|
|
155 |
int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, |
|
156 |
uint n_ranges, uint mode, HANDLER_BUFFER *buf); |
|
157 |
int multi_range_read_next(char **range_info); |
|
158 |
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, |
|
159 |
void *seq_init_param, |
|
160 |
uint n_ranges, uint *bufsz, |
|
161 |
uint *flags, COST_VECT *cost); |
|
162 |
int multi_range_read_info(uint keyno, uint n_ranges, uint keys, |
|
163 |
uint *bufsz, uint *flags, COST_VECT *cost); |
|
164 |
||
165 |
/* Index condition pushdown implementation */
|
|
166 |
Item *idx_cond_push(uint keyno, Item* idx_cond); |
|
167 |
private: |
|
168 |
DsMrr_impl ds_mrr; |
|
169 |
key_map keys_with_parts; |
|
170 |
friend my_bool index_cond_func_myisam(void *arg); |
|
171 |
};
|
|
172 |