Commit ac26ba18 authored by serg@sergbook.mysql.com's avatar serg@sergbook.mysql.com
Browse files

Merge serg:/usr/home/serg/Abk/mysql-4.0

into sergbook.mysql.com:/usr/home/serg/Abk/mysql-4.0
parents 8bf5ea3a 0a1de562
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -494,8 +494,8 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
#define my_rwlock_init(A,B) pthread_rwlock_init((A),(B))
#define rw_rdlock(A) pthread_rwlock_rdlock(A)
#define rw_wrlock(A) pthread_rwlock_wrlock(A)
#define rw_tryrdlock(A) pthread_mutex_tryrdlock((A))
#define rw_trywrlock(A) pthread_mutex_trywrlock((A))
#define rw_tryrdlock(A) pthread_rwlock_tryrdlock((A))
#define rw_trywrlock(A) pthread_rwlock_trywrlock((A))
#define rw_unlock(A) pthread_rwlock_unlock(A)
#define rwlock_destroy(A) pthread_rwlock_destroy(A)
#elif defined(HAVE_RWLOCK_INIT)
+0 −2
Original line number Diff line number Diff line
@@ -666,8 +666,6 @@ extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count);
extern void init_io_cache_share(IO_CACHE *info,
				IO_CACHE_SHARE *s, uint num_threads);
extern void remove_io_thread(IO_CACHE *info);
int lock_io_cache(IO_CACHE *);
void unlock_io_cache(IO_CACHE *);
#endif
extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
+3 −1
Original line number Diff line number Diff line
@@ -384,7 +384,7 @@ typedef struct st_mi_sort_param
  IO_CACHE tempfile, tempfile_for_exceptions;
  DYNAMIC_ARRAY buffpek;
  my_off_t pos,max_pos,filepos,start_recpos;
  my_bool fix_datafile;
  my_bool fix_datafile, master;
  char *record;
  char *tmpdir;
  int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
@@ -406,6 +406,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name);
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
		      const char * name, int rep_quick);
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
		      const char * name, int rep_quick);
int change_to_newfile(const char * filename, const char * old_ext,
		      const char * new_ext, uint raid_chunks,
		      myf myflags);
+31 −17
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/* Descript, check and repair of MyISAM tables */
/* Describe, check and repair of MyISAM tables */

#include "ftdefs.h"
#include <m_ctype.h>
@@ -1187,6 +1187,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
    my_seek(info->dfile,0L,MY_SEEK_END,MYF(0));
  sort_info.dupp=0;
  sort_param.fix_datafile= (my_bool) (! rep_quick);
  sort_param.master=1;
  sort_info.max_records= ~(ha_rows) 0;

  set_data_file_type(&sort_info, share);
@@ -1888,6 +1889,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
  sort_param.tmpdir=param->tmpdir;
  sort_param.sort_info=&sort_info;
  sort_param.fix_datafile= (my_bool) (! rep_quick);
  sort_param.master =1;

  del=info->state->del;
  param->glob_crc=0;
@@ -2107,13 +2109,14 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
  DESCRIPTION
    Same as mi_repair_by_sort but do it multithreaded
    Each key is handled by a separate thread.
    TODO: make a number of thread a parameter

  RESULT
    0	ok
    <>0	Error
*/

int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info,
int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
			const char * name, int rep_quick)
{
  int got_error;
@@ -2131,7 +2134,7 @@ int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info,
  SORT_INFO sort_info;
  ulonglong key_map=share->state.key_map;
  pthread_attr_t thr_attr;
  DBUG_ENTER("mi_repair_by_sort_r");
  DBUG_ENTER("mi_repair_parallel");

  start_records=info->state->records;
  got_error=1;
@@ -2267,6 +2270,8 @@ int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info,
      i--;
      continue;
    }
    if ((!(param->testflag & T_SILENT)))
      printf ("- Fixing index %d\n",key+1);
    sort_param[i].key_read= ((sort_param[i].keyinfo->flag & HA_FULLTEXT) ?
			     sort_ft_key_read : sort_key_read);
    sort_param[i].key_cmp=sort_key_cmp;
@@ -2274,6 +2279,7 @@ int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info,
    sort_param[i].lock_in_memory=lock_memory;
    sort_param[i].tmpdir=param->tmpdir;
    sort_param[i].sort_info=&sort_info;
    sort_param[i].master=0;
    sort_param[i].fix_datafile=0;

    sort_param[i].filepos=new_header_length;
@@ -2300,7 +2306,8 @@ int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info,
      sort_param[i].key_length+=ft_max_word_len_for_sort-ft_max_word_len;
  }
  sort_info.total_keys=i;
  sort_param[0].fix_datafile= ! rep_quick;
  sort_param[0].master= 1;
  sort_param[0].fix_datafile= (my_bool)(! rep_quick);

  sort_info.got_error=0;
  pthread_mutex_init(&sort_info.mutex, MY_MUTEX_INIT_FAST);
@@ -2321,7 +2328,7 @@ int mi_repair_by_sort_r(MI_CHECK *param, register MI_INFO *info,
        In the second one all the threads will fill their sort_buffers
        (and call write_keys) at the same time, putting more stress on i/o.
      */
#if 1
#ifndef USING_SECOND_APPROACH
      param->sort_buffer_length/sort_info.total_keys;
#else
      param->sort_buffer_length*sort_param[i].key_length/total_key_length;
@@ -2488,7 +2495,8 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key)
  if (info->state->records == sort_info->max_records)
  {
    mi_check_print_error(sort_info->param,
			 "Found too many records; Can`t continue");
			 "Key %d - Found too many records; Can't continue",
                         sort_param->key+1);
    DBUG_RETURN(1);
  }
  sort_param->real_key_length=
