summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_myisam.cc42
-rw-r--r--sql/handler.h9
-rw-r--r--sql/lex.h7
-rw-r--r--sql/slave.cc3
-rw-r--r--sql/sql_yacc.yy41
5 files changed, 53 insertions, 49 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 78ac9f3b309..2247045894c 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -289,7 +289,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
error = chk_key(&param, file);
if (!error)
{
- if ((!check_opt->quick &&
+ if ((!(param.testflag & T_QUICK) &&
((share->options &
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ||
(param.testflag & (T_EXTEND | T_MEDIUM)))) ||
@@ -330,7 +330,6 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
mi_mark_crashed(file);
file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
}
- check_opt->retry_without_quick=param.retry_without_quick;
thd->proc_info=old_proc_info;
return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK;
@@ -397,8 +396,7 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
}
tmp_check_opt.init();
- tmp_check_opt.quick = 1;
- tmp_check_opt.flags |= T_VERY_SILENT | T_CALC_CHECKSUM;
+ tmp_check_opt.flags |= T_VERY_SILENT | T_CALC_CHECKSUM | T_QUICK;
DBUG_RETURN(repair(thd, &tmp_check_opt));
err:
@@ -488,24 +486,23 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
myisamchk_init(&param);
param.thd = thd;
param.op_name = (char*) "repair";
- param.testflag = ((check_opt->flags & ~(T_EXTEND)) |
+ param.testflag = ((check_opt->flags & ~(T_EXTEND)) |
T_SILENT | T_FORCE_CREATE |
(check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT));
- if (check_opt->quick)
- param.opt_rep_quick++;
param.sort_buffer_length= check_opt->sort_buffer_size;
start_records=file->state->records;
while ((error=repair(thd,param,0)) && param.retry_repair)
{
param.retry_repair=0;
- if (param.retry_without_quick && param.opt_rep_quick)
+ if ((param.testflag & T_RETRY_WITHOUT_QUICK) &&
+ (param.testflag & T_QUICK))
{
- param.opt_rep_quick=0;
+ param.testflag&= ~T_RETRY_WITHOUT_QUICK;
sql_print_error("Warning: Retrying repair of: '%s' without quick",
table->path);
continue;
}
- param.opt_rep_quick=0; // Safety
+ param.testflag&= ~T_QUICK;
if ((param.testflag & T_REP_BY_SORT))
{
param.testflag= (param.testflag & ~T_REP_BY_SORT) | T_REP;
@@ -537,8 +534,6 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt)
param.op_name = (char*) "optimize";
param.testflag = (check_opt->flags | T_SILENT | T_FORCE_CREATE |
T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX);
- if (check_opt->quick)
- param.opt_rep_quick++;
param.sort_buffer_length= check_opt->sort_buffer_size;
return repair(thd,param,1);
}
@@ -573,7 +568,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
if (!optimize ||
((file->state->del || share->state.split != file->state->records) &&
- (!param.opt_rep_quick ||
+ (!(param.testflag & T_QUICK) ||
!(share->state.changed & STATE_NOT_OPTIMIZED_KEYS))))
{
ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ?
@@ -587,13 +582,15 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
param.testflag|= T_STATISTICS; // We get this for free
thd->proc_info="Repair by sorting";
statistics_done=1;
- error = mi_repair_by_sort(&param, file, fixed_name, param.opt_rep_quick);
+ error = mi_repair_by_sort(&param, file, fixed_name,
+ param.testflag & T_QUICK);
}
else
{
thd->proc_info="Repair with keycache";
param.testflag &= ~T_REP_BY_SORT;
- error= mi_repair(&param, file, fixed_name, param.opt_rep_quick);
+ error= mi_repair(&param, file, fixed_name,
+ param.testflag & T_QUICK);
}
param.testflag=testflag;
optimize_done=1;
@@ -697,11 +694,10 @@ bool ha_myisam::activate_all_index(THD *thd)
thd->proc_info="Creating index";
myisamchk_init(&param);
param.op_name = (char*) "recreating_index";
- param.testflag = (T_SILENT | T_REP_BY_SORT |
+ param.testflag = (T_SILENT | T_REP_BY_SORT | T_QUICK |
T_CREATE_MISSING_KEYS | T_TRUST_HEADER);
param.myf_rw&= ~MY_WAIT_IF_FULL;
param.sort_buffer_length= myisam_sort_buffer_size;
- param.opt_rep_quick++; // Don't copy data file
param.tmpdir=mysql_tmpdir;
error=repair(thd,param,0) != HA_ADMIN_OK;
thd->proc_info=save_proc_info;
@@ -723,16 +719,16 @@ bool ha_myisam::check_and_repair(THD *thd)
check_opt.flags= T_MEDIUM | T_AUTO_REPAIR;
// Don't use quick if deleted rows
if (!file->state->del && (myisam_recover_options & HA_RECOVER_QUICK))
- check_opt.quick=1;
+ check_opt.flags|=T_QUICK;
sql_print_error("Warning: Checking table: '%s'",table->path);
if ((marked_crashed=mi_is_crashed(file)) || check(thd, &check_opt))
{
sql_print_error("Warning: Recovering table: '%s'",table->path);
- check_opt.quick= !check_opt.retry_without_quick && !marked_crashed;
- check_opt.flags=(((myisam_recover_options & HA_RECOVER_BACKUP) ?
- T_BACKUP_DATA : 0) |
- (!(myisam_recover_options & HA_RECOVER_FORCE) ?
- T_SAFE_REPAIR : 0)) | T_AUTO_REPAIR;
+ check_opt.flags=
+ (myisam_recover_options & HA_RECOVER_BACKUP ? T_BACKUP_DATA : 0)
+ | (marked_crashed ? 0 : T_QUICK)
+ | (myisam_recover_options & HA_RECOVER_FORCE ? 0 : T_SAFE_REPAIR)
+ | T_AUTO_REPAIR;
if (repair(thd, &check_opt))
error=1;
}
diff --git a/sql/handler.h b/sql/handler.h
index b083465afc5..fd59dabce3e 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -174,14 +174,11 @@ extern ulong myisam_sort_buffer_size;
typedef struct st_ha_check_opt
{
ulong sort_buffer_size;
- uint flags;
- bool quick;
- bool changed_files;
- bool optimize;
- bool retry_without_quick;
+ uint flags; /* isam layer flags (e.g. for myisamchk) */
+ uint sql_flags; /* sql layer flags - for something myisamchk cannot do */
inline void init()
{
- flags= 0; quick= optimize= retry_without_quick=0;
+ flags= sql_flags= 0;
sort_buffer_size = myisam_sort_buffer_size;
}
} HA_CHECK_OPT;
diff --git a/sql/lex.h b/sql/lex.h
index 6bee4152e48..46b9e9f4bec 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -62,8 +62,8 @@ static SYMBOL symbols[] = {
{ "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH),0,0},
{ "AUTO_INCREMENT", SYM(AUTO_INC),0,0},
{ "AUTOCOMMIT", SYM(AUTOCOMMIT),0,0},
- { "BACKUP", SYM(BACKUP_SYM),0,0},
- { "BEGIN", SYM(BEGIN_SYM),0,0},
+ { "BACKUP", SYM(BACKUP_SYM),0,0},
+ { "BEGIN", SYM(BEGIN_SYM),0,0},
{ "BERKELEYDB", SYM(BERKELEY_DB_SYM),0,0},
{ "BDB", SYM(BERKELEY_DB_SYM),0,0},
{ "BETWEEN", SYM(BETWEEN_SYM),0,0},
@@ -320,7 +320,7 @@ static SYMBOL symbols[] = {
{ "SQL_LOG_UPDATE", SYM(SQL_LOG_UPDATE),0,0},
{ "SQL_LOW_PRIORITY_UPDATES", SYM(SQL_LOW_PRIORITY_UPDATES),0,0},
{ "SQL_MAX_JOIN_SIZE",SYM(SQL_MAX_JOIN_SIZE), 0, 0},
- { "SQL_NO_CACHE", SYM(SQL_NO_CACHE_SYM), 0, 0},
+ { "SQL_NO_CACHE", SYM(SQL_NO_CACHE_SYM), 0, 0},
{ "SQL_QUERY_CACHE_TYPE",SYM(SQL_QUERY_CACHE_TYPE_SYM), 0, 0},
{ "SQL_QUOTE_SHOW_CREATE",SYM(SQL_QUOTE_SHOW_CREATE), 0, 0},
{ "SQL_SAFE_UPDATES", SYM(SQL_SAFE_UPDATES),0,0},
@@ -359,6 +359,7 @@ static SYMBOL symbols[] = {
{ "UNLOCK", SYM(UNLOCK_SYM),0,0},
{ "UNSIGNED", SYM(UNSIGNED),0,0},
{ "USE", SYM(USE_SYM),0,0},
+ { "USE_FRM", SYM(USE_FRM),0,0},
{ "USING", SYM(USING),0,0},
{ "UPDATE", SYM(UPDATE_SYM),0,0},
{ "USAGE", SYM(USAGE),0,0},
diff --git a/sql/slave.cc b/sql/slave.cc
index 0ffc37eb975..176f5db2f79 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -859,8 +859,7 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db,
}
check_opt.init();
- check_opt.flags|= T_VERY_SILENT | T_CALC_CHECKSUM;
- check_opt.quick = 1;
+ check_opt.flags|= T_VERY_SILENT | T_CALC_CHECKSUM | T_QUICK;
thd->proc_info = "Rebuilding the index on master dump table";
// we do not want repair() to spam us with messages
// just send them to the error log, and report the failure in case of
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 90c16daf407..a7d6f57c3e8 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -322,6 +322,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token UNION_SYM
%token UNIQUE_SYM
%token USAGE
+%token USE_FRM
%token USE_SYM
%token USING
%token VALUES
@@ -1289,7 +1290,6 @@ backup:
Lex->backup_dir = $6.str;
}
-
repair:
REPAIR table_or_tables
{
@@ -1297,24 +1297,20 @@ repair:
lex->sql_command = SQLCOM_REPAIR;
lex->check_opt.init();
}
- table_list opt_mi_check_type
+ table_list opt_mi_repair_type
-
-opt_mi_check_type:
+opt_mi_repair_type:
/* empty */ { Lex->check_opt.flags = T_MEDIUM; }
- | TYPE_SYM EQ mi_check_types {}
- | mi_check_types {}
+ | mi_repair_types {}
-mi_check_types:
- mi_check_type {}
- | mi_check_type mi_check_types {}
+mi_repair_types:
+ mi_repair_type {}
+ | mi_repair_type mi_repair_types {}
-mi_check_type:
- QUICK { Lex->check_opt.quick = 1; }
- | FAST_SYM { Lex->check_opt.flags|= T_FAST; }
- | MEDIUM_SYM { Lex->check_opt.flags|= T_MEDIUM; }
+mi_repair_type:
+ QUICK { Lex->check_opt.flags|= T_QUICK; }
| EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; }
- | CHANGED { Lex->check_opt.flags|= T_CHECK_ONLY_CHANGED; }
+ | USE_FRM { /*Lex->check_opt.flags|= T_USEFRM;*/ }
analyze:
ANALYZE_SYM table_or_tables
@@ -1334,6 +1330,21 @@ check:
}
table_list opt_mi_check_type
+opt_mi_check_type:
+ /* empty */ { Lex->check_opt.flags = T_MEDIUM; }
+ | mi_check_types {}
+
+mi_check_types:
+ mi_check_type {}
+ | mi_check_type mi_check_types {}
+
+mi_check_type:
+ QUICK { Lex->check_opt.flags|= T_QUICK; }
+ | FAST_SYM { Lex->check_opt.flags|= T_FAST; }
+ | MEDIUM_SYM { Lex->check_opt.flags|= T_MEDIUM; }
+ | EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; }
+ | CHANGED { Lex->check_opt.flags|= T_CHECK_ONLY_CHANGED; }
+
optimize:
OPTIMIZE table_or_tables
{
@@ -3061,10 +3072,10 @@ keyword:
| TYPE_SYM {}
| UDF_SYM {}
| UNCOMMITTED_SYM {}
+ | USE_FRM {}
| VARIABLES {}
| WORK_SYM {}
| YEAR_SYM {}
- | SLAVE {}
/* Option functions */