Commit 1a647905 authored by unknown's avatar unknown

mi_check T_xxx options massaged. T_REP_PARALLEL added

my_getopt-related style changes in myisamchk.c


include/myisam.h:
  mi_check T_xxx options massaged. T_REP_PARALLEL added
myisam/mi_check.c:
  mi_check T_xxx options massaged
myisam/myisamchk.c:
  mi_check T_xxx options massaged
  my_long_option structure reformatted
  s/(argument && \*argument=='0')/(argument == disable_my_option)/
sql/ha_myisam.cc:
  mi_check T_xxx options massaged
parent dec74d08
...@@ -258,45 +258,47 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def); ...@@ -258,45 +258,47 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def);
/* /*
Definitions needed for myisamchk.c Definitions needed for myisamchk.c
Entries marked as "QQ to be removed" are NOT used to Entries marked as "QQ to be removed" are NOT used to
pass check/repair options to mi_check.c. They are used pass check/repair options to mi_check.c. They are used
internally by myisamchk.c or/and ha_myisam.cc and should NOT internally by myisamchk.c or/and ha_myisam.cc and should NOT
be stored together with other flags. They should be removed be stored together with other flags. They should be removed
from the following list to make adding of new flags possible. from the following list to make addition of new flags possible.
*/ */
#define T_VERBOSE 1 #define T_AUTO_INC 1
#define T_SILENT 2 #define T_AUTO_REPAIR 2 /* QQ to be removed */
#define T_DESCRIPT 4 #define T_BACKUP_DATA 4
#define T_EXTEND 8 #define T_CALC_CHECKSUM 8
#define T_INFO 16 #define T_CHECK 16 /* QQ to be removed */
#define T_REP 32 #define T_CHECK_ONLY_CHANGED 32 /* QQ to be removed */
#define T_FORCE_UNIQUENESS 64 #define T_CREATE_MISSING_KEYS 64
#define T_FORCE_CREATE 128 #define T_DESCRIPT 128
#define T_WRITE_LOOP 256 #define T_DONT_CHECK_CHECKSUM 256
#define T_UNPACK 512 #define T_EXTEND 512
#define T_STATISTICS (1L << 10) #define T_FAST (1L << 10) /* QQ to be removed */
#define T_VERY_SILENT (1L << 11) #define T_FORCE_CREATE (1L << 11) /* QQ to be removed */
#define T_SORT_RECORDS (1L << 12) /* QQ to be removed */ #define T_FORCE_UNIQUENESS (1L << 12)
#define T_SORT_INDEX (1L << 13) /* QQ to be removed */ #define T_INFO (1L << 13)
#define T_WAIT_FOREVER (1L << 14) #define T_MEDIUM (1L << 14)
#define T_REP_BY_SORT (1L << 15) #define T_QUICK (1L << 15) /* QQ to be removed */
#define T_FAST (1L << 16) /* QQ to be removed */ #define T_READONLY (1L << 16) /* QQ to be removed */
#define T_READONLY (1L << 17) /* QQ to be removed */ #define T_REP (1L << 17)
#define T_MEDIUM (1L << 18) #define T_REP_BY_SORT (1L << 18) /* QQ to be removed */
#define T_AUTO_INC (1L << 19) #define T_REP_PARALLEL (1L << 19) /* QQ to be removed */
#define T_CHECK (1L << 20) /* QQ to be removed */ #define T_RETRY_WITHOUT_QUICK (1L << 20)
#define T_UPDATE_STATE (1L << 21) #define T_SAFE_REPAIR (1L << 21)
#define T_CHECK_ONLY_CHANGED (1L << 22) /* QQ to be removed */ #define T_SILENT (1L << 22)
#define T_DONT_CHECK_CHECKSUM (1L << 23) #define T_SORT_INDEX (1L << 23) /* QQ to be removed */
#define T_TRUST_HEADER (1L << 24) #define T_SORT_RECORDS (1L << 24) /* QQ to be removed */
#define T_CREATE_MISSING_KEYS (1L << 25) #define T_STATISTICS (1L << 25)
#define T_SAFE_REPAIR (1L << 26) #define T_UNPACK (1L << 26)
#define T_AUTO_REPAIR (1L << 27) /* QQ to be removed */ #define T_UPDATE_STATE (1L << 27)
#define T_BACKUP_DATA (1L << 28) #define T_VERBOSE (1L << 28)
#define T_CALC_CHECKSUM (1L << 29) #define T_VERY_SILENT (1L << 29)
#define T_QUICK (1L << 30) #define T_WAIT_FOREVER (1L << 30)
#define T_RETRY_WITHOUT_QUICK (1L << 31) #define T_WRITE_LOOP (1L << 31)
#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL)
/* /*
Flags used by myisamchk.c or/and ha_myisam.cc that are NOT passed Flags used by myisamchk.c or/and ha_myisam.cc that are NOT passed
......
...@@ -1125,6 +1125,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, ...@@ -1125,6 +1125,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
printf("- recovering (with keycache) MyISAM-table '%s'\n",name); printf("- recovering (with keycache) MyISAM-table '%s'\n",name);
printf("Data records: %s\n", llstr(info->state->records,llbuff)); printf("Data records: %s\n", llstr(info->state->records,llbuff));
} }
param->testflag|=T_REP; /* for easy checking */
if (!param->using_global_keycache) if (!param->using_global_keycache)
VOID(init_key_cache(param->use_buffers,NEED_MEM)); VOID(init_key_cache(param->use_buffers,NEED_MEM));
...@@ -1767,6 +1768,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -1767,6 +1768,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
printf("- recovering (with sort) MyISAM-table '%s'\n",name); printf("- recovering (with sort) MyISAM-table '%s'\n",name);
printf("Data records: %s\n", llstr(start_records,llbuff)); printf("Data records: %s\n", llstr(start_records,llbuff));
} }
param->testflag|=T_REP; /* for easy checking */
bzero((char*)&sort_info,sizeof(sort_info)); bzero((char*)&sort_info,sizeof(sort_info));
if (!(sort_info.key_block= if (!(sort_info.key_block=
...@@ -1863,7 +1865,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -1863,7 +1865,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
else else
length=share->base.pack_reclength; length=share->base.pack_reclength;
sort_info.max_records= sort_info.max_records=
((param->testflag & T_TRUST_HEADER) ? info->state->records : ((param->testflag & T_CREATE_MISSING_KEYS) ? info->state->records :
(ha_rows) (sort_info.filelength/length+1)); (ha_rows) (sort_info.filelength/length+1));
sort_param.key_cmp=sort_key_cmp; sort_param.key_cmp=sort_key_cmp;
sort_param.key_write=sort_key_write; sort_param.key_write=sort_key_write;
...@@ -2109,6 +2111,7 @@ int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info, ...@@ -2109,6 +2111,7 @@ int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info,
printf("- parallel recovering (with sort) MyISAM-table '%s'\n",name); printf("- parallel recovering (with sort) MyISAM-table '%s'\n",name);
printf("Data records: %s\n", llstr(start_records,llbuff)); printf("Data records: %s\n", llstr(start_records,llbuff));
} }
param->testflag|=T_REP; /* for easy checking */
bzero((char*)&sort_info,sizeof(sort_info)); bzero((char*)&sort_info,sizeof(sort_info));
if (!(sort_info.key_block= if (!(sort_info.key_block=
...@@ -2196,7 +2199,7 @@ int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info, ...@@ -2196,7 +2199,7 @@ int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info,
else else
length=share->base.pack_reclength; length=share->base.pack_reclength;
sort_info.max_records= sort_info.max_records=
((param->testflag & T_TRUST_HEADER) ? info->state->records : ((param->testflag & T_CREATE_MISSING_KEYS) ? info->state->records :
(ha_rows) (sort_info.filelength/length+1)); (ha_rows) (sort_info.filelength/length+1));
del=info->state->del; del=info->state->del;
...@@ -3528,7 +3531,7 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, ...@@ -3528,7 +3531,7 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
return; return;
} }
if (!(param->testflag & T_SILENT) && if (!(param->testflag & T_SILENT) &&
!(param->testflag & (T_REP | T_REP_BY_SORT))) !(param->testflag & T_REP))
printf("Updating MyISAM file: %s\n", param->isam_file_name); printf("Updating MyISAM file: %s\n", param->isam_file_name);
/* We have to use keyread here as a normal read uses info->rec_buff */ /* We have to use keyread here as a normal read uses info->rec_buff */
mi_extra(info,HA_EXTRA_KEYREAD); mi_extra(info,HA_EXTRA_KEYREAD);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Descript, check and repair of ISAM tables */ /* Describe, check and repair of MyISAM tables */
#include "fulltext.h" #include "fulltext.h"
...@@ -69,11 +69,9 @@ static void print_version(void); ...@@ -69,11 +69,9 @@ static void print_version(void);
static void usage(void); static void usage(void);
static int myisamchk(MI_CHECK *param, char *filename); static int myisamchk(MI_CHECK *param, char *filename);
static void descript(MI_CHECK *param, register MI_INFO *info, my_string name); static void descript(MI_CHECK *param, register MI_INFO *info, my_string name);
static int mi_sort_records(MI_CHECK *param, static int mi_sort_records(MI_CHECK *param, register MI_INFO *info,
register MI_INFO *info, my_string name, my_string name, uint sort_key,
uint sort_key, my_bool write_info, my_bool update_index);
my_bool write_info,
my_bool update_index);
static int sort_record_index(MI_SORT_PARAM *sort_param,MI_INFO *info, static int sort_record_index(MI_SORT_PARAM *sort_param,MI_INFO *info,
MI_KEYDEF *keyinfo, MI_KEYDEF *keyinfo,
my_off_t page,uchar *buff,uint sortkey, my_off_t page,uchar *buff,uint sortkey,
...@@ -101,12 +99,13 @@ int main(int argc, char **argv) ...@@ -101,12 +99,13 @@ int main(int argc, char **argv)
while (--argc >= 0) while (--argc >= 0)
{ {
int new_error=myisamchk(&check_param, *(argv++)); int new_error=myisamchk(&check_param, *(argv++));
if (check_param.testflag & T_REP_ANY != T_REP)
check_param.testflag&= ~T_REP;
VOID(fflush(stdout)); VOID(fflush(stdout));
VOID(fflush(stderr)); VOID(fflush(stderr));
if ((check_param.error_printed | check_param.warning_printed) && if ((check_param.error_printed | check_param.warning_printed) &&
(check_param.testflag & T_FORCE_CREATE) && (check_param.testflag & T_FORCE_CREATE) &&
(!(check_param.testflag & (T_REP | T_REP_BY_SORT | T_SORT_RECORDS | (!(check_param.testflag & (T_REP | T_SORT_RECORDS | T_SORT_INDEX))))
T_SORT_INDEX))))
{ {
uint old_testflag=check_param.testflag; uint old_testflag=check_param.testflag;
if (!(check_param.testflag & T_REP)) if (!(check_param.testflag & T_REP))
...@@ -153,124 +152,143 @@ enum options { ...@@ -153,124 +152,143 @@ enum options {
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
{ {
{"analyze", 'a', {"analyze", 'a',
"Analyze distribution of keys. Will make some joins in MySQL faster. You can check the calculated distribution.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, "Analyze distribution of keys. Will make some joins in MySQL faster. You can check the calculated distribution.",
0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"block-search", 'b', "No help available.", 0, 0, 0, GET_ULONG, REQUIRED_ARG, {"block-search", 'b',
0, 0, 0, 0, 0, 0}, "No help available.",
{"backup", 'B', "Make a backup of the .MYD file as 'filename-time.BAK'", 0, 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"backup", 'B',
"Make a backup of the .MYD file as 'filename-time.BAK'",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR, {"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", (gptr*) &set_charset_name, 0, 0, "Directory where character sets are.",
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &set_charset_name, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, {"check", 'c',
0, 0, 0, 0}, "Check table for errors.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"check-only-changed", 'C', {"check-only-changed", 'C',
"Check only tables that have changed since last check.", 0, 0, 0, GET_NO_ARG, "Check only tables that have changed since last check.",
NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"correct-checksum", OPT_CORRECT_CHECKSUM, {"correct-checksum", OPT_CORRECT_CHECKSUM,
"Correct checksum information for table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, "Correct checksum information for table.",
0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifndef DBUG_OFF #ifndef DBUG_OFF
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, {"debug", '#',
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, "Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"description", 'd', "Prints some information about table.", 0, 0, 0, {"description", 'd',
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, "Prints some information about table.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"data-file-length", 'D', {"data-file-length", 'D',
"Max length of data file (when recreating data-file when it's full).", "Max length of data file (when recreating data-file when it's full).",
(gptr*) &check_param.max_data_file_length, (gptr*) &check_param.max_data_file_length,
(gptr*) &check_param.max_data_file_length, 0, GET_LL, REQUIRED_ARG, (gptr*) &check_param.max_data_file_length,
0, 0, 0, 0, 0, 0}, 0, GET_LL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"extend-check", 'e', {"extend-check", 'e',
"Try to recover every possible row from the data file. Normally this will also find a lot of garbage rows; Don't use this option if you are not totally desperate.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, "Try to recover every possible row from the data file. Normally this will also find a lot of garbage rows; Don't use this option if you are not totally desperate.",
{"fast", 'F', "Check only tables that haven't been closed properly.", 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"fast", 'F',
"Check only tables that haven't been closed properly.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f', {"force", 'f',
"Restart with -r if there are any errors in the table. States will be updated as with --update-state.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, "Restart with -r if there are any errors in the table. States will be updated as with --update-state.",
0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, {"help", '?',
0, 0, 0, 0, 0}, "Display this help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"information", 'i', {"information", 'i',
"Print statistics information about table that is checked.", 0, 0, 0, "Print statistics information about table that is checked.",
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"keys-used", 'k', {"keys-used", 'k',
"Tell MyISAM to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts!", "Tell MyISAM to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts!",
(gptr*) &check_param.keys_in_use, (gptr*) &check_param.keys_in_use, 0, (gptr*) &check_param.keys_in_use,
GET_ULL, REQUIRED_ARG, -1, 0, 0, 0, 0, 0}, (gptr*) &check_param.keys_in_use,
0, GET_ULL, REQUIRED_ARG, -1, 0, 0, 0, 0, 0},
{"medium-check", 'm', {"medium-check", 'm',
"Faster than extended-check, but only finds 99.99% of all errors. Should be good enough for most cases.", "Faster than extended-check, but only finds 99.99% of all errors. Should be good enough for most cases.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"quick", 'q', "Faster repair by not modifying the data file.", 0, 0, 0, {"quick", 'q', "Faster repair by not modifying the data file.",
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"read-only", 'T', "Don't mark table as checked.", 0, 0, 0, GET_NO_ARG, {"read-only", 'T',
NO_ARG, 0, 0, 0, 0, 0, 0}, "Don't mark table as checked.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"recover", 'r', {"recover", 'r',
"Can fix almost anything except unique keys that aren't unique.", 0, 0, 0, "Can fix almost anything except unique keys that aren't unique.",
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"safe-recover", 'o', {"safe-recover", 'o',
"Uses old recovery method; Slower than '-r' but can handle a couple of cases where '-r' reports that it can't fix the data file.", 0, 0, 0, GET_NO_ARG, "Uses old recovery method; Slower than '-r' but can handle a couple of cases where '-r' reports that it can't fix the data file.",
NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"start-check-pos", OPT_START_CHECK_POS, "No help available.", 0, 0, 0, {"start-check-pos", OPT_START_CHECK_POS,
GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, "No help available.",
0, 0, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"set-auto-increment", 'A', {"set-auto-increment", 'A',
"Force auto_increment to start at this or higher value. If no value is given, then sets the next auto_increment value to the highest used value for the auto key + 1.", (gptr*) &check_param.auto_increment_value, "Force auto_increment to start at this or higher value. If no value is given, then sets the next auto_increment value to the highest used value for the auto key + 1.",
(gptr*) &check_param.auto_increment_value, 0, GET_ULL, OPT_ARG, 0, 0, 0, (gptr*) &check_param.auto_increment_value,
0, 0, 0}, (gptr*) &check_param.auto_increment_value,
0, GET_ULL, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"set-character-set", OPT_SET_CHARSET, {"set-character-set", OPT_SET_CHARSET,
"Change the character set used by the index", 0, 0, 0, GET_STR, "Change the character set used by the index",
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"set-variable", 'O', {"set-variable", 'O',
"Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', {"silent", 's',
"Only print errors. One can use two -s to make myisamchk very silent.", 0, "Only print errors. One can use two -s to make myisamchk very silent.",
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"sort-index", 'S', {"sort-index", 'S',
"Sort index blocks. This speeds up 'read-next' in applications.", 0, 0, 0, "Sort index blocks. This speeds up 'read-next' in applications.",
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"sort-records", 'R', {"sort-records", 'R',
"Sort records according to an index. This makes your data much more localized and may speed up things. (It may be VERY slow to do a sort the first time!)", "Sort records according to an index. This makes your data much more localized and may speed up things. (It may be VERY slow to do a sort the first time!)",
(gptr*) &check_param.opt_sort_key, (gptr*) &check_param.opt_sort_key, 0, (gptr*) &check_param.opt_sort_key,
GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &check_param.opt_sort_key,
0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"sort-recover", 'n', {"sort-recover", 'n',
"Force recovering with sorting even if the temporary file was very big.", "Force recovering with sorting even if the temporary file was very big.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"tmpdir", 't', "Path for temporary files.", {"tmpdir", 't',
(gptr*) &check_param.tmpdir, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, "Path for temporary files.",
{"update-state", 'U', "Mark tables as crashed if any errors were found.", 0, (gptr*) &check_param.tmpdir,
0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"unpack", 'u', "Unpack file packed with myisampack.", 0, 0, 0, GET_NO_ARG, {"update-state", 'U',
NO_ARG, 0, 0, 0, 0, 0, 0}, "Mark tables as crashed if any errors were found.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"unpack", 'u',
"Unpack file packed with myisampack.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', {"verbose", 'v',
"Print more information. This can be used with --describe and --check. Use many -v for more verbosity!", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, "Print more information. This can be used with --describe and --check. Use many -v for more verbosity!",
0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, {"version", 'V',
0, 0, 0, 0, 0}, "Print version and exit.",
{"wait", 'w', "Wait if table is locked.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
0, 0, 0, 0}, {"wait", 'w',
"Wait if table is locked.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "key_buffer_size", OPT_KEY_BUFFER_SIZE, "", { "key_buffer_size", OPT_KEY_BUFFER_SIZE, "",
(gptr*) &check_param.use_buffers, (gptr*) &check_param.use_buffers, 0, (gptr*) &check_param.use_buffers, (gptr*) &check_param.use_buffers, 0,
GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD, GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD,
(long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0}, (long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0},
{ "myisam_block_size", OPT_MYISAM_BLOCK_SIZE, "", { "myisam_block_size", OPT_MYISAM_BLOCK_SIZE, "",
(gptr*) &opt_myisam_block_size, (gptr*) &opt_myisam_block_size, 0, (gptr*) &opt_myisam_block_size, (gptr*) &opt_myisam_block_size, 0,
GET_LONG, REQUIRED_ARG, MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, GET_LONG, REQUIRED_ARG, MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH,
MI_MAX_KEY_BLOCK_LENGTH, 0, MI_MIN_KEY_BLOCK_LENGTH, 0}, MI_MAX_KEY_BLOCK_LENGTH, 0, MI_MIN_KEY_BLOCK_LENGTH, 0},
{ "read_buffer_size", OPT_READ_BUFFER_SIZE, "", { "read_buffer_size", OPT_READ_BUFFER_SIZE, "",
(gptr*) &check_param.read_buffer_length, (gptr*) &check_param.read_buffer_length,
(gptr*) &check_param.read_buffer_length, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &check_param.read_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
(long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD, (long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD,
(long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0}, (long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0},
{ "write_buffer_size", OPT_WRITE_BUFFER_SIZE, "", { "write_buffer_size", OPT_WRITE_BUFFER_SIZE, "",
(gptr*) &check_param.write_buffer_length, (gptr*) &check_param.write_buffer_length,
(gptr*) &check_param.write_buffer_length, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &check_param.write_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
(long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD, (long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD,
(long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0}, (long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0},
{ "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "", { "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "",
(gptr*) &check_param.sort_buffer_length, (gptr*) &check_param.sort_buffer_length,
(gptr*) &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
(long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), (long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD),
(long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0}, (long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0},
{ "sort_key_blocks", OPT_SORT_KEY_BLOCKS, "", { "sort_key_blocks", OPT_SORT_KEY_BLOCKS, "",
(gptr*) &check_param.sort_key_blocks, (gptr*) &check_param.sort_key_blocks,
(gptr*) &check_param.sort_key_blocks, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &check_param.sort_key_blocks, 0, GET_ULONG, REQUIRED_ARG,
...@@ -393,7 +411,7 @@ get_one_option(int optid, ...@@ -393,7 +411,7 @@ get_one_option(int optid,
{ {
switch (optid) { switch (optid) {
case 'a': case 'a':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_STATISTICS; check_param.testflag&= ~T_STATISTICS;
else else
check_param.testflag|= T_STATISTICS; check_param.testflag|= T_STATISTICS;
...@@ -409,19 +427,19 @@ get_one_option(int optid, ...@@ -409,19 +427,19 @@ get_one_option(int optid,
check_param.search_after_block= strtoul(argument, NULL, 10); check_param.search_after_block= strtoul(argument, NULL, 10);
break; break;
case 'B': case 'B':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_BACKUP_DATA; check_param.testflag&= ~T_BACKUP_DATA;
else else
check_param.testflag|= T_BACKUP_DATA; check_param.testflag|= T_BACKUP_DATA;
break; break;
case 'c': case 'c':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_CHECK; check_param.testflag&= ~T_CHECK;
else else
check_param.testflag|= T_CHECK; check_param.testflag|= T_CHECK;
break; break;
case 'C': case 'C':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~(T_CHECK | T_CHECK_ONLY_CHANGED); check_param.testflag&= ~(T_CHECK | T_CHECK_ONLY_CHANGED);
else else
check_param.testflag|= T_CHECK | T_CHECK_ONLY_CHANGED; check_param.testflag|= T_CHECK | T_CHECK_ONLY_CHANGED;
...@@ -430,7 +448,7 @@ get_one_option(int optid, ...@@ -430,7 +448,7 @@ get_one_option(int optid,
check_param.max_data_file_length=strtoll(argument, NULL, 10); check_param.max_data_file_length=strtoll(argument, NULL, 10);
break; break;
case 's': /* silent */ case 's': /* silent */
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~(T_SILENT | T_VERY_SILENT); check_param.testflag&= ~(T_SILENT | T_VERY_SILENT);
else else
{ {
...@@ -441,31 +459,31 @@ get_one_option(int optid, ...@@ -441,31 +459,31 @@ get_one_option(int optid,
} }
break; break;
case 'w': case 'w':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_WAIT_FOREVER; check_param.testflag&= ~T_WAIT_FOREVER;
else else
check_param.testflag|= T_WAIT_FOREVER; check_param.testflag|= T_WAIT_FOREVER;
break; break;
case 'd': /* description if isam-file */ case 'd': /* description if isam-file */
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_DESCRIPT; check_param.testflag&= ~T_DESCRIPT;
else else
check_param.testflag|= T_DESCRIPT; check_param.testflag|= T_DESCRIPT;
break; break;
case 'e': /* extend check */ case 'e': /* extend check */
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_EXTEND; check_param.testflag&= ~T_EXTEND;
else else
check_param.testflag|= T_EXTEND; check_param.testflag|= T_EXTEND;
break; break;
case 'i': case 'i':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_INFO; check_param.testflag&= ~T_INFO;
else else
check_param.testflag|= T_INFO; check_param.testflag|= T_INFO;
break; break;
case 'f': case 'f':
if (argument && *argument == '0') if (argument == disabled_my_option)
{ {
check_param.tmpfile_createflag= O_RDWR | O_TRUNC | O_EXCL; check_param.tmpfile_createflag= O_RDWR | O_TRUNC | O_EXCL;
check_param.testflag&= ~(T_FORCE_CREATE | T_UPDATE_STATE); check_param.testflag&= ~(T_FORCE_CREATE | T_UPDATE_STATE);
...@@ -477,7 +495,7 @@ get_one_option(int optid, ...@@ -477,7 +495,7 @@ get_one_option(int optid,
} }
break; break;
case 'F': case 'F':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_FAST; check_param.testflag&= ~T_FAST;
else else
check_param.testflag|= T_FAST; check_param.testflag|= T_FAST;
...@@ -486,44 +504,37 @@ get_one_option(int optid, ...@@ -486,44 +504,37 @@ get_one_option(int optid,
check_param.keys_in_use= (ulonglong) strtoll(argument, NULL, 10); check_param.keys_in_use= (ulonglong) strtoll(argument, NULL, 10);
break; break;
case 'm': case 'm':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_MEDIUM; check_param.testflag&= ~T_MEDIUM;
else else
check_param.testflag|= T_MEDIUM; /* Medium check */ check_param.testflag|= T_MEDIUM; /* Medium check */
break; break;
case 'r': /* Repair table */ case 'r': /* Repair table */
if (argument && *argument == '0') check_param.testflag&= ~T_REP_ANY;
check_param.testflag&= ~(T_REP | T_REP_BY_SORT); if (argument != disabled_my_option)
else check_param.testflag|= T_REP_BY_SORT;
check_param.testflag= (check_param.testflag & ~T_REP) | T_REP_BY_SORT;
break; break;
case 'o': case 'o':
if (argument && *argument == '0') check_param.testflag&= ~T_REP_ANY;
check_param.force_sort= 0;
if (argument != disabled_my_option)
{ {
check_param.testflag&= ~(T_REP | T_REP_BY_SORT); check_param.testflag|= T_REP;
check_param.force_sort= 0;
}
else
{
check_param.testflag= (check_param.testflag & ~T_REP_BY_SORT) | T_REP;
check_param.force_sort= 0;
my_disable_async_io= 1; /* More safety */ my_disable_async_io= 1; /* More safety */
} }
break; break;
case 'n': case 'n':
if (argument && *argument == '0') check_param.testflag&= ~T_REP_ANY;
{ if (argument == disabled_my_option)
check_param.testflag&= ~(T_REP | T_REP_BY_SORT);
check_param.force_sort= 0; check_param.force_sort= 0;
}
else else
{ {
check_param.testflag= (check_param.testflag & ~T_REP) | T_REP_BY_SORT; check_param.testflag|= T_REP_BY_SORT;
check_param.force_sort= 1; check_param.force_sort= 1;
} }
break; break;
case 'q': case 'q':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~(T_QUICK | T_FORCE_UNIQUENESS); check_param.testflag&= ~(T_QUICK | T_FORCE_UNIQUENESS);
else else
check_param.testflag|= check_param.testflag|=
...@@ -536,7 +547,7 @@ get_one_option(int optid, ...@@ -536,7 +547,7 @@ get_one_option(int optid,
check_param.testflag|= T_UNPACK | T_REP_BY_SORT; check_param.testflag|= T_UNPACK | T_REP_BY_SORT;
break; break;
case 'v': /* Verbose */ case 'v': /* Verbose */
if (argument && *argument == '0') if (argument == disabled_my_option)
{ {
check_param.testflag&= ~T_VERBOSE; check_param.testflag&= ~T_VERBOSE;
check_param.verbose=0; check_param.verbose=0;
...@@ -548,7 +559,7 @@ get_one_option(int optid, ...@@ -548,7 +559,7 @@ get_one_option(int optid,
} }
break; break;
case 'R': /* Sort records */ case 'R': /* Sort records */
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_SORT_RECORDS; check_param.testflag&= ~T_SORT_RECORDS;
else else
{ {
...@@ -564,25 +575,25 @@ get_one_option(int optid, ...@@ -564,25 +575,25 @@ get_one_option(int optid,
} }
break; break;
case 'S': /* Sort index */ case 'S': /* Sort index */
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_SORT_INDEX; check_param.testflag&= ~T_SORT_INDEX;
else else
check_param.testflag|= T_SORT_INDEX; check_param.testflag|= T_SORT_INDEX;
break; break;
case 'T': case 'T':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_READONLY; check_param.testflag&= ~T_READONLY;
else else
check_param.testflag|= T_READONLY; check_param.testflag|= T_READONLY;
break; break;
case 'U': case 'U':
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_UPDATE_STATE; check_param.testflag&= ~T_UPDATE_STATE;
else else
check_param.testflag|= T_UPDATE_STATE; check_param.testflag|= T_UPDATE_STATE;
break; break;
case '#': case '#':
if (argument && *argument == '0') if (argument == disabled_my_option)
{ {
DBUG_POP(); DBUG_POP();
} }
...@@ -595,7 +606,7 @@ get_one_option(int optid, ...@@ -595,7 +606,7 @@ get_one_option(int optid,
print_version(); print_version();
exit(0); exit(0);
case OPT_CORRECT_CHECKSUM: case OPT_CORRECT_CHECKSUM:
if (argument && *argument == '0') if (argument == disabled_my_option)
check_param.testflag&= ~T_CALC_CHECKSUM; check_param.testflag&= ~T_CALC_CHECKSUM;
else else
check_param.testflag|= T_CALC_CHECKSUM; check_param.testflag|= T_CALC_CHECKSUM;
...@@ -627,7 +638,7 @@ static void get_options(register int *argc,register char ***argv) ...@@ -627,7 +638,7 @@ static void get_options(register int *argc,register char ***argv)
/* If using repair, then update checksum if one uses --update-state */ /* If using repair, then update checksum if one uses --update-state */
if ((check_param.testflag & T_UPDATE_STATE) && if ((check_param.testflag & T_UPDATE_STATE) &&
(check_param.testflag & (T_REP | T_REP_BY_SORT))) (check_param.testflag & T_REP_ANY))
check_param.testflag|= T_CALC_CHECKSUM; check_param.testflag|= T_CALC_CHECKSUM;
if (*argc == 0) if (*argc == 0)
...@@ -646,7 +657,7 @@ static void get_options(register int *argc,register char ***argv) ...@@ -646,7 +657,7 @@ static void get_options(register int *argc,register char ***argv)
} }
if ((check_param.testflag & T_READONLY) && if ((check_param.testflag & T_READONLY) &&
(check_param.testflag & (check_param.testflag &
(T_REP_BY_SORT | T_REP | T_STATISTICS | T_AUTO_INC | (T_REP_ANY | T_STATISTICS | T_AUTO_INC |
T_SORT_RECORDS | T_SORT_INDEX | T_FORCE_CREATE))) T_SORT_RECORDS | T_SORT_INDEX | T_FORCE_CREATE)))
{ {
VOID(fprintf(stderr, VOID(fprintf(stderr,
...@@ -743,7 +754,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -743,7 +754,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
{ {
my_bool need_to_check= mi_is_crashed(info) || share->state.open_count != 0; my_bool need_to_check= mi_is_crashed(info) || share->state.open_count != 0;
if ((param->testflag & (T_REP_BY_SORT | T_REP | T_SORT_RECORDS)) && if ((param->testflag & (T_REP_ANY | T_SORT_RECORDS)) &&
((share->state.changed & (STATE_CHANGED | STATE_CRASHED | ((share->state.changed & (STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR) || STATE_CRASHED_ON_REPAIR) ||
!(param->testflag & T_CHECK_ONLY_CHANGED)))) !(param->testflag & T_CHECK_ONLY_CHANGED))))
...@@ -775,7 +786,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -775,7 +786,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
} }
if ((param->testflag & (T_REP_BY_SORT | T_REP | T_STATISTICS | if ((param->testflag & (T_REP_ANY | T_STATISTICS |
T_SORT_RECORDS | T_SORT_INDEX)) && T_SORT_RECORDS | T_SORT_INDEX)) &&
(((param->testflag & T_UNPACK) && (((param->testflag & T_UNPACK) &&
share->data_file_type == COMPRESSED_RECORD) || share->data_file_type == COMPRESSED_RECORD) ||
...@@ -791,8 +802,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -791,8 +802,8 @@ static int myisamchk(MI_CHECK *param, my_string filename)
myisam_block_size != MI_KEY_BLOCK_LENGTH)) myisam_block_size != MI_KEY_BLOCK_LENGTH))
{ {
if (set_charset) if (set_charset)
check_param.language=set_charset->number; param->language=set_charset->number;
if (recreate_table(&check_param, &info,filename)) if (recreate_table(param, &info,filename))
{ {
VOID(fprintf(stderr, VOID(fprintf(stderr,
"MyISAM-table '%s' is not fixed because of errors\n", "MyISAM-table '%s' is not fixed because of errors\n",
...@@ -800,7 +811,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -800,7 +811,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
return(-1); return(-1);
} }
recreate=1; recreate=1;
if (!(param->testflag & (T_REP | T_REP_BY_SORT))) if (!(param->testflag & T_REP_ANY))
{ {
param->testflag|=T_REP_BY_SORT; /* if only STATISTICS */ param->testflag|=T_REP_BY_SORT; /* if only STATISTICS */
if (!(param->testflag & T_SILENT)) if (!(param->testflag & T_SILENT))
...@@ -817,7 +828,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -817,7 +828,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
param->total_files++; param->total_files++;
param->total_records+=info->state->records; param->total_records+=info->state->records;
param->total_deleted+=info->state->del; param->total_deleted+=info->state->del;
descript(&check_param, info, filename); descript(param, info, filename);
} }
else else
{ {
...@@ -843,9 +854,9 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -843,9 +854,9 @@ static int myisamchk(MI_CHECK *param, my_string filename)
info->tmp_lock_type=lock_type; info->tmp_lock_type=lock_type;
datafile=info->dfile; datafile=info->dfile;
if (param->testflag & (T_REP+T_REP_BY_SORT+T_SORT_RECORDS+T_SORT_INDEX)) if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX))
{ {
if (param->testflag & (T_REP+T_REP_BY_SORT)) if (param->testflag & T_REP_ANY)
{ {
ulonglong tmp=share->state.key_map; ulonglong tmp=share->state.key_map;
share->state.key_map= (((ulonglong) 1 << share->base.keys)-1) share->state.key_map= (((ulonglong) 1 << share->base.keys)-1)
...@@ -853,7 +864,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -853,7 +864,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
if (tmp != share->state.key_map) if (tmp != share->state.key_map)
info->update|=HA_STATE_CHANGED; info->update|=HA_STATE_CHANGED;
} }
if (rep_quick && chk_del(&check_param, info, if (rep_quick && chk_del(param, info,
param->testflag & ~T_VERBOSE)) param->testflag & ~T_VERBOSE))
{ {
if (param->testflag & T_FORCE_CREATE) if (param->testflag & T_FORCE_CREATE)
...@@ -875,13 +886,13 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -875,13 +886,13 @@ static int myisamchk(MI_CHECK *param, my_string filename)
(rep_quick && !param->keys_in_use && !recreate)) && (rep_quick && !param->keys_in_use && !recreate)) &&
mi_test_if_sort_rep(info, info->state->records, mi_test_if_sort_rep(info, info->state->records,
info->s->state.key_map, info->s->state.key_map,
check_param.force_sort)) param->force_sort))
{ {
error=mi_repair_by_sort(&check_param,info,filename,rep_quick); error=mi_repair_by_sort(param,info,filename,rep_quick);
state_updated=1; state_updated=1;
} }
else if (param->testflag & (T_REP | T_REP_BY_SORT)) else if (param->testflag & T_REP_ANY)
error=mi_repair(&check_param, info,filename,rep_quick); error=mi_repair(param, info,filename,rep_quick);
} }
if (!error && param->testflag & T_SORT_RECORDS) if (!error && param->testflag & T_SORT_RECORDS)
{ {
...@@ -915,14 +926,15 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -915,14 +926,15 @@ static int myisamchk(MI_CHECK *param, my_string filename)
update_index=0; update_index=0;
error=mi_sort_records(param,info,filename,param->opt_sort_key, error=mi_sort_records(param,info,filename,param->opt_sort_key,
/* what is the following parameter for ? */
(my_bool) !(param->testflag & T_REP), (my_bool) !(param->testflag & T_REP),
update_index); update_index);
datafile=info->dfile; /* This is now locked */ datafile=info->dfile; /* This is now locked */
if (!error && !update_index) if (!error && !update_index)
{ {
if (check_param.verbose) if (param->verbose)
puts("Table had a compressed index; We must now recreate the index"); puts("Table had a compressed index; We must now recreate the index");
error=mi_repair_by_sort(&check_param,info,filename,1); error=mi_repair_by_sort(param,info,filename,1);
} }
} }
} }
...@@ -996,8 +1008,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -996,8 +1008,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
} }
} }
if ((param->testflag & T_AUTO_INC) || if ((param->testflag & T_AUTO_INC) ||
((param->testflag & (T_REP | T_REP_BY_SORT)) && ((param->testflag & T_REP_ANY) && info->s->base.auto_key))
info->s->base.auto_key))
update_auto_increment_key(param, info, update_auto_increment_key(param, info,
(my_bool) !test(param->testflag & T_AUTO_INC)); (my_bool) !test(param->testflag & T_AUTO_INC));
...@@ -1006,7 +1017,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -1006,7 +1017,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
if (info->update & HA_STATE_CHANGED && ! (param->testflag & T_READONLY)) if (info->update & HA_STATE_CHANGED && ! (param->testflag & T_READONLY))
error|=update_state_info(param, info, error|=update_state_info(param, info,
UPDATE_OPEN_COUNT | UPDATE_OPEN_COUNT |
(((param->testflag & (T_REP | T_REP_BY_SORT)) ? (((param->testflag & T_REP_ANY) ?
UPDATE_TIME : 0) | UPDATE_TIME : 0) |
(state_updated ? UPDATE_STAT : 0) | (state_updated ? UPDATE_STAT : 0) |
((param->testflag & T_SORT_RECORDS) ? ((param->testflag & T_SORT_RECORDS) ?
...@@ -1036,12 +1047,12 @@ end2: ...@@ -1036,12 +1047,12 @@ end2:
VOID(fflush(stdout)); VOID(fflush(stderr)); VOID(fflush(stdout)); VOID(fflush(stderr));
if (param->error_printed) if (param->error_printed)
{ {
if (param->testflag & (T_REP+T_REP_BY_SORT+T_SORT_RECORDS+T_SORT_INDEX)) if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX))
{ {
VOID(fprintf(stderr, VOID(fprintf(stderr,
"MyISAM-table '%s' is not fixed because of errors\n", "MyISAM-table '%s' is not fixed because of errors\n",
filename)); filename));
if (check_param.testflag & (T_REP_BY_SORT | T_REP)) if (param->testflag & T_REP_ANY)
VOID(fprintf(stderr, VOID(fprintf(stderr,
"Try fixing it by using the --safe-recover (-o) or the --force (-f) option\n")); "Try fixing it by using the --safe-recover (-o) or the --force (-f) option\n"));
} }
...@@ -1052,7 +1063,7 @@ end2: ...@@ -1052,7 +1063,7 @@ end2:
filename)); filename));
} }
else if (param->warning_printed && else if (param->warning_printed &&
! (param->testflag & (T_REP+T_REP_BY_SORT+T_SORT_RECORDS+T_SORT_INDEX+ ! (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX |
T_FORCE_CREATE))) T_FORCE_CREATE)))
VOID(fprintf(stderr, "MyISAM-table '%s' is usable but should be fixed\n", VOID(fprintf(stderr, "MyISAM-table '%s' is usable but should be fixed\n",
filename)); filename));
......
...@@ -67,8 +67,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, ...@@ -67,8 +67,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
sql_print_error(msgbuf); sql_print_error(msgbuf);
return; return;
} }
if (param->testflag & (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | if (param->testflag & (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR))
T_AUTO_REPAIR))
{ {
my_message(ER_NOT_KEYFILE,msgbuf,MYF(MY_WME)); my_message(ER_NOT_KEYFILE,msgbuf,MYF(MY_WME));
return; return;
...@@ -696,7 +695,7 @@ bool ha_myisam::activate_all_index(THD *thd) ...@@ -696,7 +695,7 @@ bool ha_myisam::activate_all_index(THD *thd)
myisamchk_init(&param); myisamchk_init(&param);
param.op_name = (char*) "recreating_index"; param.op_name = (char*) "recreating_index";
param.testflag = (T_SILENT | T_REP_BY_SORT | T_QUICK | param.testflag = (T_SILENT | T_REP_BY_SORT | T_QUICK |
T_CREATE_MISSING_KEYS | T_TRUST_HEADER); T_CREATE_MISSING_KEYS);
param.myf_rw&= ~MY_WAIT_IF_FULL; param.myf_rw&= ~MY_WAIT_IF_FULL;
param.sort_buffer_length= myisam_sort_buffer_size; param.sort_buffer_length= myisam_sort_buffer_size;
param.tmpdir=mysql_tmpdir; param.tmpdir=mysql_tmpdir;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment