|
static int | check_k_link (MI_CHECK *param, MI_INFO *info, uint nr) |
|
static int | chk_index (MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t page, uchar *buff, ha_rows *keys, ha_checksum *key_checksum, uint level) |
|
static uint | isam_key_length (MI_INFO *info, MI_KEYDEF *keyinfo) |
|
static ha_checksum | calc_checksum (ha_rows count) |
|
static int | writekeys (MI_SORT_PARAM *sort_param) |
|
static int | sort_one_index (MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pagepos, File new_file) |
|
static int | sort_key_read (MI_SORT_PARAM *sort_param, void *key) |
|
static int | sort_ft_key_read (MI_SORT_PARAM *sort_param, void *key) |
|
static int | sort_get_next_record (MI_SORT_PARAM *sort_param) |
|
static int | sort_key_cmp (void *cmp_arg, unsigned char *a, unsigned char *b) |
|
static int | sort_ft_key_write (MI_SORT_PARAM *sort_param, const void *a) |
|
static int | sort_key_write (MI_SORT_PARAM *sort_param, const void *a) |
|
static my_off_t | get_record_for_key (MI_INFO *info, MI_KEYDEF *keyinfo, const uchar *key) |
|
static int | sort_insert_key (MI_SORT_PARAM *sort_param, SORT_KEY_BLOCKS *key_block, const uchar *key, my_off_t prev_block) |
|
static int | sort_delete_record (MI_SORT_PARAM *sort_param) |
|
static SORT_KEY_BLOCKS * | alloc_key_blocks (MI_CHECK *param, uint blocks, uint buffer_length) |
|
static ha_checksum | mi_byte_checksum (const uchar *buf, uint length) |
|
static void | set_data_file_type (SORT_INFO *sort_info, MYISAM_SHARE *share) |
|
static HA_KEYSEG * | ha_find_null (HA_KEYSEG *keyseg, const uchar *a) |
|
void | myisamchk_init (MI_CHECK *param) |
|
int | chk_status (MI_CHECK *param, MI_INFO *info) |
|
int | chk_del (MI_CHECK *param, MI_INFO *info, uint test_flag) |
|
int | chk_size (MI_CHECK *param, MI_INFO *info) |
|
int | chk_key (MI_CHECK *param, MI_INFO *info) |
|
static int | chk_index_down (MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t page, uchar *buff, ha_rows *keys, ha_checksum *key_checksum, uint level) |
|
static void | mi_collect_stats_nonulls_first (HA_KEYSEG *keyseg, ulonglong *notnull, const uchar *key) |
|
static int | mi_collect_stats_nonulls_next (HA_KEYSEG *keyseg, ulonglong *notnull, uchar *prev_key, const uchar *last_key) |
|
int | chk_data_link (MI_CHECK *param, MI_INFO *info, int extend) |
|
static int | mi_drop_all_indexes (MI_CHECK *param, MI_INFO *info, bool force) |
| Drop all indexes. More...
|
|
int | mi_repair (MI_CHECK *param, MI_INFO *info, char *name, int rep_quick, bool no_copy_stat) |
|
int | movepoint (MI_INFO *info, uchar *record, my_off_t oldpos, my_off_t newpos, uint prot_key) |
|
int | flush_blocks (MI_CHECK *param, KEY_CACHE *key_cache, File file) |
|
int | mi_sort_index (MI_CHECK *param, MI_INFO *info, char *name, bool no_copy_stat) |
|
int | change_to_newfile (const char *filename, const char *old_ext, const char *new_ext, myf MyFlags) |
|
int | lock_file (MI_CHECK *param, File file, int lock_type, const char *filetype, const char *filename) |
|
int | filecopy (MI_CHECK *param, File to, File from, my_off_t start, my_off_t length, const char *type) |
|
int | mi_repair_by_sort (MI_CHECK *param, MI_INFO *info, const char *name, int rep_quick, bool no_copy_stat) |
|
int | sort_write_record (MI_SORT_PARAM *sort_param) |
|
int | sort_ft_buf_flush (MI_SORT_PARAM *sort_param) |
|
int | flush_pending_blocks (MI_SORT_PARAM *sort_param) |
|
int | test_if_almost_full (MI_INFO *info) |
|
int | recreate_table (MI_CHECK *param, MI_INFO **org_info, char *filename) |
|
int | write_data_suffix (SORT_INFO *sort_info, bool fix_datafile) |
|
int | update_state_info (MI_CHECK *param, MI_INFO *info, uint update) |
|
void | update_auto_increment_key (MI_CHECK *param, MI_INFO *info, bool repair_only) |
|
void | update_key_parts (MI_KEYDEF *keyinfo, ulong *rec_per_key_part, ulonglong *unique, ulonglong *notnull, ulonglong records) |
|
static bool | mi_too_big_key_for_sort (MI_KEYDEF *key, ha_rows rows) |
|
void | mi_disable_non_unique_index (MI_INFO *info, ha_rows rows) |
|
bool | mi_test_if_sort_rep (MI_INFO *info, ha_rows rows, ulonglong key_map, bool force) |
|
static int mi_drop_all_indexes |
( |
MI_CHECK * |
param, |
|
|
MI_INFO * |
info, |
|
|
bool |
force |
|
) |
| |
|
static |
Drop all indexes.
- Parameters
-
[in] | param | check parameters |
[in] | info | MI_INFO handle |
[in] | force | if to force drop all indexes |
- Returns
- status
- Return values
-
- Note
- Once allocated, index blocks remain part of the key file forever. When indexes are disabled, no block is freed. When enabling indexes, no block is freed either. The new indexes are create from new blocks. (Bug #4692)
Before recreating formerly disabled indexes, the unused blocks must be freed. There are two options to do this:
- Follow the tree of disabled indexes, add all blocks to the deleted blocks chain. Would require a lot of random I/O.
- Drop all blocks by clearing all index root pointers and all delete chain pointers and resetting key_file_length to the end of the index file header. This requires to recreate all indexes, even those that may still be intact. The second method is probably faster in most cases.
When disabling indexes, MySQL disables either all indexes or all non-unique indexes. When MySQL [re-]enables disabled indexes (T_CREATE_MISSING_KEYS), then we either have "lost" blocks in the index file, or there are no non-unique indexes. In the latter case, mi_repair*() would not be called as there would be no disabled indexes.
If there would be more unique indexes than disabled (non-unique) indexes, we could do the first method. But this is not implemented yet. By now we drop and recreate all indexes when repair is called.
However, there is an exception. Sometimes MySQL disables non-unique indexes when the table is empty (e.g. when copying a table in mysql_alter_table()). When enabling the non-unique indexes, they are still empty. So there is no index block that can be lost. This optimization is implemented in this function.
Note that in normal repair (T_CREATE_MISSING_KEYS not set) we recreate all enabled indexes unconditonally. We do not change the key_map. Otherwise we invert the key map temporarily (outside of this function) and recreate the then "seemingly" enabled indexes. When we cannot use the optimization, and drop all indexes, we pretend that all indexes were disabled. By the inversion, we will then recrate all indexes.