@@ -248,7 +248,7 @@ enum options_mc {
248248 OPT_MAX_RECORD_LENGTH , OPT_AUTO_CLOSE , OPT_STATS_METHOD , OPT_TRANSACTION_LOG ,
249249 OPT_ZEROFILL_KEEP_LSN ,
250250 OPT_REQUIRE_CONTROL_FILE , OPT_IGNORE_CONTROL_FILE ,
251- OPT_LOG_DIR , OPT_WARNING_FOR_WRONG_TRANSID
251+ OPT_LOG_DIR , OPT_WARNING_FOR_WRONG_TRANSID , OPT_ACTIVE_KEYS
252252};
253253
254254static struct my_option my_long_options [] =
@@ -319,10 +319,16 @@ static struct my_option my_long_options[] =
319319 (uchar * * )& opt_ignore_control_file , 0 , 0 , GET_BOOL , NO_ARG ,
320320 0 , 0 , 0 , 0 , 0 , 0 },
321321 {"keys-used" , 'k' ,
322- "Tell Aria to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts." ,
322+ "Tell Aria to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts. See also keys-active " ,
323323 & check_param .keys_in_use ,
324324 & check_param .keys_in_use ,
325325 0 , GET_ULL , REQUIRED_ARG , -1 , 0 , 0 , 0 , 0 , 0 },
326+ {"keys-active" , OPT_ACTIVE_KEYS ,
327+ "Threat all not listed keys as disabled. If used with repair, the keys "
328+ "will be disabled permanently. The argument is a list of key numbers, "
329+ "starting from 1, separated by ','. "
330+ "keys-active and keys-used are two ways to do the same thing" ,
331+ 0 , 0 , 0 , GET_STR , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
326332 {"datadir" , 'h' ,
327333 "Path for control file (and logs if --logdir not used)." ,
328334 (char * * ) & maria_data_root , 0 , 0 , GET_STR , REQUIRED_ARG ,
@@ -455,7 +461,7 @@ static struct my_option my_long_options[] =
455461 REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
456462 { "stats_method" , OPT_STATS_METHOD ,
457463 "Specifies how index statistics collection code should treat NULLs. "
458- "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), "
464+ "Possible values of name are \"nulls_unequal\" (default behavior for MySQL 4.1/5.0), "
459465 "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\"." ,
460466 (char * * ) & maria_stats_method_str , (char * * ) & maria_stats_method_str , 0 ,
461467 GET_STR , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
@@ -472,7 +478,7 @@ static struct my_option my_long_options[] =
472478
473479static void print_version (void )
474480{
475- printf ("%s Ver 1.3 for %s on %s\n" , my_progname , SYSTEM_TYPE ,
481+ printf ("%s Ver 1.4 for %s on %s\n" , my_progname , SYSTEM_TYPE ,
476482 MACHINE_TYPE );
477483}
478484
@@ -566,6 +572,11 @@ Recover (repair)/ options (When using '--recover' or '--safe-recover'):\n\
566572 -k, --keys-used=# Tell Aria to update only some specific keys. # is a\n\
567573 bit mask of which keys to use. This can be used to\n\
568574 get faster inserts.\n\
575+ --keys-active\n\
576+ Treat all not listed keys as disabled. If used with repair, the keys\n\
577+ will be disabled permanently. The argument is a list of key numbers,\n\
578+ starting from 1, separated by ','\n\
579+ keys-active and keys-used are two ways to do the same thing\n\
569580 --max-record-length=#\n\
570581 Skip rows bigger than this if aria_chk can't allocate\n\
571582 memory to hold it.\n\
@@ -750,6 +761,32 @@ get_one_option(const struct my_option *opt,
750761 case 'k' :
751762 check_param .keys_in_use = (ulonglong ) strtoll (argument , NULL , 10 );
752763 break ;
764+ case OPT_ACTIVE_KEYS :
765+ if (argument == disabled_my_option )
766+ check_param .keys_in_use = ~0LL ;
767+ else
768+ {
769+ const char * start ;
770+ char * end , * str_end = strend (argument );
771+ check_param .keys_in_use = 0 ;
772+ for (start = argument ; * start ; start = end )
773+ {
774+ int error ;
775+ longlong key ;
776+ end = str_end ;
777+ key = my_strtoll10 (start , & end , & error );
778+ if (error || key > 64 || (* end && * end != ',' ))
779+ {
780+ fprintf (stderr , "Wrong argument to active-keys. Expected a list of "
781+ "numbers like 1,2,3,4\n" );
782+ exit (1 ); /* Change to my_exit after merge */
783+ }
784+ check_param .keys_in_use |= 1LL << (key - 1 );
785+ if (* end == ',' )
786+ end ++ ;
787+ }
788+ }
789+ break ;
753790 case 'm' :
754791 if (argument == disabled_my_option )
755792 check_param .testflag &= ~T_MEDIUM ;
@@ -1032,7 +1069,9 @@ static int maria_chk(HA_CHECK *param, char *filename)
10321069 if (!(info = maria_open (filename ,
10331070 (param -> testflag & (T_DESCRIPT | T_READONLY )) ?
10341071 O_RDONLY : O_RDWR ,
1035- HA_OPEN_FOR_REPAIR |
1072+ HA_OPEN_FOR_REPAIR | HA_OPEN_FORCE_MODE |
1073+ ((param -> testflag & T_QUICK ) ?
1074+ HA_OPEN_DATA_READONLY : 0 ) |
10361075 ((param -> testflag & T_WAIT_FOREVER ) ?
10371076 HA_OPEN_WAIT_IF_LOCKED :
10381077 (param -> testflag & T_DESCRIPT ) ?
@@ -1160,6 +1199,13 @@ static int maria_chk(HA_CHECK *param, char *filename)
11601199 DBUG_RETURN (0 );
11611200 }
11621201 }
1202+
1203+ /* Don't allow disable of active auto_increment keys for repair */
1204+ if (share -> base .auto_key &&
1205+ (share -> state .key_map & (1LL << share -> base .auto_key )) &&
1206+ param -> testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX ))
1207+ check_param .keys_in_use |= (1LL << share -> base .auto_key );
1208+
11631209 if ((param -> testflag & (T_REP_ANY | T_STATISTICS |
11641210 T_SORT_RECORDS | T_SORT_INDEX )) &&
11651211 (((param -> testflag & T_UNPACK ) &&
0 commit comments