71
70
This means that clearing of high keys is ignored, setting one high key
72
71
sets all high keys.
74
#define MI_KEYMAP_BITS (8 * SIZEOF_LONG_LONG)
75
#define MI_KEYMAP_HIGH_MASK (ULL(1) << (MI_KEYMAP_BITS - 1))
73
#define MI_KEYMAP_BITS (64)
74
#define MI_KEYMAP_HIGH_MASK (1UL << (MI_KEYMAP_BITS - 1))
76
75
#define mi_get_mask_all_keys_active(_keys_) \
77
76
(((_keys_) < MI_KEYMAP_BITS) ? \
78
((ULL(1) << (_keys_)) - ULL(1)) : \
77
((1UL << (_keys_)) - 1UL) : \
81
80
#if MI_MAX_KEY > MI_KEYMAP_BITS
83
82
#define mi_is_key_active(_keymap_,_keyno_) \
84
83
(((_keyno_) < MI_KEYMAP_BITS) ? \
85
test((_keymap_) & (ULL(1) << (_keyno_))) : \
84
test((_keymap_) & (1UL << (_keyno_))) : \
86
85
test((_keymap_) & MI_KEYMAP_HIGH_MASK))
87
86
#define mi_set_key_active(_keymap_,_keyno_) \
88
87
(_keymap_)|= (((_keyno_) < MI_KEYMAP_BITS) ? \
89
(ULL(1) << (_keyno_)) : \
88
(1UL << (_keyno_)) : \
90
89
MI_KEYMAP_HIGH_MASK)
91
90
#define mi_clear_key_active(_keymap_,_keyno_) \
92
91
(_keymap_)&= (((_keyno_) < MI_KEYMAP_BITS) ? \
93
(~ (ULL(1) << (_keyno_))) : \
94
(~ (ULL(0))) /*ignore*/ )
92
(~ (1UL << (_keyno_))) : \
93
(~ (0UL)) /*ignore*/ )
98
97
#define mi_is_key_active(_keymap_,_keyno_) \
99
test((_keymap_) & (ULL(1) << (_keyno_)))
98
test((_keymap_) & (1UL << (_keyno_)))
100
99
#define mi_set_key_active(_keymap_,_keyno_) \
101
(_keymap_)|= (ULL(1) << (_keyno_))
100
(_keymap_)|= (1UL << (_keyno_))
102
101
#define mi_clear_key_active(_keymap_,_keyno_) \
103
(_keymap_)&= (~ (ULL(1) << (_keyno_)))
102
(_keymap_)&= (~ (1UL << (_keyno_)))
175
174
typedef struct st_mi_keydef /* Key definition with open & info */
177
176
struct st_mi_isam_share *share; /* Pointer to base (set in mi_open) */
178
uint16 keysegs; /* Number of key-segment */
179
uint16 flag; /* NOSAME, PACK_USED */
177
uint16_t keysegs; /* Number of key-segment */
178
uint16_t flag; /* NOSAME, PACK_USED */
181
uint8 key_alg; /* BTREE, RTREE */
182
uint16 block_length; /* Length of keyblock (auto) */
183
uint16 underflow_block_length; /* When to execute underflow */
184
uint16 keylength; /* Tot length of keyparts (auto) */
185
uint16 minlength; /* min length of (packed) key (auto) */
186
uint16 maxlength; /* max length of (packed) key (auto) */
187
uint16 block_size_index; /* block_size (auto) */
188
uint32 version; /* For concurrent read/write */
189
uint32 ftparser_nr; /* distinct ftparser number */
180
uint8_t key_alg; /* BTREE, RTREE */
181
uint16_t block_length; /* Length of keyblock (auto) */
182
uint16_t underflow_block_length; /* When to execute underflow */
183
uint16_t keylength; /* Tot length of keyparts (auto) */
184
uint16_t minlength; /* min length of (packed) key (auto) */
185
uint16_t maxlength; /* max length of (packed) key (auto) */
186
uint16_t block_size_index; /* block_size (auto) */
187
uint32_t version; /* For concurrent read/write */
191
189
HA_KEYSEG *seg,*end;
192
struct st_mysql_ftparser *parser; /* Fulltext [pre]parser */
193
191
int (*bin_search)(struct st_myisam_info *info,struct st_mi_keydef *keyinfo,
194
uchar *page,uchar *key,
195
uint key_len,uint comp_flag,uchar * *ret_pos,
196
uchar *buff, my_bool *was_last_key);
197
uint (*get_key)(struct st_mi_keydef *keyinfo,uint nod_flag,uchar * *page,
199
int (*pack_key)(struct st_mi_keydef *keyinfo,uint nod_flag,uchar *next_key,
200
uchar *org_key, uchar *prev_key, uchar *key,
192
unsigned char *page,unsigned char *key,
193
uint32_t key_len,uint32_t comp_flag,unsigned char * *ret_pos,
194
unsigned char *buff, bool *was_last_key);
195
uint32_t (*get_key)(struct st_mi_keydef *keyinfo,uint32_t nod_flag,unsigned char * *page,
197
int (*pack_key)(struct st_mi_keydef *keyinfo,uint32_t nod_flag,unsigned char *next_key,
198
unsigned char *org_key, unsigned char *prev_key, unsigned char *key,
201
199
struct st_mi_s_param *s_temp);
202
void (*store_key)(struct st_mi_keydef *keyinfo, uchar *key_pos,
200
void (*store_key)(struct st_mi_keydef *keyinfo, unsigned char *key_pos,
203
201
struct st_mi_s_param *s_temp);
204
int (*ck_insert)(struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
205
int (*ck_delete)(struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
202
int (*ck_insert)(struct st_myisam_info *inf, uint32_t k_nr, unsigned char *k, uint32_t klen);
203
int (*ck_delete)(struct st_myisam_info *inf, uint32_t k_nr, unsigned char *k, uint32_t klen);
235
233
typedef struct st_columndef /* column information */
237
int16 type; /* en_fieldtype */
238
uint16 length; /* length of field */
239
uint32 offset; /* Offset to position in row */
240
uint8 null_bit; /* If column may be 0 */
241
uint16 null_pos; /* position for null marker */
235
int16_t type; /* en_fieldtype */
236
uint16_t length; /* length of field */
237
uint32_t offset; /* Offset to position in row */
238
uint8_t null_bit; /* If column may be 0 */
239
uint16_t null_pos; /* position for null marker */
243
241
#ifndef NOT_PACKED_DATABASES
244
242
void (*unpack)(struct st_columndef *rec,struct st_mi_bit_buff *buff,
245
uchar *start,uchar *end);
243
unsigned char *start,unsigned char *end);
246
244
enum en_fieldtype base_type;
247
uint space_length_bits,pack_type;
245
uint32_t space_length_bits,pack_type;
248
246
MI_DECODE_TREE *huff_tree;
253
251
extern char * myisam_log_filename; /* Name of logfile */
254
extern ulong myisam_block_size;
255
extern ulong myisam_concurrent_insert;
256
extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user;
252
extern uint32_t myisam_block_size;
253
extern uint32_t myisam_concurrent_insert;
254
extern bool myisam_flush,myisam_delay_key_write,myisam_single_user;
257
255
extern my_off_t myisam_max_temp_length;
258
extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size;
256
extern uint32_t myisam_bulk_insert_tree_size, myisam_data_pointer_size;
260
258
/* Prototypes for myisam-functions */
262
260
extern int mi_close(struct st_myisam_info *file);
263
extern int mi_delete(struct st_myisam_info *file,const uchar *buff);
261
extern int mi_delete(struct st_myisam_info *file,const unsigned char *buff);
264
262
extern struct st_myisam_info *mi_open(const char *name,int mode,
265
uint wait_if_locked);
263
uint32_t wait_if_locked);
266
264
extern int mi_panic(enum ha_panic_function function);
267
extern int mi_rfirst(struct st_myisam_info *file,uchar *buf,int inx);
268
extern int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key,
265
extern int mi_rfirst(struct st_myisam_info *file,unsigned char *buf,int inx);
266
extern int mi_rkey(MI_INFO *info, unsigned char *buf, int inx, const unsigned char *key,
269
267
key_part_map keypart_map, enum ha_rkey_function search_flag);
270
extern int mi_rlast(struct st_myisam_info *file,uchar *buf,int inx);
271
extern int mi_rnext(struct st_myisam_info *file,uchar *buf,int inx);
272
extern int mi_rnext_same(struct st_myisam_info *info, uchar *buf);
273
extern int mi_rprev(struct st_myisam_info *file,uchar *buf,int inx);
274
extern int mi_rrnd(struct st_myisam_info *file,uchar *buf, my_off_t pos);
268
extern int mi_rlast(struct st_myisam_info *file,unsigned char *buf,int inx);
269
extern int mi_rnext(struct st_myisam_info *file,unsigned char *buf,int inx);
270
extern int mi_rnext_same(struct st_myisam_info *info, unsigned char *buf);
271
extern int mi_rprev(struct st_myisam_info *file,unsigned char *buf,int inx);
272
extern int mi_rrnd(struct st_myisam_info *file,unsigned char *buf, my_off_t pos);
275
273
extern int mi_scan_init(struct st_myisam_info *file);
276
extern int mi_scan(struct st_myisam_info *file,uchar *buf);
277
extern int mi_rsame(struct st_myisam_info *file,uchar *record,int inx);
278
extern int mi_rsame_with_pos(struct st_myisam_info *file,uchar *record,
274
extern int mi_scan(struct st_myisam_info *file,unsigned char *buf);
275
extern int mi_rsame(struct st_myisam_info *file,unsigned char *record,int inx);
276
extern int mi_rsame_with_pos(struct st_myisam_info *file,unsigned char *record,
279
277
int inx, my_off_t pos);
280
extern int mi_update(struct st_myisam_info *file,const uchar *old,
282
extern int mi_write(struct st_myisam_info *file,uchar *buff);
278
extern int mi_update(struct st_myisam_info *file,const unsigned char *old,
279
unsigned char *new_record);
280
extern int mi_write(struct st_myisam_info *file,unsigned char *buff);
283
281
extern my_off_t mi_position(struct st_myisam_info *file);
284
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint flag);
282
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint32_t flag);
285
283
extern int mi_lock_database(struct st_myisam_info *file,int lock_type);
286
extern int mi_create(const char *name,uint keys,MI_KEYDEF *keydef,
287
uint columns, MI_COLUMNDEF *columndef,
288
uint uniques, MI_UNIQUEDEF *uniquedef,
289
MI_CREATE_INFO *create_info, uint flags);
284
extern int mi_create(const char *name,uint32_t keys,MI_KEYDEF *keydef,
285
uint32_t columns, MI_COLUMNDEF *columndef,
286
uint32_t uniques, MI_UNIQUEDEF *uniquedef,
287
MI_CREATE_INFO *create_info, uint32_t flags);
290
288
extern int mi_delete_table(const char *name);
291
289
extern int mi_rename(const char *from, const char *to);
292
290
extern int mi_extra(struct st_myisam_info *file,
403
401
ha_checksum record_checksum,glob_crc;
404
402
ulong use_buffers,read_buffer_length,write_buffer_length,
405
403
sort_buffer_length,sort_key_blocks;
406
uint out_flag,warning_printed,error_printed,verbose;
407
uint opt_sort_key,total_files,max_level;
408
uint testflag, key_cache_block_size;
410
my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
411
my_bool retry_repair, force_sort;
404
uint32_t out_flag,warning_printed,error_printed,verbose;
405
uint32_t opt_sort_key,total_files,max_level;
406
uint32_t testflag, key_cache_block_size;
408
bool using_global_keycache, opt_lock_memory, opt_follow_links;
409
bool retry_repair, force_sort;
412
410
char temp_filename[FN_REFLEN],*isam_file_name;
413
411
MY_TMPDIR *tmpdir;
414
412
int tmpfile_createflag;
430
428
enum_mi_stats_method stats_method;
433
typedef struct st_sort_ft_buf
437
uchar lastkey[MI_MAX_KEY_BUFF];
440
431
typedef struct st_sort_info
442
433
my_off_t filelength,dupp,buff_length;
443
434
ha_rows max_records;
444
uint current_key, total_keys;
435
uint32_t current_key, total_keys;
446
437
enum data_file_type new_data_file_type;
450
441
SORT_KEY_BLOCKS *key_block,*key_block_end;
452
442
/* sync things */
453
uint got_error, threads_running;
443
uint32_t got_error, threads_running;
455
444
pthread_mutex_t mutex;
456
445
pthread_cond_t cond;
460
448
/* functions in mi_check */
461
449
void myisamchk_init(MI_CHECK *param);
462
450
int chk_status(MI_CHECK *param, MI_INFO *info);
463
int chk_del(MI_CHECK *param, register MI_INFO *info, uint test_flag);
451
int chk_del(MI_CHECK *param, register MI_INFO *info, uint32_t test_flag);
464
452
int chk_size(MI_CHECK *param, MI_INFO *info);
465
453
int chk_key(MI_CHECK *param, MI_INFO *info);
466
454
int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend);
472
460
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
473
461
const char * name, int rep_quick);
474
462
int change_to_newfile(const char * filename, const char * old_ext,
475
const char * new_ext, uint raid_chunks,
463
const char * new_ext, uint32_t raid_chunks,
477
int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type,
478
const char *filetype, const char *filename);
479
465
void lock_memory(MI_CHECK *param);
480
466
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
482
int update_state_info(MI_CHECK *param, MI_INFO *info,uint update);
468
int update_state_info(MI_CHECK *param, MI_INFO *info,uint32_t update);
483
469
void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part,
484
ulonglong *unique, ulonglong *notnull,
470
uint64_t *unique, uint64_t *notnull,
486
472
int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
487
473
my_off_t length, const char *type);
488
int movepoint(MI_INFO *info,uchar *record,my_off_t oldpos,
489
my_off_t newpos, uint prot_key);
490
int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile);
474
int movepoint(MI_INFO *info,unsigned char *record,my_off_t oldpos,
475
my_off_t newpos, uint32_t prot_key);
476
int write_data_suffix(SORT_INFO *sort_info, bool fix_datafile);
491
477
int test_if_almost_full(MI_INFO *info);
492
478
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
493
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows);
494
my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map,
479
bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, uint64_t key_map,
497
int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows);
498
void mi_flush_bulk_insert(MI_INFO *info, uint inx);
482
int mi_init_bulk_insert(MI_INFO *info, uint32_t cache_size, ha_rows rows);
483
void mi_flush_bulk_insert(MI_INFO *info, uint32_t inx);
499
484
void mi_end_bulk_insert(MI_INFO *info);
500
int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map,
485
int mi_assign_to_key_cache(MI_INFO *info, uint64_t key_map,
501
486
KEY_CACHE *key_cache);
502
487
void mi_change_key_cache(KEY_CACHE *old_key_cache,
503
488
KEY_CACHE *new_key_cache);
504
int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves);
489
int mi_preload(MI_INFO *info, uint64_t key_map, bool ignore_leaves);
506
491
#ifdef __cplusplus