Commit a7430f38 authored by unknown's avatar unknown

--tmpdir=dir1:dir2:... support in myisamchk

parent 13da94b7
...@@ -329,7 +329,8 @@ typedef struct st_mi_check_param ...@@ -329,7 +329,8 @@ typedef struct st_mi_check_param
uint8 language; uint8 language;
my_bool using_global_keycache, opt_lock_memory, opt_follow_links; my_bool using_global_keycache, opt_lock_memory, opt_follow_links;
my_bool retry_repair, force_sort, calc_checksum; my_bool retry_repair, force_sort, calc_checksum;
char temp_filename[FN_REFLEN],*isam_file_name,*tmpdir; char temp_filename[FN_REFLEN],*isam_file_name;
MY_TMPDIR *tmpdir;
int tmpfile_createflag; int tmpfile_createflag;
myf myf_rw; myf myf_rw;
IO_CACHE read_cache; IO_CACHE read_cache;
...@@ -376,7 +377,7 @@ typedef struct st_mi_sort_param ...@@ -376,7 +377,7 @@ typedef struct st_mi_sort_param
byte *rec_buff; byte *rec_buff;
void *wordlist, *wordptr; void *wordlist, *wordptr;
char *record; char *record;
char *tmpdir; MY_TMPDIR *tmpdir;
int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *); int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
int (*key_read)(struct st_mi_sort_param *,void *); int (*key_read)(struct st_mi_sort_param *,void *);
int (*key_write)(struct st_mi_sort_param *, const void *); int (*key_write)(struct st_mi_sort_param *, const void *);
......
...@@ -41,9 +41,10 @@ SET_STACK_SIZE(9000) /* Minimum stack size for program */ ...@@ -41,9 +41,10 @@ SET_STACK_SIZE(9000) /* Minimum stack size for program */
static uint decode_bits; static uint decode_bits;
static char **default_argv; static char **default_argv;
static const char *load_default_groups[]= { "myisamchk", 0 }; static const char *load_default_groups[]= { "myisamchk", 0 };
static const char *set_charset_name; static const char *set_charset_name, *opt_tmpdir;
static CHARSET_INFO *set_charset; static CHARSET_INFO *set_charset;
static long opt_myisam_block_size; static long opt_myisam_block_size;
static MY_TMPDIR myisamchk_tmpdir;
static const char *type_names[]= static const char *type_names[]=
{ "?","char","binary", "short", "long", "float", { "?","char","binary", "short", "long", "float",
...@@ -257,7 +258,7 @@ static struct my_option my_long_options[] = ...@@ -257,7 +258,7 @@ static struct my_option my_long_options[] =
0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"tmpdir", 't', {"tmpdir", 't',
"Path for temporary files.", "Path for temporary files.",
(gptr*) &check_param.tmpdir, (gptr*) &opt_tmpdir,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"update-state", 'U', {"update-state", 'U',
"Mark tables as crashed if any errors were found.", "Mark tables as crashed if any errors were found.",
...@@ -338,7 +339,9 @@ static void usage(void) ...@@ -338,7 +339,9 @@ static void usage(void)
Change the value of a variable. Please note that\n\ Change the value of a variable. Please note that\n\
this option is deprecated; you can set variables\n\ this option is deprecated; you can set variables\n\
directly with '--variable-name=value'.\n\ directly with '--variable-name=value'.\n\
-t, --tmpdir=path Path for temporary files\n\ -t, --tmpdir=path Path for temporary files. Multiple paths can be\n\
specified, separated by colon (:), they will be used\n\
in a round-robin fashion.\n\
-s, --silent Only print errors. One can use two -s to make\n\ -s, --silent Only print errors. One can use two -s to make\n\
myisamchk very silent\n\ myisamchk very silent\n\
-v, --verbose Print more information. This can be used with\n\ -v, --verbose Print more information. This can be used with\n\
...@@ -693,6 +696,11 @@ static void get_options(register int *argc,register char ***argv) ...@@ -693,6 +696,11 @@ static void get_options(register int *argc,register char ***argv)
exit(1); exit(1);
} }
if (init_tmpdir(&myisamchk_tmpdir, opt_tmpdir))
exit(1);
check_param.tmpdir=&myisamchk_tmpdir;
if (set_charset_name) if (set_charset_name)
if (!(set_charset=get_charset_by_name(set_charset_name, MYF(MY_WME)))) if (!(set_charset=get_charset_by_name(set_charset_name, MYF(MY_WME))))
exit(1); exit(1);
......
...@@ -553,8 +553,8 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys, ...@@ -553,8 +553,8 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys,
qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp, qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp,
info); info);
if (!my_b_inited(tempfile) && if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, info->tmpdir, "ST", DISK_BUFFER_SIZE, open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
info->sort_info->param->myf_rw)) DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
DBUG_RETURN(1); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */
buffpek->file_pos=my_b_tell(tempfile); buffpek->file_pos=my_b_tell(tempfile);
...@@ -576,8 +576,8 @@ static int NEAR_F write_key(MI_SORT_PARAM *info, uchar *key, ...@@ -576,8 +576,8 @@ static int NEAR_F write_key(MI_SORT_PARAM *info, uchar *key,
DBUG_ENTER("write_key"); DBUG_ENTER("write_key");
if (!my_b_inited(tempfile) && if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, info->tmpdir, "ST", DISK_BUFFER_SIZE, open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
info->sort_info->param->myf_rw)) DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
DBUG_RETURN(1); DBUG_RETURN(1);
if (my_b_write(tempfile,(byte*)&key_length,sizeof(key_length)) || if (my_b_write(tempfile,(byte*)&key_length,sizeof(key_length)) ||
...@@ -619,8 +619,8 @@ static int NEAR_F merge_many_buff(MI_SORT_PARAM *info, uint keys, ...@@ -619,8 +619,8 @@ static int NEAR_F merge_many_buff(MI_SORT_PARAM *info, uint keys,
if (*maxbuffer < MERGEBUFF2) if (*maxbuffer < MERGEBUFF2)
DBUG_RETURN(0); /* purecov: inspected */ DBUG_RETURN(0); /* purecov: inspected */
if (flush_io_cache(t_file) || if (flush_io_cache(t_file) ||
open_cached_file(&t_file2,info->tmpdir,"ST",DISK_BUFFER_SIZE, open_cached_file(&t_file2,my_tmpdir(info->tmpdir),"ST",
info->sort_info->param->myf_rw)) DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
DBUG_RETURN(1); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */
from_file= t_file ; to_file= &t_file2; from_file= t_file ; to_file= &t_file2;
......
...@@ -559,7 +559,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize) ...@@ -559,7 +559,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
param.tmpfile_createflag = O_RDWR | O_TRUNC; param.tmpfile_createflag = O_RDWR | O_TRUNC;
param.using_global_keycache = 1; param.using_global_keycache = 1;
param.thd=thd; param.thd=thd;
param.tmpdir=mysql_tmpdir; param.tmpdir=&mysql_tmpdir_list;
param.out_flag=0; param.out_flag=0;
strmov(fixed_name,file->filename); strmov(fixed_name,file->filename);
...@@ -718,7 +718,7 @@ bool ha_myisam::activate_all_index(THD *thd) ...@@ -718,7 +718,7 @@ bool ha_myisam::activate_all_index(THD *thd)
T_CREATE_MISSING_KEYS); T_CREATE_MISSING_KEYS);
param.myf_rw&= ~MY_WAIT_IF_FULL; param.myf_rw&= ~MY_WAIT_IF_FULL;
param.sort_buffer_length= thd->variables.myisam_sort_buff_size; param.sort_buffer_length= thd->variables.myisam_sort_buff_size;
param.tmpdir=mysql_tmpdir; param.tmpdir=&mysql_tmpdir_list;
error=repair(thd,param,0) != HA_ADMIN_OK; error=repair(thd,param,0) != HA_ADMIN_OK;
thd->proc_info=save_proc_info; thd->proc_info=save_proc_info;
} }
......
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