34 #include "my_compare.h"
35 #include <mysql/plugin.h>
41 #if MAX_INDEXES > HA_MAX_POSSIBLE_KEY
42 #define MI_MAX_KEY HA_MAX_POSSIBLE_KEY
44 #define MI_MAX_KEY MAX_INDEXES
47 #define MI_MAX_POSSIBLE_KEY_BUFF HA_MAX_POSSIBLE_KEY_BUFF
52 #define MI_MAX_KEY_LENGTH 1000
53 #define MI_MAX_KEY_SEG 16
55 #define MI_MAX_KEY_BUFF (MI_MAX_KEY_LENGTH+MI_MAX_KEY_SEG*6+8+8)
56 #define MI_MAX_MSG_BUF 1024
57 #define MI_NAME_IEXT ".MYI"
58 #define MI_NAME_DEXT ".MYD"
61 #define MI_KEY_BLOCK_LENGTH 1024
62 #define MI_MIN_KEY_BLOCK_LENGTH 1024
63 #define MI_MAX_KEY_BLOCK_LENGTH 16384
72 #define MI_KEYMAP_BITS (8 * SIZEOF_LONG_LONG)
73 #define MI_KEYMAP_HIGH_MASK (ULL(1) << (MI_KEYMAP_BITS - 1))
74 #define mi_get_mask_all_keys_active(_keys_) \
75 (((_keys_) < MI_KEYMAP_BITS) ? \
76 ((ULL(1) << (_keys_)) - ULL(1)) : \
79 #if MI_MAX_KEY > MI_KEYMAP_BITS
81 #define mi_is_key_active(_keymap_,_keyno_) \
82 (((_keyno_) < MI_KEYMAP_BITS) ? \
83 test((_keymap_) & (ULL(1) << (_keyno_))) : \
84 test((_keymap_) & MI_KEYMAP_HIGH_MASK))
85 #define mi_set_key_active(_keymap_,_keyno_) \
86 (_keymap_)|= (((_keyno_) < MI_KEYMAP_BITS) ? \
87 (ULL(1) << (_keyno_)) : \
89 #define mi_clear_key_active(_keymap_,_keyno_) \
90 (_keymap_)&= (((_keyno_) < MI_KEYMAP_BITS) ? \
91 (~ (ULL(1) << (_keyno_))) : \
96 #define mi_is_key_active(_keymap_,_keyno_) \
97 test((_keymap_) & (ULL(1) << (_keyno_)))
98 #define mi_set_key_active(_keymap_,_keyno_) \
99 (_keymap_)|= (ULL(1) << (_keyno_))
100 #define mi_clear_key_active(_keymap_,_keyno_) \
101 (_keymap_)&= (~ (ULL(1) << (_keyno_)))
105 #define mi_is_any_key_active(_keymap_) \
107 #define mi_is_all_keys_active(_keymap_,_keys_) \
108 ((_keymap_) == mi_get_mask_all_keys_active(_keys_))
109 #define mi_set_all_keys_active(_keymap_,_keys_) \
110 (_keymap_)= mi_get_mask_all_keys_active(_keys_)
111 #define mi_clear_all_keys_active(_keymap_) \
113 #define mi_intersect_keys_active(_to_,_from_) \
115 #define mi_is_any_intersect_keys_active(_keymap1_,_keys_,_keymap2_) \
116 ((_keymap1_) & (_keymap2_) & \
117 mi_get_mask_all_keys_active(_keys_))
118 #define mi_copy_keys_active(_to_,_maxkeys_,_from_) \
119 (_to_)= (mi_get_mask_all_keys_active(_maxkeys_) & \
130 my_off_t dupp_key_pos;
131 my_off_t data_file_length,
132 max_data_file_length,
134 max_index_file_length,
137 ulong mean_reclength;
138 ulonglong auto_increment;
140 char *data_file_name, *index_file_name;
157 const char *index_file_name, *data_file_name;
160 ulonglong auto_increment;
161 ulonglong data_file_length;
162 ulonglong key_file_length;
165 my_bool with_auto_increment;
181 uint16 underflow_block_length;
185 uint16 block_size_index;
192 uchar *
page,uchar *key,
193 uint key_len,uint comp_flag,uchar * *ret_pos,
194 uchar *buff, my_bool *was_last_key);
197 int (*pack_key)(
struct st_mi_keydef *keyinfo,uint nod_flag,uchar *next_key,
198 uchar *org_key, uchar *prev_key, uchar *key,
202 int (*ck_insert)(
struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
203 int (*ck_delete)(
struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
207 #define MI_UNIQUE_HASH_LENGTH 4
213 uint8 null_are_equal;
220 uint quick_table_bits;
241 #ifndef NOT_PACKED_DATABASES
243 uchar *start,uchar *end);
244 enum en_fieldtype base_type;
245 uint space_length_bits,pack_type;
251 extern char * myisam_log_filename;
252 extern ulong myisam_block_size;
253 extern ulong myisam_concurrent_insert;
254 extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user;
255 extern my_off_t myisam_max_temp_length;
256 extern ulong myisam_data_pointer_size;
260 extern int (*myisam_test_invalid_symlink)(
const char *filename);
261 extern ulonglong myisam_mmap_size, myisam_mmap_used;
269 uint wait_if_locked);
270 extern int mi_panic(
enum ha_panic_function
function);
272 extern int mi_rkey(
MI_INFO *info, uchar *
buf,
int inx,
const uchar *key,
273 key_part_map keypart_map,
enum ha_rkey_function search_flag);
283 int inx, my_off_t pos);
290 extern int mi_create(
const char *
name,uint keys,
MI_KEYDEF *keydef,
294 extern int mi_delete_table(
const char *
name);
295 extern int mi_rename(
const char *from,
const char *
to);
297 enum ha_extra_function
function,
300 extern ha_rows mi_records_in_range(
MI_INFO *info,
int inx,
302 extern int mi_log(
int activate_log);
305 extern ulong _mi_calc_blob_length(uint length ,
const uchar *pos);
306 extern uint mi_get_pointer_length(ulonglong file_length, uint def);
308 #define MEMMAP_EXTRA_MARGIN 7
311 #define MYISAMCHK_REPAIR 1
312 #define MYISAMCHK_VERIFY 2
325 #define T_AUTO_REPAIR 2
326 #define T_BACKUP_DATA 4
327 #define T_CALC_CHECKSUM 8
329 #define T_CHECK_ONLY_CHANGED 32
330 #define T_CREATE_MISSING_KEYS 64
331 #define T_DESCRIPT 128
332 #define T_DONT_CHECK_CHECKSUM 256
334 #define T_FAST (1L << 10)
335 #define T_FORCE_CREATE (1L << 11)
336 #define T_FORCE_UNIQUENESS (1L << 12)
337 #define T_INFO (1L << 13)
338 #define T_MEDIUM (1L << 14)
339 #define T_QUICK (1L << 15)
340 #define T_READONLY (1L << 16)
341 #define T_REP (1L << 17)
342 #define T_REP_BY_SORT (1L << 18)
343 #define T_REP_PARALLEL (1L << 19)
344 #define T_RETRY_WITHOUT_QUICK (1L << 20)
345 #define T_SAFE_REPAIR (1L << 21)
346 #define T_SILENT (1L << 22)
347 #define T_SORT_INDEX (1L << 23)
348 #define T_SORT_RECORDS (1L << 24)
349 #define T_STATISTICS (1L << 25)
350 #define T_UNPACK (1L << 26)
351 #define T_UPDATE_STATE (1L << 27)
352 #define T_VERBOSE (1L << 28)
353 #define T_VERY_SILENT (1L << 29)
354 #define T_WAIT_FOREVER (1L << 30)
355 #define T_WRITE_LOOP ((ulong) 1L << 31)
357 #define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL)
365 #define TT_FOR_UPGRADE 2
367 #define O_NEW_INDEX 1
369 #define O_DATA_LOST 4
375 uchar *buff,*end_pos;
376 uchar lastkey[MI_MAX_POSSIBLE_KEY_BUFF];
391 MI_STATS_METHOD_NULLS_NOT_EQUAL,
393 MI_STATS_METHOD_NULLS_EQUAL,
395 MI_STATS_METHOD_IGNORE_NULLS
396 } enum_mi_stats_method;
400 ulonglong auto_increment_value;
401 ulonglong max_data_file_length;
402 ulonglong keys_in_use;
403 ulonglong max_record_length;
404 ulonglong sort_buffer_length;
405 my_off_t search_after_block;
406 my_off_t new_file_pos,key_file_blocks;
407 my_off_t keydata,totaldata,key_blocks,start_check_pos;
408 ha_rows total_records,total_deleted;
409 ha_checksum record_checksum,glob_crc;
410 ulonglong use_buffers;
411 ulong read_buffer_length, write_buffer_length, sort_key_blocks;
412 uint out_flag,warning_printed,error_printed,verbose;
413 uint opt_sort_key,total_files,max_level;
414 uint testflag, key_cache_block_size;
416 my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
417 my_bool retry_repair, force_sort;
418 char temp_filename[FN_REFLEN],*isam_file_name;
420 int tmpfile_createflag;
428 ulonglong unique_count[MI_MAX_KEY_SEG+1];
429 ulonglong notnull_count[MI_MAX_KEY_SEG+1];
431 ha_checksum key_crc[HA_MAX_POSSIBLE_KEY];
432 ulong rec_per_key_part[MI_MAX_KEY_SEG*HA_MAX_POSSIBLE_KEY];
434 const char *db_name, *table_name;
436 enum_mi_stats_method stats_method;
438 my_bool need_print_msg_lock;
445 uchar lastkey[MI_MAX_KEY_BUFF];
450 my_off_t filelength,dupp,buff_length;
452 uint current_key, total_keys;
454 enum data_file_type new_data_file_type;
461 uint got_error, threads_running;
467 void myisamchk_init(
MI_CHECK *param);
474 char *
name,
int rep_quick);
477 const char *
name,
int rep_quick);
479 const char *
name,
int rep_quick);
480 int change_to_newfile(
const char * filename,
const char * old_ext,
481 const char * new_ext, myf myflags);
482 int lock_file(
MI_CHECK *param, File
file, my_off_t start,
int lock_type,
483 const char *filetype,
const char *filename);
488 void update_key_parts(
MI_KEYDEF *keyinfo, ulong *rec_per_key_part,
489 ulonglong *unique, ulonglong *notnull,
491 int filecopy(
MI_CHECK *param, File
to,File from,my_off_t start,
492 my_off_t length,
const char *
type);
494 my_off_t newpos, uint prot_key);
495 int write_data_suffix(
SORT_INFO *sort_info, my_bool fix_datafile);
496 int test_if_almost_full(
MI_INFO *info);
497 int recreate_table(
MI_CHECK *param,
MI_INFO **org_info,
char *filename);
498 void mi_disable_non_unique_index(
MI_INFO *info, ha_rows rows);
499 my_bool mi_test_if_sort_rep(
MI_INFO *info, ha_rows rows, ulonglong
key_map,
502 int mi_init_bulk_insert(
MI_INFO *info, ulong cache_size, ha_rows rows);
503 void mi_flush_bulk_insert(
MI_INFO *info, uint inx);
504 void mi_end_bulk_insert(
MI_INFO *info);
507 void mi_change_key_cache(
KEY_CACHE *old_key_cache,
509 int mi_preload(
MI_INFO *info, ulonglong
key_map, my_bool ignore_leaves);