Commit 08bb74b6 authored by unknown's avatar unknown

Fixes for automatic repair


Docs/manual.texi:
  Clarifications
myisam/mi_check.c:
  Cleanup
myisam/myisamdef.h:
  Header file fix
sql/ha_myisam.cc:
  Fix for repair
sql/sql_base.cc:
  Fix for repair
parent 6842cd1c
...@@ -16319,7 +16319,8 @@ Version 3.22. @code{ADDDATE()} and @code{SUBDATE()} are synonyms for ...@@ -16319,7 +16319,8 @@ Version 3.22. @code{ADDDATE()} and @code{SUBDATE()} are synonyms for
@code{DATE_ADD()} and @code{DATE_SUB()}. @code{DATE_ADD()} and @code{DATE_SUB()}.
In @strong{MySQL} Version 3.23, you can use @code{+} and @code{-} instead of In @strong{MySQL} Version 3.23, you can use @code{+} and @code{-} instead of
@code{DATE_ADD()} and @code{DATE_SUB()}. (See example) @code{DATE_ADD()} and @code{DATE_SUB()} if the expression on the right side is
a date or datetime column. (See example)
@code{date} is a @code{DATETIME} or @code{DATE} value specifying the starting @code{date} is a @code{DATETIME} or @code{DATE} value specifying the starting
date. @code{expr} is an expression specifying the interval value to be added date. @code{expr} is an expression specifying the interval value to be added
...@@ -20221,7 +20222,9 @@ this join type is good. ...@@ -20221,7 +20222,9 @@ this join type is good.
@item range @item range
Only rows that are in a given range will be retrieved, using an index to Only rows that are in a given range will be retrieved, using an index to
select the rows. The @code{ref} column indicates which index is used. select the rows. The @code{key} column indicates which index is used.
The @code{key_len} contains the longest key part that was used.
The @code{ref} column will be NULL for this type.
@item index @item index
This is the same as @code{ALL}, except that only the index tree is This is the same as @code{ALL}, except that only the index tree is
...@@ -504,7 +504,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, ...@@ -504,7 +504,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
if (used_length > keyinfo->block_length) if (used_length > keyinfo->block_length)
{ {
mi_check_print_error(param,"Wrong pageinfo at page: %s", llstr(page,llbuff)); mi_check_print_error(param,"Wrong pageinfo at page: %s",
llstr(page,llbuff));
goto err; goto err;
} }
for ( ;; ) for ( ;; )
......
...@@ -575,6 +575,10 @@ enum myisam_log_commands { ...@@ -575,6 +575,10 @@ enum myisam_log_commands {
#define myisam_log_command(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_command(a,b,c,d,e) #define myisam_log_command(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_command(a,b,c,d,e)
#define myisam_log_record(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_record(a,b,c,d,e) #define myisam_log_record(a,b,c,d,e) if (myisam_log_file >= 0) _myisam_log_record(a,b,c,d,e)
#ifdef __cplusplus
extern "C" {
#endif
extern uint _mi_get_block_info(MI_BLOCK_INFO *,File, my_off_t); extern uint _mi_get_block_info(MI_BLOCK_INFO *,File, my_off_t);
extern uint _mi_rec_pack(MI_INFO *info,byte *to,const byte *from); extern uint _mi_rec_pack(MI_INFO *info,byte *to,const byte *from);
extern uint _mi_pack_get_block_info(MI_INFO *mysql, MI_BLOCK_INFO *, File, extern uint _mi_pack_get_block_info(MI_INFO *mysql, MI_BLOCK_INFO *, File,
...@@ -630,9 +634,6 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share); ...@@ -630,9 +634,6 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share);
int mi_open_keyfile(MYISAM_SHARE *share); int mi_open_keyfile(MYISAM_SHARE *share);
/* Functions needed by mi_check */ /* Functions needed by mi_check */
#ifdef __cplusplus
extern "C" {
#endif
void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...)); void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...));
void mi_check_print_warning _VARARGS((MI_CHECK *param, const char *fmt,...)); void mi_check_print_warning _VARARGS((MI_CHECK *param, const char *fmt,...));
void mi_check_print_info _VARARGS((MI_CHECK *param, const char *fmt,...)); void mi_check_print_info _VARARGS((MI_CHECK *param, const char *fmt,...));
......
...@@ -57,6 +57,8 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, ...@@ -57,6 +57,8 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
my_vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); my_vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
msgbuf[sizeof(msgbuf) - 1] = 0; // healthy paranoia msgbuf[sizeof(msgbuf) - 1] = 0; // healthy paranoia
DBUG_PRINT(msg_type,("message: %s",msgbuf));
if (thd->net.vio == 0) if (thd->net.vio == 0)
{ {
sql_print_error(msgbuf); sql_print_error(msgbuf);
...@@ -413,8 +415,8 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) ...@@ -413,8 +415,8 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
myisamchk_init(&param); myisamchk_init(&param);
param.thd = thd; param.thd = thd;
param.op_name = (char*) "repair"; param.op_name = (char*) "repair";
param.testflag = (check_opt->flags | T_SILENT | T_FORCE_CREATE | param.testflag = ((check_opt->flags | T_SILENT | T_FORCE_CREATE) |
T_REP_BY_SORT); (check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT));
if (check_opt->quick) if (check_opt->quick)
param.opt_rep_quick++; param.opt_rep_quick++;
param.sort_buffer_length= check_opt->sort_buffer_size; param.sort_buffer_length= check_opt->sort_buffer_size;
...@@ -430,7 +432,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) ...@@ -430,7 +432,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
if ((param.testflag & T_REP_BY_SORT)) if ((param.testflag & T_REP_BY_SORT))
{ {
param.testflag= (param.testflag & ~T_REP_BY_SORT) | T_REP; param.testflag= (param.testflag & ~T_REP_BY_SORT) | T_REP;
sql_print_error("Warning: Retrying recover of: %s with safe repair", sql_print_error("Warning: Retrying recover of: %s with keycache",
table->path); table->path);
continue; continue;
} }
...@@ -463,13 +465,14 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize) ...@@ -463,13 +465,14 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
char fixed_name[FN_REFLEN]; char fixed_name[FN_REFLEN];
const char *old_proc_info=thd->proc_info; const char *old_proc_info=thd->proc_info;
MYISAM_SHARE* share = file->s; MYISAM_SHARE* share = file->s;
DBUG_ENTER("ha_myisam::repair");
param.table_name = table->table_name; param.table_name = table->table_name;
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;
param.out_flag=0;
VOID(fn_format(fixed_name,file->filename,"",MI_NAME_IEXT, VOID(fn_format(fixed_name,file->filename,"",MI_NAME_IEXT,
4+ (param.opt_follow_links ? 16 : 0))); 4+ (param.opt_follow_links ? 16 : 0)));
...@@ -479,15 +482,16 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize) ...@@ -479,15 +482,16 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
!(share->state.changed & STATE_NOT_OPTIMIZED_KEYS)))) !(share->state.changed & STATE_NOT_OPTIMIZED_KEYS))))
{ {
optimize_done=1; optimize_done=1;
if (mi_test_if_sort_rep(file,file->state->records,0)) if (mi_test_if_sort_rep(file,file->state->records,0) &&
(param.testflag & T_REP_BY_SORT))
{ {
param.testflag|= T_STATISTICS; // We get this for free param.testflag|= T_STATISTICS; // We get this for free
thd->proc_info="Repairing by sorting"; thd->proc_info="Repair by sorting";
error = mi_repair_by_sort(&param, file, fixed_name, param.opt_rep_quick); error = mi_repair_by_sort(&param, file, fixed_name, param.opt_rep_quick);
} }
else else
{ {
thd->proc_info="Repairing"; thd->proc_info="Repair with keycache";
error= mi_repair(&param, file, fixed_name, param.opt_rep_quick); error= mi_repair(&param, file, fixed_name, param.opt_rep_quick);
} }
} }
...@@ -558,8 +562,9 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize) ...@@ -558,8 +562,9 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
} }
if (param.out_flag & O_NEW_DATA) if (param.out_flag & O_NEW_DATA)
error|=change_to_newfile(fixed_name,MI_NAME_DEXT, error|=change_to_newfile(fixed_name,MI_NAME_DEXT,
DATA_TMP_EXT, 0, MYF(0)); DATA_TMP_EXT, 0,
(param.testflag & T_BACKUP_DATA ?
MYF(MY_REDEL_MAKE_BACKUP): MYF(0)));
if (param.out_flag & O_NEW_INDEX) if (param.out_flag & O_NEW_INDEX)
error|=change_to_newfile(fixed_name,MI_NAME_IEXT, error|=change_to_newfile(fixed_name,MI_NAME_IEXT,
INDEX_TMP_EXT, 0, MYF(0)); INDEX_TMP_EXT, 0, MYF(0));
...@@ -574,7 +579,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize) ...@@ -574,7 +579,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
} }
} }
thd->proc_info=old_proc_info; thd->proc_info=old_proc_info;
return (error ? HA_ADMIN_FAILED : DBUG_RETURN(error ? HA_ADMIN_FAILED :
!optimize_done ? HA_ADMIN_ALREADY_DONE : HA_ADMIN_OK); !optimize_done ? HA_ADMIN_ALREADY_DONE : HA_ADMIN_OK);
} }
......
...@@ -1165,6 +1165,10 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, ...@@ -1165,6 +1165,10 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
entry) || entry) ||
(entry->file->is_crashed() && entry->file->check_and_repair(thd))) (entry->file->is_crashed() && entry->file->check_and_repair(thd)))
{ {
/* Give right error message */
thd->net.last_error[0]=0;
thd->net.last_errno=0;
entry->file->print_error(HA_ERR_CRASHED,MYF(0));
sql_print_error("Error: Couldn't repair table: %s.%s",db,name); sql_print_error("Error: Couldn't repair table: %s.%s",db,name);
closefrm(entry); closefrm(entry);
error=1; error=1;
......
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