summaryrefslogtreecommitdiff
path: root/storage/maria
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2012-03-28 13:49:07 +0300
committerMichael Widenius <monty@askmonty.org>2012-03-28 13:49:07 +0300
commit3bc932ec175ae9ac2fc6c0c5be29002819c9b102 (patch)
tree142e8c1fdf2e1cd20740c27716b4fb692895db41 /storage/maria
parentc88e2679c60f56719b6d347c30374e69ffd3d5c4 (diff)
parent74b064933267f58b9201c46eb67454237d7664d3 (diff)
downloadmariadb-git-3bc932ec175ae9ac2fc6c0c5be29002819c9b102.tar.gz
Merge with 5.1
Diffstat (limited to 'storage/maria')
-rw-r--r--storage/maria/ha_maria.cc23
-rw-r--r--storage/maria/ha_maria.h10
-rw-r--r--storage/maria/ma_open.c2
3 files changed, 31 insertions, 4 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 1e8a03d3990..f47ad47df41 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -53,6 +53,9 @@ C_MODE_END
ulong pagecache_division_limit, pagecache_age_threshold;
ulonglong pagecache_buffer_size;
+const char *zerofill_error_msg=
+ "Table is from another system and must be zerofilled or repaired to be "
+ "usable on this system";
/**
As the auto-repair is initiated when opened from the SQL layer
@@ -1024,7 +1027,15 @@ int ha_maria::open(const char *name, int mode, uint test_if_locked)
}
if (!(file= maria_open(name, mode, test_if_locked | HA_OPEN_FROM_SQL_LAYER)))
+ {
+ if (my_errno == HA_ERR_OLD_FILE)
+ {
+ push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_CRASHED_ON_USAGE,
+ zerofill_error_msg);
+ }
return (my_errno ? my_errno : -1);
+ }
file->s->chst_invalidator= query_cache_invalidate_by_MyISAM_filename_ref;
@@ -1124,6 +1135,13 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
return HA_ADMIN_ALREADY_DONE;
maria_chk_init_for_check(&param, file);
+ if ((file->s->state.changed & (STATE_CRASHED_FLAGS | STATE_MOVED)) ==
+ STATE_MOVED)
+ {
+ _ma_check_print_error(&param, zerofill_error_msg);
+ return HA_ADMIN_CORRUPT;
+ }
+
(void) maria_chk_status(&param, file); // Not fatal
error= maria_chk_size(&param, file);
if (!error)
@@ -2080,6 +2098,11 @@ bool ha_maria::check_and_repair(THD *thd)
if ((file->s->state.changed & (STATE_CRASHED_FLAGS | STATE_MOVED)) ==
STATE_MOVED)
{
+ /* Remove error about crashed table */
+ mysql_reset_errors(thd, true);
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_CRASHED_ON_USAGE,
+ "Zerofilling moved table %s", table->s->path.str);
sql_print_information("Zerofilling moved table: '%s'",
table->s->path.str);
if (!(error= zerofill(thd, &check_opt)))
diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h
index 2cfa2d8cd9b..8062b235d7d 100644
--- a/storage/maria/ha_maria.h
+++ b/storage/maria/ha_maria.h
@@ -136,8 +136,14 @@ public:
bool check_and_repair(THD * thd);
bool is_crashed() const;
bool is_changed() const;
- bool auto_repair() const
- { return test(maria_recover_options & HA_RECOVER_ANY); }
+ bool auto_repair(int error) const
+ {
+ /* Always auto-repair moved tables (error == HA_ERR_OLD_FILE) */
+ return ((test(maria_recover_options & HA_RECOVER_ANY) &&
+ error == HA_ERR_CRASHED_ON_USAGE) ||
+ error == HA_ERR_OLD_FILE);
+
+ }
int optimize(THD * thd, HA_CHECK_OPT * check_opt);
int restore(THD * thd, HA_CHECK_OPT * check_opt);
int backup(THD * thd, HA_CHECK_OPT * check_opt);
diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c
index 2ffbfecb854..d3e758ada58 100644
--- a/storage/maria/ma_open.c
+++ b/storage/maria/ma_open.c
@@ -987,8 +987,6 @@ err:
tmp_name.length= strlen(name);
_ma_report_error(save_errno, &tmp_name);
}
- if (save_errno == HA_ERR_OLD_FILE) /* uuid is different ? */
- save_errno= HA_ERR_CRASHED_ON_USAGE; /* the code to trigger auto-repair */
switch (errpos) {
case 5:
if (data_file >= 0)