@@ -2578,6 +2586,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
      if (!sort_param->fix_datafile)
      {
	sort_param->filepos=sort_param->pos;
        if (sort_param->master)
	  share->state.split++;
      }
      sort_param->max_pos=(sort_param->pos+=share->base.pack_reclength);
@@ -2588,7 +2597,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
			     mi_static_checksum(info,sort_param->record));
	DBUG_RETURN(0);
      }
      if (!sort_param->fix_datafile)
      if (!sort_param->fix_datafile && sort_param->master)
      {
	info->state->del++;
	info->state->empty+=share->base.pack_reclength;
@@ -2734,7 +2743,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
	}
	if (b_type & (BLOCK_DELETED | BLOCK_SYNC_ERROR))
	{
	  if (!sort_param->fix_datafile && (b_type & BLOCK_DELETED))
          if (!sort_param->fix_datafile && sort_param->master &&
              (b_type & BLOCK_DELETED))
	  {
	    info->state->empty+=block_info.block_len;
	    info->state->del++;
@@ -2753,7 +2763,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
	  continue;
	}

	if (!sort_param->fix_datafile)
	if (!sort_param->fix_datafile && sort_param->master)
	  share->state.split++;
	if (! found_record++)
	{
@@ -2895,6 +2905,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
      if (!sort_param->fix_datafile)
      {
	sort_param->filepos=sort_param->pos;
        if (sort_param->master)
	  share->state.split++;
      }
      sort_param->max_pos=(sort_param->pos=block_info.filepos+
@@ -3003,6 +3014,8 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
      break;
    }
  }
  if (sort_param->master)
  {
    info->state->records++;
    if ((param->testflag & T_WRITE_LOOP) &&
        (info->state->records % WRITE_COUNT) == 0)
@@ -3010,6 +3023,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
      char llbuff[22];
      printf("%s\r", llstr(info->state->records,llbuff)); VOID(fflush(stdout));
    }
  }
  DBUG_RETURN(0);
} /* sort_write_record */

+23 −7
Original line number Diff line number Diff line
@@ -194,6 +194,9 @@ static struct my_option my_long_options[] =
  {"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, 0},
  {"HELP", 'H',
   "Display this help and exit.",
   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, 0, 0, 0, 0, 0},
@@ -216,9 +219,15 @@ static struct my_option my_long_options[] =
  {"recover", 'r',
   "Can fix almost anything except unique keys that aren't unique.",
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
  {"paraller-recover", 'p',
   "Same as '-r' but creates all the keys in parallel",
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
  {"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, NO_ARG, 0, 0, 0, 0, 0, 0},
  {"sort-recover", 'n',
   "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},
  {"start-check-pos", OPT_START_CHECK_POS,
   "No help available.",
   0, 0, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -244,9 +253,6 @@ static struct my_option my_long_options[] =
   (gptr*) &check_param.opt_sort_key,
   (gptr*) &check_param.opt_sort_key,
   0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
  {"sort-recover", 'n',
   "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},
  {"tmpdir", 't',
   "Path for temporary files.",
   (gptr*) &check_param.tmpdir,
@@ -514,6 +520,11 @@ get_one_option(int optid,
    if (argument != disabled_my_option)
      check_param.testflag|= T_REP_BY_SORT;
    break;
  case 'p':
    check_param.testflag&= ~T_REP_ANY;
    if (argument != disabled_my_option)
      check_param.testflag|= T_REP_PARALLEL;
    break;
  case 'o':
    check_param.testflag&= ~T_REP_ANY;
    check_param.force_sort= 0;
@@ -616,6 +627,9 @@ get_one_option(int optid,
    check_param.start_check_pos= strtoull(argument, NULL, 0);
    break;
#endif
  case 'H':
    my_print_help(my_long_options);
    exit(0);
  case '?':
    usage();
    exit(0);
@@ -864,8 +878,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
	if (tmp != share->state.key_map)
	  info->update|=HA_STATE_CHANGED;
      }
      if (rep_quick && chk_del(param, info,
			       param->testflag & ~T_VERBOSE))
      if (rep_quick && chk_del(param, info, param->testflag & ~T_VERBOSE))
      {
	if (param->testflag & T_FORCE_CREATE)
	{
@@ -881,14 +894,17 @@ static int myisamchk(MI_CHECK *param, my_string filename)
      }
      if (!error)
      {
	if ((param->testflag & T_REP_BY_SORT) &&
	if ((param->testflag & (T_REP_BY_SORT | T_REP_PARALLEL)) &&
	    (share->state.key_map ||
	     (rep_quick && !param->keys_in_use && !recreate)) &&
	    mi_test_if_sort_rep(info, info->state->records,
				info->s->state.key_map,
				param->force_sort))
	{
          if (param->testflag & T_REP_BY_SORT)
            error=mi_repair_by_sort(param,info,filename,rep_quick);
          else
            error=mi_repair_parallel(param,info,filename,rep_quick);
	  state_updated=1;
	}
	else if (param->testflag & T_REP_ANY)
Loading