303
299
enum ha_extra_function function,
304
300
void *extra_arg);
305
301
extern int mi_reset(struct st_myisam_info *file);
306
extern ha_rows mi_records_in_range(MI_INFO *info, int inx,
302
extern ha_rows mi_records_in_range(MI_INFO *info,int inx,
307
303
key_range *min_key, key_range *max_key);
308
extern int mi_log(int activate_log);
304
/** Open/close actions allowed on a MyISAM log */
305
enum enum_mi_log_action
308
MI_LOG_ACTION_CLOSE_CONSISTENT, MI_LOG_ACTION_CLOSE_INCONSISTENT
310
enum enum_mi_log_type { MI_LOG_PHYSICAL, MI_LOG_LOGICAL };
311
extern int mi_log(enum enum_mi_log_action action, enum enum_mi_log_type type,
312
const char *log_filename, const HASH *tables);
309
313
extern int mi_is_changed(struct st_myisam_info *info);
310
314
extern int mi_delete_all_rows(struct st_myisam_info *info);
311
315
extern ulong _mi_calc_blob_length(uint length , const uchar *pos);
312
316
extern uint mi_get_pointer_length(ulonglong file_length, uint def);
314
/* this is used to pass to mysql_myisamchk_table -- by Sasha Pachev */
318
/* this is used to pass to mysql_myisamchk_table */
316
320
#define MYISAMCHK_REPAIR 1 /* equivalent to myisamchk -r */
317
321
#define MYISAMCHK_VERIFY 2 /* Verify, run repair if failure */
320
Definitions needed for myisamchk.c
322
Entries marked as "QQ to be removed" are NOT used to
323
pass check/repair options to mi_check.c. They are used
324
internally by myisamchk.c or/and ha_myisam.cc and should NOT
325
be stored together with other flags. They should be removed
326
from the following list to make addition of new flags possible.
330
#define T_AUTO_REPAIR 2 /* QQ to be removed */
331
#define T_BACKUP_DATA 4
332
#define T_CALC_CHECKSUM 8
333
#define T_CHECK 16 /* QQ to be removed */
334
#define T_CHECK_ONLY_CHANGED 32 /* QQ to be removed */
335
#define T_CREATE_MISSING_KEYS 64
336
#define T_DESCRIPT 128
337
#define T_DONT_CHECK_CHECKSUM 256
339
#define T_FAST (1L << 10) /* QQ to be removed */
340
#define T_FORCE_CREATE (1L << 11) /* QQ to be removed */
341
#define T_FORCE_UNIQUENESS (1L << 12)
342
#define T_INFO (1L << 13)
343
#define T_MEDIUM (1L << 14)
344
#define T_QUICK (1L << 15) /* QQ to be removed */
345
#define T_READONLY (1L << 16) /* QQ to be removed */
346
#define T_REP (1L << 17)
347
#define T_REP_BY_SORT (1L << 18) /* QQ to be removed */
348
#define T_REP_PARALLEL (1L << 19) /* QQ to be removed */
349
#define T_RETRY_WITHOUT_QUICK (1L << 20)
350
#define T_SAFE_REPAIR (1L << 21)
351
#define T_SILENT (1L << 22)
352
#define T_SORT_INDEX (1L << 23) /* QQ to be removed */
353
#define T_SORT_RECORDS (1L << 24) /* QQ to be removed */
354
#define T_STATISTICS (1L << 25)
355
#define T_UNPACK (1L << 26)
356
#define T_UPDATE_STATE (1L << 27)
357
#define T_VERBOSE (1L << 28)
358
#define T_VERY_SILENT (1L << 29)
359
#define T_WAIT_FOREVER (1L << 30)
360
#define T_WRITE_LOOP ((ulong) 1L << 31)
362
#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL)
365
Flags used by myisamchk.c or/and ha_myisam.cc that are NOT passed
366
to mi_check.c follows:
370
#define TT_FOR_UPGRADE 2
372
#define O_NEW_INDEX 1 /* Bits set in out_flag */
374
#define O_DATA_LOST 4
376
/* these struct is used by my_check to tell it what to do */
378
typedef struct st_sort_key_blocks /* Used when sorting */
380
uchar *buff,*end_pos;
381
uchar lastkey[MI_MAX_POSSIBLE_KEY_BUFF];
388
MyISAM supports several statistics collection methods. Currently statistics
389
collection method is not stored in MyISAM file and has to be specified for
390
each table analyze/repair operation in MI_CHECK::stats_method.
395
/* Treat NULLs as inequal when collecting statistics (default for 4.1/5.0) */
396
MI_STATS_METHOD_NULLS_NOT_EQUAL,
397
/* Treat NULLs as equal when collecting statistics (like 4.0 did) */
398
MI_STATS_METHOD_NULLS_EQUAL,
399
/* Ignore NULLs - count only tuples without NULLs in the index components */
400
MI_STATS_METHOD_IGNORE_NULLS
401
} enum_mi_stats_method;
403
typedef struct st_mi_check_param
405
ulonglong auto_increment_value;
406
ulonglong max_data_file_length;
407
ulonglong keys_in_use;
408
ulonglong max_record_length;
409
my_off_t search_after_block;
410
my_off_t new_file_pos,key_file_blocks;
411
my_off_t keydata,totaldata,key_blocks,start_check_pos;
412
ha_rows total_records,total_deleted;
413
ha_checksum record_checksum,glob_crc;
414
ulong use_buffers,read_buffer_length,write_buffer_length,
415
sort_buffer_length,sort_key_blocks;
416
uint out_flag,warning_printed,error_printed,verbose;
417
uint opt_sort_key,total_files,max_level;
418
uint testflag, key_cache_block_size;
420
my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
421
my_bool retry_repair, force_sort;
422
char temp_filename[FN_REFLEN],*isam_file_name;
323
typedef uint mi_bit_type;
325
typedef struct st_mi_bit_buff
326
{ /* Used for packing of record */
327
mi_bit_type current_byte;
329
uchar *pos, *end, *blob_pos, *blob_end;
334
typedef struct st_sort_info
338
pthread_mutex_t mutex;
344
SORT_KEY_BLOCKS *key_block, *key_block_end;
346
my_off_t filelength, dupp, buff_length;
348
uint current_key, total_keys;
349
uint got_error, threads_running;
351
enum data_file_type new_data_file_type;
354
typedef struct st_mi_sort_param
357
IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
358
DYNAMIC_ARRAY buffpek;
359
MI_BIT_BUFF bit_buff; /* For parallel repair of packrec. */
362
MI_SORT_INFO *sort_info;
366
void *wordlist, *wordptr;
423
369
MY_TMPDIR *tmpdir;
424
int tmpfile_createflag;
429
372
The next two are used to collect statistics, see update_key_parts for
432
ulonglong unique_count[MI_MAX_KEY_SEG+1];
433
ulonglong notnull_count[MI_MAX_KEY_SEG+1];
435
ha_checksum key_crc[MI_MAX_POSSIBLE_KEY];
436
ulong rec_per_key_part[MI_MAX_KEY_SEG*MI_MAX_POSSIBLE_KEY];
438
const char *db_name, *table_name;
440
enum_mi_stats_method stats_method;
443
typedef struct st_sort_ft_buf
447
uchar lastkey[MI_MAX_KEY_BUFF];
450
typedef struct st_sort_info
452
my_off_t filelength,dupp,buff_length;
454
uint current_key, total_keys;
456
enum data_file_type new_data_file_type;
460
SORT_KEY_BLOCKS *key_block,*key_block_end;
463
uint got_error, threads_running;
465
pthread_mutex_t mutex;
375
ulonglong unique[HA_MAX_KEY_SEG+1];
376
ulonglong notnull[HA_MAX_KEY_SEG+1];
378
my_off_t pos,max_pos,filepos,start_recpos;
379
uint key, key_length,real_key_length,sortbuff_size;
380
uint maxbuffers, keys, find_length, sort_keys_length;
381
my_bool fix_datafile, master;
382
my_bool calc_checksum; /* calculate table checksum */
384
int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
385
int (*key_read)(struct st_mi_sort_param *,void *);
386
int (*key_write)(struct st_mi_sort_param *, const void *);
387
void (*lock_in_memory)(HA_CHECK *);
388
NEAR int (*write_keys)(struct st_mi_sort_param *, register uchar **,
389
uint , struct st_buffpek *, IO_CACHE *);
390
NEAR uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
391
NEAR int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,uchar *,
470
396
/* functions in mi_check */
471
void myisamchk_init(MI_CHECK *param);
472
int chk_status(MI_CHECK *param, MI_INFO *info);
473
int chk_del(MI_CHECK *param, register MI_INFO *info, uint test_flag);
474
int chk_size(MI_CHECK *param, MI_INFO *info);
475
int chk_key(MI_CHECK *param, MI_INFO *info);
476
int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend);
477
int mi_repair(MI_CHECK *param, register MI_INFO *info,
397
void myisamchk_init(HA_CHECK *param);
398
int chk_status(HA_CHECK *param, MI_INFO *info);
399
int chk_del(HA_CHECK *param, register MI_INFO *info, ulonglong test_flag);
400
int chk_size(HA_CHECK *param, MI_INFO *info);
401
int chk_key(HA_CHECK *param, MI_INFO *info);
402
int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend);
403
int mi_repair(HA_CHECK *param, register MI_INFO *info,
478
404
char * name, int rep_quick);
479
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name);
480
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
405
int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name);
406
int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
481
407
const char * name, int rep_quick);
482
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
408
int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
483
409
const char * name, int rep_quick);
484
410
int change_to_newfile(const char * filename, const char * old_ext,
485
411
const char * new_ext, uint raid_chunks,
487
int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type,
413
int lock_file(HA_CHECK *param, File file, my_off_t start, int lock_type,
488
414
const char *filetype, const char *filename);
489
void lock_memory(MI_CHECK *param);
490
void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
415
void lock_memory(HA_CHECK *param);
416
void update_auto_increment_key(HA_CHECK *param, MI_INFO *info,
492
int update_state_info(MI_CHECK *param, MI_INFO *info,uint update);
418
int update_state_info(HA_CHECK *param, MI_INFO *info,uint update);
493
419
void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part,
494
420
ulonglong *unique, ulonglong *notnull,
495
421
ulonglong records);
496
int filecopy(MI_CHECK *param, File to,File from,my_off_t start,
422
int filecopy(HA_CHECK *param, File to,File from,my_off_t start,
497
423
my_off_t length, const char *type);
498
424
int movepoint(MI_INFO *info,uchar *record,my_off_t oldpos,
499
425
my_off_t newpos, uint prot_key);
500
int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile);
426
int write_data_suffix(MI_SORT_INFO *sort_info, my_bool fix_datafile);
501
427
int test_if_almost_full(MI_INFO *info);
502
int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename);
428
int recreate_table(HA_CHECK *param, MI_INFO **org_info, char *filename);
503
429
void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows);
504
430
my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map,