72
71
This means that clearing of high keys is ignored, setting one high key
73
72
sets all high keys.
75
#define MI_KEYMAP_BITS (64)
76
#define MI_KEYMAP_HIGH_MASK (1UL << (MI_KEYMAP_BITS - 1))
74
#define MI_KEYMAP_BITS (8 * SIZEOF_LONG_LONG)
75
#define MI_KEYMAP_HIGH_MASK (1ULL << (MI_KEYMAP_BITS - 1))
77
76
#define mi_get_mask_all_keys_active(_keys_) \
78
77
(((_keys_) < MI_KEYMAP_BITS) ? \
79
((1UL << (_keys_)) - 1UL) : \
78
((1ULL << (_keys_)) - 1ULL) : \
82
81
#if MI_MAX_KEY > MI_KEYMAP_BITS
84
83
#define mi_is_key_active(_keymap_,_keyno_) \
85
84
(((_keyno_) < MI_KEYMAP_BITS) ? \
86
test((_keymap_) & (1UL << (_keyno_))) : \
85
test((_keymap_) & (1ULL << (_keyno_))) : \
87
86
test((_keymap_) & MI_KEYMAP_HIGH_MASK))
88
87
#define mi_set_key_active(_keymap_,_keyno_) \
89
88
(_keymap_)|= (((_keyno_) < MI_KEYMAP_BITS) ? \
90
(1UL << (_keyno_)) : \
89
(1ULL << (_keyno_)) : \
91
90
MI_KEYMAP_HIGH_MASK)
92
91
#define mi_clear_key_active(_keymap_,_keyno_) \
93
92
(_keymap_)&= (((_keyno_) < MI_KEYMAP_BITS) ? \
94
(~ (1UL << (_keyno_))) : \
95
(~ (0UL)) /*ignore*/ )
93
(~ (1ULL << (_keyno_))) : \
94
(~ (0ULL)) /*ignore*/ )
99
98
#define mi_is_key_active(_keymap_,_keyno_) \
100
test((_keymap_) & (1UL << (_keyno_)))
99
test((_keymap_) & (1ULL << (_keyno_)))
101
100
#define mi_set_key_active(_keymap_,_keyno_) \
102
(_keymap_)|= (1UL << (_keyno_))
101
(_keymap_)|= (1ULL << (_keyno_))
103
102
#define mi_clear_key_active(_keymap_,_keyno_) \
104
(_keymap_)&= (~ (1UL << (_keyno_)))
103
(_keymap_)&= (~ (1ULL << (_keyno_)))
176
175
typedef struct st_mi_keydef /* Key definition with open & info */
178
177
struct st_mi_isam_share *share; /* Pointer to base (set in mi_open) */
179
uint16_t keysegs; /* Number of key-segment */
180
uint16_t flag; /* NOSAME, PACK_USED */
178
uint16 keysegs; /* Number of key-segment */
179
uint16 flag; /* NOSAME, PACK_USED */
182
uint8_t key_alg; /* BTREE, RTREE */
183
uint16_t block_length; /* Length of keyblock (auto) */
184
uint16_t underflow_block_length; /* When to execute underflow */
185
uint16_t keylength; /* Tot length of keyparts (auto) */
186
uint16_t minlength; /* min length of (packed) key (auto) */
187
uint16_t maxlength; /* max length of (packed) key (auto) */
188
uint16_t block_size_index; /* block_size (auto) */
189
uint32_t version; /* For concurrent read/write */
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 */
191
190
HA_KEYSEG *seg,*end;
193
192
int (*bin_search)(struct st_myisam_info *info,struct st_mi_keydef *keyinfo,
194
unsigned char *page,unsigned char *key,
195
uint32_t key_len,uint32_t comp_flag,unsigned char * *ret_pos,
196
unsigned char *buff, bool *was_last_key);
197
uint32_t (*get_key)(struct st_mi_keydef *keyinfo,uint32_t nod_flag,unsigned char * *page,
199
int (*pack_key)(struct st_mi_keydef *keyinfo,uint32_t nod_flag,unsigned char *next_key,
200
unsigned char *org_key, unsigned char *prev_key, unsigned char *key,
193
uchar *page,uchar *key,
194
uint key_len,uint comp_flag,uchar * *ret_pos,
195
uchar *buff, my_bool *was_last_key);
196
uint (*get_key)(struct st_mi_keydef *keyinfo,uint nod_flag,uchar * *page,
198
int (*pack_key)(struct st_mi_keydef *keyinfo,uint nod_flag,uchar *next_key,
199
uchar *org_key, uchar *prev_key, uchar *key,
201
200
struct st_mi_s_param *s_temp);
202
void (*store_key)(struct st_mi_keydef *keyinfo, unsigned char *key_pos,
201
void (*store_key)(struct st_mi_keydef *keyinfo, uchar *key_pos,
203
202
struct st_mi_s_param *s_temp);
204
int (*ck_insert)(struct st_myisam_info *inf, uint32_t k_nr, unsigned char *k, uint32_t klen);
205
int (*ck_delete)(struct st_myisam_info *inf, uint32_t k_nr, unsigned char *k, uint32_t klen);
203
int (*ck_insert)(struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
204
int (*ck_delete)(struct st_myisam_info *inf, uint k_nr, uchar *k, uint klen);
235
234
typedef struct st_columndef /* column information */
237
int16_t type; /* en_fieldtype */
238
uint16_t length; /* length of field */
239
uint32_t offset; /* Offset to position in row */
240
uint8_t null_bit; /* If column may be 0 */
241
uint16_t null_pos; /* position for null marker */
236
int16 type; /* en_fieldtype */
237
uint16 length; /* length of field */
238
uint32 offset; /* Offset to position in row */
239
uint8 null_bit; /* If column may be 0 */
240
uint16 null_pos; /* position for null marker */
243
242
#ifndef NOT_PACKED_DATABASES
244
243
void (*unpack)(struct st_columndef *rec,struct st_mi_bit_buff *buff,
245
unsigned char *start,unsigned char *end);
244
uchar *start,uchar *end);
246
245
enum en_fieldtype base_type;
247
uint32_t space_length_bits,pack_type;
246
uint space_length_bits,pack_type;
248
247
MI_DECODE_TREE *huff_tree;
253
252
extern char * myisam_log_filename; /* Name of logfile */
254
extern uint32_t myisam_block_size;
255
extern uint32_t myisam_concurrent_insert;
256
extern uint32_t myisam_bulk_insert_tree_size;
257
extern uint32_t data_pointer_size;
253
extern ulong myisam_block_size;
254
extern ulong myisam_concurrent_insert;
255
extern bool myisam_flush,myisam_delay_key_write,myisam_single_user;
256
extern my_off_t myisam_max_temp_length;
257
extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size;
259
259
/* Prototypes for myisam-functions */
261
261
extern int mi_close(struct st_myisam_info *file);
262
extern int mi_delete(struct st_myisam_info *file,const unsigned char *buff);
262
extern int mi_delete(struct st_myisam_info *file,const uchar *buff);
263
263
extern struct st_myisam_info *mi_open(const char *name,int mode,
264
uint32_t wait_if_locked);
264
uint wait_if_locked);
265
265
extern int mi_panic(enum ha_panic_function function);
266
extern int mi_rfirst(struct st_myisam_info *file,unsigned char *buf,int inx);
267
extern int mi_rkey(MI_INFO *info, unsigned char *buf, int inx, const unsigned char *key,
266
extern int mi_rfirst(struct st_myisam_info *file,uchar *buf,int inx);
267
extern int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key,
268
268
key_part_map keypart_map, enum ha_rkey_function search_flag);
269
extern int mi_rlast(struct st_myisam_info *file,unsigned char *buf,int inx);
270
extern int mi_rnext(struct st_myisam_info *file,unsigned char *buf,int inx);
271
extern int mi_rnext_same(struct st_myisam_info *info, unsigned char *buf);
272
extern int mi_rprev(struct st_myisam_info *file,unsigned char *buf,int inx);
273
extern int mi_rrnd(struct st_myisam_info *file,unsigned char *buf, my_off_t pos);
269
extern int mi_rlast(struct st_myisam_info *file,uchar *buf,int inx);
270
extern int mi_rnext(struct st_myisam_info *file,uchar *buf,int inx);
271
extern int mi_rnext_same(struct st_myisam_info *info, uchar *buf);
272
extern int mi_rprev(struct st_myisam_info *file,uchar *buf,int inx);
273
extern int mi_rrnd(struct st_myisam_info *file,uchar *buf, my_off_t pos);
274
274
extern int mi_scan_init(struct st_myisam_info *file);
275
extern int mi_scan(struct st_myisam_info *file,unsigned char *buf);
276
extern int mi_rsame(struct st_myisam_info *file,unsigned char *record,int inx);
277
extern int mi_rsame_with_pos(struct st_myisam_info *file,unsigned char *record,
275
extern int mi_scan(struct st_myisam_info *file,uchar *buf);
276
extern int mi_rsame(struct st_myisam_info *file,uchar *record,int inx);
277
extern int mi_rsame_with_pos(struct st_myisam_info *file,uchar *record,
278
278
int inx, my_off_t pos);
279
extern int mi_update(struct st_myisam_info *file,const unsigned char *old,
280
unsigned char *new_record);
281
extern int mi_write(struct st_myisam_info *file,unsigned char *buff);
279
extern int mi_update(struct st_myisam_info *file,const uchar *old,
281
extern int mi_write(struct st_myisam_info *file,uchar *buff);
282
282
extern my_off_t mi_position(struct st_myisam_info *file);
283
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint32_t flag);
283
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint flag);
284
284
extern int mi_lock_database(struct st_myisam_info *file,int lock_type);
285
extern int mi_create(const char *name,uint32_t keys,MI_KEYDEF *keydef,
286
uint32_t columns, MI_COLUMNDEF *columndef,
287
uint32_t uniques, MI_UNIQUEDEF *uniquedef,
288
MI_CREATE_INFO *create_info, uint32_t flags);
285
extern int mi_create(const char *name,uint keys,MI_KEYDEF *keydef,
286
uint columns, MI_COLUMNDEF *columndef,
287
uint uniques, MI_UNIQUEDEF *uniquedef,
288
MI_CREATE_INFO *create_info, uint flags);
289
289
extern int mi_delete_table(const char *name);
290
290
extern int mi_rename(const char *from, const char *to);
291
291
extern int mi_extra(struct st_myisam_info *file,
392
400
my_off_t keydata,totaldata,key_blocks,start_check_pos;
393
401
ha_rows total_records,total_deleted;
394
402
ha_checksum record_checksum,glob_crc;
395
uint64_t use_buffers;
396
size_t read_buffer_length, write_buffer_length,
397
sort_buffer_length, sort_key_blocks;
398
uint32_t out_flag,warning_printed,error_printed,verbose;
399
uint32_t opt_sort_key,total_files,max_level;
400
uint32_t testflag, key_cache_block_size;
402
bool using_global_keycache, opt_lock_memory, opt_follow_links;
403
bool retry_repair, force_sort;
403
ulong use_buffers,read_buffer_length,write_buffer_length,
404
sort_buffer_length,sort_key_blocks;
405
uint out_flag,warning_printed,error_printed,verbose;
406
uint opt_sort_key,total_files,max_level;
407
uint testflag, key_cache_block_size;
409
my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
410
my_bool retry_repair, force_sort;
404
411
char temp_filename[FN_REFLEN],*isam_file_name;
405
413
int tmpfile_createflag;
407
415
IO_CACHE read_cache;
410
418
The next two are used to collect statistics, see update_key_parts for
413
421
uint64_t unique_count[MI_MAX_KEY_SEG+1];
414
422
uint64_t notnull_count[MI_MAX_KEY_SEG+1];
416
424
ha_checksum key_crc[HA_MAX_POSSIBLE_KEY];
417
425
ulong rec_per_key_part[MI_MAX_KEY_SEG*HA_MAX_POSSIBLE_KEY];
419
427
const char *db_name, *table_name;
420
428
const char *op_name;
421
429
enum_mi_stats_method stats_method;
453
461
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
454
462
const char * name, int rep_quick);
455
463
int change_to_newfile(const char * filename, const char * old_ext,
456
const char * new_ext, uint32_t raid_chunks,
464
const char * new_ext, uint raid_chunks,
458
466
void lock_memory(MI_CHECK *param);
459
467
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
461
int update_state_info(MI_CHECK *param, MI_INFO *info,uint32_t update);
469
int update_state_info(MI_CHECK *param, MI_INFO *info,uint update);
462
470
void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part,
463
uint64_t *unique, uint64_t *notnull,
471
uint64_t *unique, uint64_t *notnull,
464
472
uint64_t records);
465
473
int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
466
474
my_off_t length, const char *type);
467
int movepoint(MI_INFO *info,unsigned char *record,my_off_t oldpos,
468
my_off_t newpos, uint32_t prot_key);
469
int write_data_suffix(SORT_INFO *sort_info, bool fix_datafile);
475
int movepoint(MI_INFO *info,uchar *record,my_off_t oldpos,
476
my_off_t newpos, uint prot_key);
477
int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile);
470
478
int test_if_almost_full(MI_INFO *info);
471
479
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
472
bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, uint64_t key_map,
480
my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, uint64_t key_map,
475
int mi_init_bulk_insert(MI_INFO *info, uint32_t cache_size, ha_rows rows);
476
void mi_flush_bulk_insert(MI_INFO *info, uint32_t inx);
483
int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows);
484
void mi_flush_bulk_insert(MI_INFO *info, uint inx);
477
485
void mi_end_bulk_insert(MI_INFO *info);
478
int mi_assign_to_key_cache(MI_INFO *info, KEY_CACHE *key_cache);
486
int mi_assign_to_key_cache(MI_INFO *info, uint64_t key_map,
487
KEY_CACHE *key_cache);
479
488
void mi_change_key_cache(KEY_CACHE *old_key_cache,
480
489
KEY_CACHE *new_key_cache);
481
int mi_preload(MI_INFO *info, uint64_t key_map, bool ignore_leaves);
490
int mi_preload(MI_INFO *info, uint64_t key_map, my_bool ignore_leaves);
483
492
#ifdef __cplusplus