2 Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifdef USE_PRAGMA_INTERFACE
20 #pragma interface /* gcc class implementation */
23 /* class for the the myisam handler */
26 #include <ft_global.h>
28 #define HA_RECOVER_NONE 0 /* No automatic recover */
29 #define HA_RECOVER_DEFAULT 1 /* Automatic recover active */
30 #define HA_RECOVER_BACKUP 2 /* Make a backupfile on recover */
31 #define HA_RECOVER_FORCE 4 /* Recover even if we loose rows */
32 #define HA_RECOVER_QUICK 8 /* Don't check rows in data file */
34 extern ulong myisam_sort_buffer_size
;
35 extern TYPELIB myisam_recover_typelib
;
36 extern ulong myisam_recover_options
;
38 class ha_myisam
: public handler
41 ulonglong int_table_flags
;
42 char *data_file_name
, *index_file_name
;
43 bool can_enable_indexes
;
44 int repair(THD
*thd
, MI_CHECK
¶m
, bool optimize
);
47 ha_myisam(handlerton
*hton
, TABLE_SHARE
*table_arg
);
49 handler
*clone(const char *name
, MEM_ROOT
*mem_root
);
50 const char *table_type() const { return "MyISAM"; }
51 const char *index_type(uint key_number
);
52 const char **bas_ext() const;
53 ulonglong
table_flags() const { return int_table_flags
; }
54 ulong
index_flags(uint inx
, uint part
, bool all_parts
) const
56 return ((table_share
->key_info
[inx
].algorithm
== HA_KEY_ALG_FULLTEXT
) ?
57 0 : HA_READ_NEXT
| HA_READ_PREV
| HA_READ_RANGE
|
58 HA_READ_ORDER
| HA_KEYREAD_ONLY
);
60 uint
max_supported_keys() const { return MI_MAX_KEY
; }
61 uint
max_supported_key_length() const { return MI_MAX_KEY_LENGTH
; }
62 uint
max_supported_key_part_length() const { return MI_MAX_KEY_LENGTH
; }
63 uint
checksum() const;
65 int open(const char *name
, int mode
, uint test_if_locked
);
67 int write_row(uchar
* buf
);
68 int update_row(const uchar
* old_data
, uchar
* new_data
);
69 int delete_row(const uchar
* buf
);
70 int index_read_map(uchar
*buf
, const uchar
*key
, key_part_map keypart_map
,
71 enum ha_rkey_function find_flag
);
72 int index_read_idx_map(uchar
*buf
, uint index
, const uchar
*key
,
73 key_part_map keypart_map
,
74 enum ha_rkey_function find_flag
);
75 int index_read_last_map(uchar
*buf
, const uchar
*key
, key_part_map keypart_map
);
76 int index_next(uchar
* buf
);
77 int index_prev(uchar
* buf
);
78 int index_first(uchar
* buf
);
79 int index_last(uchar
* buf
);
80 int index_next_same(uchar
*buf
, const uchar
*key
, uint keylen
);
85 ft_handler
->please
->reinit_search(ft_handler
);
88 FT_INFO
*ft_init_ext(uint flags
, uint inx
,String
*key
)
90 return ft_init_search(flags
,file
,inx
,
91 (uchar
*)key
->ptr(), key
->length(), key
->charset(),
94 int ft_read(uchar
*buf
);
95 int rnd_init(bool scan
);
96 int rnd_next(uchar
*buf
);
97 int rnd_pos(uchar
* buf
, uchar
*pos
);
98 int restart_rnd_next(uchar
*buf
, uchar
*pos
);
99 void position(const uchar
*record
);
101 int extra(enum ha_extra_function operation
);
102 int extra_opt(enum ha_extra_function operation
, ulong cache_size
);
104 int external_lock(THD
*thd
, int lock_type
);
105 int delete_all_rows(void);
106 int reset_auto_increment(ulonglong value
);
107 int disable_indexes(uint mode
);
108 int enable_indexes(uint mode
);
109 int indexes_are_disabled(void);
110 void start_bulk_insert(ha_rows rows
);
111 int end_bulk_insert();
112 ha_rows
records_in_range(uint inx
, key_range
*min_key
, key_range
*max_key
);
113 void update_create_info(HA_CREATE_INFO
*create_info
);
114 int create(const char *name
, TABLE
*form
, HA_CREATE_INFO
*create_info
);
115 THR_LOCK_DATA
**store_lock(THD
*thd
, THR_LOCK_DATA
**to
,
116 enum thr_lock_type lock_type
);
117 virtual void get_auto_increment(ulonglong offset
, ulonglong increment
,
118 ulonglong nb_desired_values
,
119 ulonglong
*first_value
,
120 ulonglong
*nb_reserved_values
);
121 int rename_table(const char * from
, const char * to
);
122 int delete_table(const char *name
);
123 int check(THD
* thd
, HA_CHECK_OPT
* check_opt
);
124 int analyze(THD
* thd
,HA_CHECK_OPT
* check_opt
);
125 int repair(THD
* thd
, HA_CHECK_OPT
* check_opt
);
126 bool check_and_repair(THD
*thd
);
127 bool is_crashed() const;
128 bool auto_repair() const { return myisam_recover_options
!= 0; }
129 int optimize(THD
* thd
, HA_CHECK_OPT
* check_opt
);
130 int restore(THD
* thd
, HA_CHECK_OPT
* check_opt
);
131 int backup(THD
* thd
, HA_CHECK_OPT
* check_opt
);
132 int assign_to_keycache(THD
* thd
, HA_CHECK_OPT
* check_opt
);
133 int preload_keys(THD
* thd
, HA_CHECK_OPT
* check_opt
);
134 bool check_if_incompatible_data(HA_CREATE_INFO
*info
, uint table_changes
);
135 #ifdef HAVE_REPLICATION
136 int dump(THD
* thd
, int fd
);
137 int net_read_dump(NET
* net
);
139 #ifdef HAVE_QUERY_CACHE
140 my_bool
register_query_cache_table(THD
*thd
, char *table_key
,
144 ulonglong
*engine_data
);
146 MI_INFO
*file_ptr(void)