70
71
This means that clearing of high keys is ignored, setting one high key
71
72
sets all high keys.
73
#define MI_KEYMAP_BITS (64)
74
#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))
75
76
#define mi_get_mask_all_keys_active(_keys_) \
76
77
(((_keys_) < MI_KEYMAP_BITS) ? \
77
((1UL << (_keys_)) - 1UL) : \
78
((1ULL << (_keys_)) - 1ULL) : \
80
81
#if MI_MAX_KEY > MI_KEYMAP_BITS
82
83
#define mi_is_key_active(_keymap_,_keyno_) \
83
84
(((_keyno_) < MI_KEYMAP_BITS) ? \
84
test((_keymap_) & (1UL << (_keyno_))) : \
85
test((_keymap_) & (1ULL << (_keyno_))) : \
85
86
test((_keymap_) & MI_KEYMAP_HIGH_MASK))
86
87
#define mi_set_key_active(_keymap_,_keyno_) \
87
88
(_keymap_)|= (((_keyno_) < MI_KEYMAP_BITS) ? \
88
(1UL << (_keyno_)) : \
89
(1ULL << (_keyno_)) : \
89
90
MI_KEYMAP_HIGH_MASK)
90
91
#define mi_clear_key_active(_keymap_,_keyno_) \
91
92
(_keymap_)&= (((_keyno_) < MI_KEYMAP_BITS) ? \
92
(~ (1UL << (_keyno_))) : \
93
(~ (0UL)) /*ignore*/ )
93
(~ (1ULL << (_keyno_))) : \
94
(~ (0ULL)) /*ignore*/ )
97
98
#define mi_is_key_active(_keymap_,_keyno_) \
98
test((_keymap_) & (1UL << (_keyno_)))
99
test((_keymap_) & (1ULL << (_keyno_)))
99
100
#define mi_set_key_active(_keymap_,_keyno_) \
100
(_keymap_)|= (1UL << (_keyno_))
101
(_keymap_)|= (1ULL << (_keyno_))
101
102
#define mi_clear_key_active(_keymap_,_keyno_) \
102
(_keymap_)&= (~ (1UL << (_keyno_)))
103
(_keymap_)&= (~ (1ULL << (_keyno_)))
174
175
typedef struct st_mi_keydef /* Key definition with open & info */
176
177
struct st_mi_isam_share *share; /* Pointer to base (set in mi_open) */
177
uint16_t keysegs; /* Number of key-segment */
178
uint16_t flag; /* NOSAME, PACK_USED */
178
uint16 keysegs; /* Number of key-segment */
179
uint16 flag; /* NOSAME, PACK_USED */
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 */
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 */
189
191
HA_KEYSEG *seg,*end;
192
struct st_mysql_ftparser *parser; /* Fulltext [pre]parser */
191
193
int (*bin_search)(struct st_myisam_info *info,struct st_mi_keydef *keyinfo,
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,
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,
199
201
struct st_mi_s_param *s_temp);
200
void (*store_key)(struct st_mi_keydef *keyinfo, unsigned char *key_pos,
202
void (*store_key)(struct st_mi_keydef *keyinfo, uchar *key_pos,
201
203
struct st_mi_s_param *s_temp);
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);
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);
233
235
typedef struct st_columndef /* column information */
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 */
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 */
241
243
#ifndef NOT_PACKED_DATABASES
242
244
void (*unpack)(struct st_columndef *rec,struct st_mi_bit_buff *buff,
243
unsigned char *start,unsigned char *end);
245
uchar *start,uchar *end);
244
246
enum en_fieldtype base_type;
245
uint32_t space_length_bits,pack_type;
247
uint space_length_bits,pack_type;
246
248
MI_DECODE_TREE *huff_tree;
251
253
extern char * myisam_log_filename; /* Name of logfile */
252
extern uint32_t myisam_block_size;
253
extern uint32_t myisam_concurrent_insert;
254
extern ulong myisam_block_size;
255
extern ulong myisam_concurrent_insert;
254
256
extern bool myisam_flush,myisam_delay_key_write,myisam_single_user;
255
257
extern my_off_t myisam_max_temp_length;
256
extern uint32_t myisam_bulk_insert_tree_size, myisam_data_pointer_size;
258
extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size;
258
260
/* Prototypes for myisam-functions */
260
262
extern int mi_close(struct st_myisam_info *file);
261
extern int mi_delete(struct st_myisam_info *file,const unsigned char *buff);
263
extern int mi_delete(struct st_myisam_info *file,const uchar *buff);
262
264
extern struct st_myisam_info *mi_open(const char *name,int mode,
263
uint32_t wait_if_locked);
265
uint wait_if_locked);
264
266
extern int mi_panic(enum ha_panic_function function);
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,
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,
267
269
key_part_map keypart_map, enum ha_rkey_function search_flag);
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);
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);
273
275
extern int mi_scan_init(struct st_myisam_info *file);
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,
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,
277
279
int inx, my_off_t pos);
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);
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);
281
283
extern my_off_t mi_position(struct st_myisam_info *file);
282
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint32_t flag);
284
extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint flag);
283
285
extern int mi_lock_database(struct st_myisam_info *file,int lock_type);
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);
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);
288
290
extern int mi_delete_table(const char *name);
289
291
extern int mi_rename(const char *from, const char *to);
290
292
extern int mi_extra(struct st_myisam_info *file,
401
403
ha_checksum record_checksum,glob_crc;
402
404
ulong use_buffers,read_buffer_length,write_buffer_length,
403
405
sort_buffer_length,sort_key_blocks;
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;
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;
410
412
char temp_filename[FN_REFLEN],*isam_file_name;
411
413
MY_TMPDIR *tmpdir;
412
414
int tmpfile_createflag;
460
470
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
461
471
const char * name, int rep_quick);
462
472
int change_to_newfile(const char * filename, const char * old_ext,
463
const char * new_ext, uint32_t raid_chunks,
473
const char * new_ext, uint raid_chunks,
465
475
void lock_memory(MI_CHECK *param);
466
476
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
468
int update_state_info(MI_CHECK *param, MI_INFO *info,uint32_t update);
478
int update_state_info(MI_CHECK *param, MI_INFO *info,uint update);
469
479
void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part,
470
480
uint64_t *unique, uint64_t *notnull,
471
481
uint64_t records);
472
482
int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
473
483
my_off_t length, const char *type);
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);
484
int movepoint(MI_INFO *info,uchar *record,my_off_t oldpos,
485
my_off_t newpos, uint prot_key);
486
int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile);
477
487
int test_if_almost_full(MI_INFO *info);
478
488
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
479
bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, uint64_t key_map,
489
my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, uint64_t key_map,
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);
492
int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows);
493
void mi_flush_bulk_insert(MI_INFO *info, uint inx);
484
494
void mi_end_bulk_insert(MI_INFO *info);
485
495
int mi_assign_to_key_cache(MI_INFO *info, uint64_t key_map,
486
496
KEY_CACHE *key_cache);
487
497
void mi_change_key_cache(KEY_CACHE *old_key_cache,
488
498
KEY_CACHE *new_key_cache);
489
int mi_preload(MI_INFO *info, uint64_t key_map, bool ignore_leaves);
499
int mi_preload(MI_INFO *info, uint64_t key_map, my_bool ignore_leaves);
491
501
#ifdef __cplusplus