Commit f0dd11d5 authored by unknown's avatar unknown

Fixed problem when repairing packed MyISAM files.


Docs/manual.texi:
  Changelog
parent ffadef5d
...@@ -46838,12 +46838,22 @@ not yet 100% confident in this code. ...@@ -46838,12 +46838,22 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.45 @appendixsubsec Changes in release 3.23.45
@itemize @bullet @itemize @bullet
@item @item
@code{(UPDATE|DELETE) ...WHERE MATCH} bugfix
@item
shutdown should now work on Darwin (Mac OS X).
@item
Fixed core-dump when repairing corrupted packed MyISAM files.
@item
@code{--core-file} now works on Solaris. @code{--core-file} now works on Solaris.
@item @item
Fix a bug which could cause InnoDB to complain if it cannot find free blocks Fix a bug which could cause InnoDB to complain if it cannot find free blocks
from the buffer cache during recovery. from the buffer cache during recovery.
@item @item
Fixed a bug in InnoDB insert buffer B-tree handling that could cause crashes. Fixed bug in InnoDB insert buffer B-tree handling that could cause crashes.
@item
Fixed bug in InnoDB lock timeout handling.
@item
Fixed core dump bug in @code{ALTER TABLE} on a @code{TEMPORARY} InnoDB table.
@item @item
Fixed bug in @code{OPTIMIZE TABLE} that reset index cardinality if it Fixed bug in @code{OPTIMIZE TABLE} that reset index cardinality if it
was up to date. was up to date.
...@@ -46856,8 +46866,6 @@ Fixed bug with BDB tables and keys on @code{BLOB}'s. ...@@ -46856,8 +46866,6 @@ Fixed bug with BDB tables and keys on @code{BLOB}'s.
Fixed bug in @code{MERGE} tables on OS with 32 bit file pointers. Fixed bug in @code{MERGE} tables on OS with 32 bit file pointers.
@item @item
Fixed bug in @code{TIME_TO_SEC()} when using negative values. Fixed bug in @code{TIME_TO_SEC()} when using negative values.
@item
Fixed core dump bug in @code{ALTER TABLE} on a @code{TEMPORARY} InnoDB table.
@end itemize @end itemize
@node News-3.23.44, News-3.23.43, News-3.23.45, News-3.23.x @node News-3.23.44, News-3.23.43, News-3.23.45, News-3.23.x
...@@ -41,7 +41,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, ...@@ -41,7 +41,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
ha_checksum *key_checksum, uint level); ha_checksum *key_checksum, uint level);
static uint isam_key_length(MI_INFO *info,MI_KEYDEF *keyinfo); static uint isam_key_length(MI_INFO *info,MI_KEYDEF *keyinfo);
static ha_checksum calc_checksum(ha_rows count); static ha_checksum calc_checksum(ha_rows count);
static int writekeys(MI_INFO *info,byte *buff,my_off_t filepos); static int writekeys(MI_CHECK *param, MI_INFO *info,byte *buff,
my_off_t filepos);
static int sort_one_index(MI_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo, static int sort_one_index(MI_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo,
my_off_t pagepos, File new_file); my_off_t pagepos, File new_file);
static int sort_key_read(SORT_INFO *sort_info,void *key); static int sort_key_read(SORT_INFO *sort_info,void *key);
...@@ -61,7 +62,8 @@ static void update_key_parts(MI_KEYDEF *keyinfo, ...@@ -61,7 +62,8 @@ static void update_key_parts(MI_KEYDEF *keyinfo,
ulonglong *unique, ulonglong *unique,
ulonglong records); ulonglong records);
static ha_checksum mi_byte_checksum(const byte *buf, uint length); static ha_checksum mi_byte_checksum(const byte *buf, uint length);
static void set_data_file_type(MI_CHECK *param, SORT_INFO *info,
MYISAM_SHARE *share);
#ifdef __WIN__ #ifdef __WIN__
static double ulonglong2double(ulonglong value) static double ulonglong2double(ulonglong value)
...@@ -1179,15 +1181,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, ...@@ -1179,15 +1181,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
sort_info->dupp=0; sort_info->dupp=0;
sort_info->fix_datafile= (my_bool) (! rep_quick); sort_info->fix_datafile= (my_bool) (! rep_quick);
sort_info->max_records= ~(ha_rows) 0; sort_info->max_records= ~(ha_rows) 0;
if ((sort_info->new_data_file_type=share->data_file_type) ==
COMPRESSED_RECORD && param->testflag & T_UNPACK)
{
if (share->options & HA_OPTION_PACK_RECORD)
sort_info->new_data_file_type = DYNAMIC_RECORD;
else
sort_info->new_data_file_type = STATIC_RECORD;
}
set_data_file_type(param, sort_info, share);
del=info->state->del; del=info->state->del;
info->state->records=info->state->del=share->state.split=0; info->state->records=info->state->del=share->state.split=0;
info->state->empty=0; info->state->empty=0;
...@@ -1215,9 +1210,10 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, ...@@ -1215,9 +1210,10 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
lock_memory(param); /* Everything is alloced */ lock_memory(param); /* Everything is alloced */
while (!(error=sort_get_next_record(sort_info))) while (!(error=sort_get_next_record(sort_info)))
{ {
if (writekeys(info,(byte*) sort_info->record,sort_info->filepos)) if (writekeys(param, info,(byte*) sort_info->record,sort_info->filepos))
{ {
if (my_errno != HA_ERR_FOUND_DUPP_KEY) goto err; if (my_errno != HA_ERR_FOUND_DUPP_KEY)
goto err;
DBUG_DUMP("record",(byte*) sort_info->record,share->base.pack_reclength); DBUG_DUMP("record",(byte*) sort_info->record,share->base.pack_reclength);
mi_check_print_info(param,"Duplicate key %2d for record at %10s against new record at %10s", mi_check_print_info(param,"Duplicate key %2d for record at %10s against new record at %10s",
info->errkey+1, info->errkey+1,
...@@ -1356,7 +1352,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, ...@@ -1356,7 +1352,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
/* Uppate keyfile when doing repair */ /* Uppate keyfile when doing repair */
static int writekeys(register MI_INFO *info,byte *buff,my_off_t filepos) static int writekeys(MI_CHECK *param, register MI_INFO *info, byte *buff,
my_off_t filepos)
{ {
register uint i; register uint i;
uchar *key; uchar *key;
...@@ -1369,12 +1366,14 @@ static int writekeys(register MI_INFO *info,byte *buff,my_off_t filepos) ...@@ -1369,12 +1366,14 @@ static int writekeys(register MI_INFO *info,byte *buff,my_off_t filepos)
{ {
if (info->s->keyinfo[i].flag & HA_FULLTEXT ) if (info->s->keyinfo[i].flag & HA_FULLTEXT )
{ {
if (_mi_ft_add(info,i,(char*) key,buff,filepos)) goto err; if (_mi_ft_add(info,i,(char*) key,buff,filepos))
goto err;
} }
else else
{ {
uint key_length=_mi_make_key(info,i,key,buff,filepos); uint key_length=_mi_make_key(info,i,key,buff,filepos);
if (_mi_ck_write(info,i,key,key_length)) goto err; if (_mi_ck_write(info,i,key,key_length))
goto err;
} }
} }
} }
...@@ -1390,16 +1389,21 @@ static int writekeys(register MI_INFO *info,byte *buff,my_off_t filepos) ...@@ -1390,16 +1389,21 @@ static int writekeys(register MI_INFO *info,byte *buff,my_off_t filepos)
{ {
if (info->s->keyinfo[i].flag & HA_FULLTEXT) if (info->s->keyinfo[i].flag & HA_FULLTEXT)
{ {
if (_mi_ft_del(info,i,(char*) key,buff,filepos)) break; if (_mi_ft_del(info,i,(char*) key,buff,filepos))
break;
} }
else else
{ {
uint key_length=_mi_make_key(info,i,key,buff,filepos); uint key_length=_mi_make_key(info,i,key,buff,filepos);
if (_mi_ck_delete(info,i,key,key_length)) break; if (_mi_ck_delete(info,i,key,key_length))
break;
} }
} }
} }
} }
/* Remove checksum that was added to glob_crc in sort_get_next_record */
if (param->calc_checksum)
param->glob_crc-= info->checksum;
DBUG_PRINT("error",("errno: %d",my_errno)); DBUG_PRINT("error",("errno: %d",my_errno));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} /* writekeys */ } /* writekeys */
...@@ -1840,15 +1844,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -1840,15 +1844,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
sort_info->info=info; sort_info->info=info;
sort_info->param = param; sort_info->param = param;
if ((sort_info->new_data_file_type=share->data_file_type) == set_data_file_type(param, sort_info, share);
COMPRESSED_RECORD && param->testflag & T_UNPACK)
{
if (share->options & HA_OPTION_PACK_RECORD)
sort_info->new_data_file_type = DYNAMIC_RECORD;
else
sort_info->new_data_file_type = STATIC_RECORD;
}
sort_info->filepos=new_header_length; sort_info->filepos=new_header_length;
sort_info->dupp=0; sort_info->dupp=0;
sort_info->buff=0; sort_info->buff=0;
...@@ -2129,7 +2125,8 @@ static int sort_get_next_record(SORT_INFO *sort_info) ...@@ -2129,7 +2125,8 @@ static int sort_get_next_record(SORT_INFO *sort_info)
if (*sort_info->record) if (*sort_info->record)
{ {
if (param->calc_checksum) if (param->calc_checksum)
param->glob_crc+= mi_static_checksum(info,sort_info->record); param->glob_crc+= (info->checksum=
mi_static_checksum(info,sort_info->record));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (!sort_info->fix_datafile) if (!sort_info->fix_datafile)
...@@ -2582,7 +2579,7 @@ static int sort_key_write(SORT_INFO *sort_info, const void *a) ...@@ -2582,7 +2579,7 @@ static int sort_key_write(SORT_INFO *sort_info, const void *a)
sort_info->key_block-> sort_info->key_block->
lastkey), lastkey),
llbuff2)); llbuff2));
param->error_printed=param->retry_without_quick=1; param->retry_without_quick=1;
if (sort_info->param->testflag & T_VERBOSE) if (sort_info->param->testflag & T_VERBOSE)
_mi_print_key(stdout,sort_info->keyseg,(uchar*) a, USE_WHOLE_KEY); _mi_print_key(stdout,sort_info->keyseg,(uchar*) a, USE_WHOLE_KEY);
return (sort_delete_record(param)); return (sort_delete_record(param));
...@@ -3235,3 +3232,25 @@ my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ...@@ -3235,3 +3232,25 @@ my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows,
} }
return TRUE; return TRUE;
} }
static void
set_data_file_type(MI_CHECK *param, SORT_INFO *sort_info, MYISAM_SHARE *share)
{
if ((sort_info->new_data_file_type=share->data_file_type) ==
COMPRESSED_RECORD && param->testflag & T_UNPACK)
{
MYISAM_SHARE tmp;
if (share->options & HA_OPTION_PACK_RECORD)
sort_info->new_data_file_type = DYNAMIC_RECORD;
else
sort_info->new_data_file_type = STATIC_RECORD;
/* Set delete_function for sort_delete_record() */
memcpy((char*) &tmp, share, sizeof(*share));
tmp.options= ~HA_OPTION_COMPRESS_RECORD;
mi_setup_functions(&tmp);
share->delete_record=tmp.delete_record;
}
}
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "static.c" #include "static.c"
#endif #endif
static void setup_functions(MYISAM_SHARE *info);
static void setup_key_functions(MI_KEYDEF *keyinfo); static void setup_key_functions(MI_KEYDEF *keyinfo);
#define get_next_element(to,pos,size) { memcpy((char*) to,pos,(size_t) size); \ #define get_next_element(to,pos,size) { memcpy((char*) to,pos,(size_t) size); \
pos+=size;} pos+=size;}
...@@ -392,7 +391,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -392,7 +391,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
else if (share->options & HA_OPTION_PACK_RECORD) else if (share->options & HA_OPTION_PACK_RECORD)
share->data_file_type = DYNAMIC_RECORD; share->data_file_type = DYNAMIC_RECORD;
my_afree((gptr) disk_cache); my_afree((gptr) disk_cache);
setup_functions(share); mi_setup_functions(share);
#ifdef THREAD #ifdef THREAD
thr_lock_init(&share->lock); thr_lock_init(&share->lock);
VOID(pthread_mutex_init(&share->intern_lock,MY_MUTEX_INIT_FAST)); VOID(pthread_mutex_init(&share->intern_lock,MY_MUTEX_INIT_FAST));
...@@ -566,7 +565,7 @@ ulonglong mi_safe_mul(ulonglong a, ulonglong b) ...@@ -566,7 +565,7 @@ ulonglong mi_safe_mul(ulonglong a, ulonglong b)
/* Set up functions in structs */ /* Set up functions in structs */
static void setup_functions(register MYISAM_SHARE *share) void mi_setup_functions(register MYISAM_SHARE *share)
{ {
if (share->options & HA_OPTION_COMPRESS_RECORD) if (share->options & HA_OPTION_COMPRESS_RECORD)
{ {
......
...@@ -785,7 +785,10 @@ static void decode_bytes(MI_COLUMNDEF *rec,MI_BIT_BUFF *bit_buff,uchar *to, ...@@ -785,7 +785,10 @@ static void decode_bytes(MI_COLUMNDEF *rec,MI_BIT_BUFF *bit_buff,uchar *to,
if (bits <= 32) if (bits <= 32)
{ {
if (bit_buff->pos > bit_buff->end+4) if (bit_buff->pos > bit_buff->end+4)
{
bit_buff->error=1;
return; /* Can't be right */ return; /* Can't be right */
}
bit_buff->current_byte= (bit_buff->current_byte << 32) + bit_buff->current_byte= (bit_buff->current_byte << 32) +
((((uint) bit_buff->pos[3])) + ((((uint) bit_buff->pos[3])) +
(((uint) bit_buff->pos[2]) << 8) + (((uint) bit_buff->pos[2]) << 8) +
...@@ -829,7 +832,8 @@ static void decode_bytes(MI_COLUMNDEF *rec,MI_BIT_BUFF *bit_buff,uchar *to, ...@@ -829,7 +832,8 @@ static void decode_bytes(MI_COLUMNDEF *rec,MI_BIT_BUFF *bit_buff,uchar *to,
#else #else
static void decode_bytes(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to, uchar *end) static void decode_bytes(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to,
uchar *end)
{ {
reg1 uint bits,low_byte; reg1 uint bits,low_byte;
reg3 uint16 *pos; reg3 uint16 *pos;
...@@ -846,7 +850,10 @@ static void decode_bytes(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to, uc ...@@ -846,7 +850,10 @@ static void decode_bytes(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to, uc
if (bits < table_bits) if (bits < table_bits)
{ {
if (bit_buff->pos > bit_buff->end+1) if (bit_buff->pos > bit_buff->end+1)
{
bit_buff->error=1;
return; /* Can't be right */ return; /* Can't be right */
}
#if BITS_SAVED == 32 #if BITS_SAVED == 32
bit_buff->current_byte= (bit_buff->current_byte << 24) + bit_buff->current_byte= (bit_buff->current_byte << 24) +
(((uint) ((uchar) bit_buff->pos[2]))) + (((uint) ((uchar) bit_buff->pos[2]))) +
......
...@@ -204,7 +204,7 @@ static struct option long_options[] = ...@@ -204,7 +204,7 @@ static struct option long_options[] =
static void print_version(void) static void print_version(void)
{ {
printf("%s Ver 1.51 for %s at %s\n",my_progname,SYSTEM_TYPE, printf("%s Ver 1.53 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE); MACHINE_TYPE);
} }
......
...@@ -635,6 +635,7 @@ void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows); ...@@ -635,6 +635,7 @@ void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows);
my_bool check_table_is_closed(const char *name, const char *where); my_bool check_table_is_closed(const char *name, const char *where);
int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share); int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share);
int mi_open_keyfile(MYISAM_SHARE *share); int mi_open_keyfile(MYISAM_SHARE *share);
void mi_setup_functions(register MYISAM_SHARE *share);
/* Functions needed by mi_check */ /* Functions needed by mi_check */
void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...)); void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...));
......
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