Commit b8416bce authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-maria

into  janus.mylan:/usr/home/serg/Abk/mysql-maria


dbug/dbug.c:
  Auto merged
include/my_dbug.h:
  Auto merged
storage/maria/ha_maria.cc:
  Auto merged
storage/maria/ma_check.c:
  Auto merged
storage/maria/ma_open.c:
  Auto merged
storage/maria/maria_def.h:
  Auto merged
parents 7e7c534b 0bbccfde
...@@ -951,7 +951,6 @@ void _db_enter_(const char *_func_, const char *_file_, ...@@ -951,7 +951,6 @@ void _db_enter_(const char *_func_, const char *_file_,
*_slevel_= 0; /* Set to avoid valgrind warnings if dbug is enabled later */ *_slevel_= 0; /* Set to avoid valgrind warnings if dbug is enabled later */
return; return;
} }
get_code_state_or_return;
save_errno= errno; save_errno= errno;
*_sfunc_= cs->func; *_sfunc_= cs->func;
......
...@@ -82,8 +82,8 @@ extern void _db_force_flush(); ...@@ -82,8 +82,8 @@ extern void _db_force_flush();
#define DBUG_ASSERT(A) assert(A) #define DBUG_ASSERT(A) assert(A)
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len)) #define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len)) #define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
#define DEBUGGER_OFF _dbug_on_= 0 #define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
#define DEBUGGER_ON _dbug_on_= 1 #define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
#define IF_DBUG(A) A #define IF_DBUG(A) A
#else /* No debugger */ #else /* No debugger */
...@@ -108,11 +108,11 @@ extern void _db_force_flush(); ...@@ -108,11 +108,11 @@ extern void _db_force_flush();
#define DBUG_ASSERT(A) do { } while(0) #define DBUG_ASSERT(A) do { } while(0)
#define DBUG_LOCK_FILE #define DBUG_LOCK_FILE
#define DBUG_FILE (stderr) #define DBUG_FILE (stderr)
#define DEBUGGER_OFF
#define DEBUGGER_ON
#define DBUG_UNLOCK_FILE #define DBUG_UNLOCK_FILE
#define DBUG_EXPLAIN(buf,len) #define DBUG_EXPLAIN(buf,len)
#define DBUG_EXPLAIN_INITIAL(buf,len) #define DBUG_EXPLAIN_INITIAL(buf,len)
#define DEBUGGER_OFF do { } while(0)
#define DEBUGGER_ON do { } while(0)
#define IF_DBUG(A) #define IF_DBUG(A)
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -1181,6 +1181,24 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt) ...@@ -1181,6 +1181,24 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt)
return error; return error;
} }
int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
HA_CHECK param;
if (!file)
return HA_ADMIN_INTERNAL_ERROR;
maria_chk_init(&param);
param.thd= thd;
param.op_name= "zerofill";
param.testflag= check_opt->flags | T_SILENT | T_ZEROFILL;
param.sort_buffer_length= check_opt->sort_buffer_size;
error=maria_zerofill(&param, file, file->s->open_file_name);
return error;
}
int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt) int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt)
{ {
int error; int error;
...@@ -1736,7 +1754,7 @@ int ha_maria::end_bulk_insert() ...@@ -1736,7 +1754,7 @@ int ha_maria::end_bulk_insert()
bool ha_maria::check_and_repair(THD *thd) bool ha_maria::check_and_repair(THD *thd)
{ {
int error= 0; int error;
int marked_crashed; int marked_crashed;
char *old_query; char *old_query;
uint old_query_length; uint old_query_length;
...@@ -1744,6 +1762,24 @@ bool ha_maria::check_and_repair(THD *thd) ...@@ -1744,6 +1762,24 @@ bool ha_maria::check_and_repair(THD *thd)
DBUG_ENTER("ha_maria::check_and_repair"); DBUG_ENTER("ha_maria::check_and_repair");
check_opt.init(); check_opt.init();
if (file->s->state.changed & STATE_MOVED)
{
sql_print_information("Zerofilling table: '%s'", table->s->path.str);
if (!(error= zerofill(thd, &check_opt)))
DBUG_RETURN(0);
}
else
error= 1;
/*
if we got this far - the table is crashed.
but don't auto-repair if maria_recover_options is not set
*/
if (!maria_recover_options)
DBUG_RETURN(error);
error= 0;
check_opt.flags= T_MEDIUM | T_AUTO_REPAIR; check_opt.flags= T_MEDIUM | T_AUTO_REPAIR;
// Don't use quick if deleted rows // Don't use quick if deleted rows
if (!file->state->del && (maria_recover_options & HA_RECOVER_QUICK)) if (!file->state->del && (maria_recover_options & HA_RECOVER_QUICK))
...@@ -1778,7 +1814,7 @@ bool ha_maria::check_and_repair(THD *thd) ...@@ -1778,7 +1814,7 @@ bool ha_maria::check_and_repair(THD *thd)
bool ha_maria::is_crashed() const bool ha_maria::is_crashed() const
{ {
return (file->s->state.changed & STATE_CRASHED || return (file->s->state.changed & (STATE_CRASHED | STATE_MOVED) ||
(my_disable_locking && file->s->state.open_count)); (my_disable_locking && file->s->state.open_count));
} }
......
...@@ -41,6 +41,7 @@ class ha_maria :public handler ...@@ -41,6 +41,7 @@ class ha_maria :public handler
enum data_file_type data_file_type; enum data_file_type data_file_type;
bool can_enable_indexes; bool can_enable_indexes;
int repair(THD * thd, HA_CHECK &param, bool optimize); int repair(THD * thd, HA_CHECK &param, bool optimize);
int zerofill(THD * thd, HA_CHECK_OPT *check_opt);
public: public:
ha_maria(handlerton *hton, TABLE_SHARE * table_arg); ha_maria(handlerton *hton, TABLE_SHARE * table_arg);
...@@ -133,8 +134,7 @@ public: ...@@ -133,8 +134,7 @@ public:
int repair(THD * thd, HA_CHECK_OPT * check_opt); int repair(THD * thd, HA_CHECK_OPT * check_opt);
bool check_and_repair(THD * thd); bool check_and_repair(THD * thd);
bool is_crashed() const; bool is_crashed() const;
bool auto_repair() const bool auto_repair() const { return 1; }
{ return maria_recover_options != 0; }
int optimize(THD * thd, HA_CHECK_OPT * check_opt); int optimize(THD * thd, HA_CHECK_OPT * check_opt);
int restore(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); int backup(THD * thd, HA_CHECK_OPT * check_opt);
......
...@@ -3079,7 +3079,8 @@ int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name) ...@@ -3079,7 +3079,8 @@ int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name)
Mark that table is movable and that we have done zerofill of data and Mark that table is movable and that we have done zerofill of data and
index index
*/ */
info->s->state.changed&= ~(STATE_NOT_ZEROFILLED | STATE_NOT_MOVABLE); info->s->state.changed&= ~(STATE_NOT_ZEROFILLED | STATE_NOT_MOVABLE |
STATE_MOVED);
/* Ensure state are flushed to disk */ /* Ensure state are flushed to disk */
info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -396,6 +396,17 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -396,6 +396,17 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
goto err; goto err;
} }
if (memcmp(share->base.uuid, maria_uuid, MY_UUID_SIZE))
{
if (open_flags & HA_OPEN_FOR_REPAIR)
share->state.changed|= STATE_MOVED;
else
{
my_errno= HA_ERR_OLD_FILE;
goto err;
}
}
/* sanity check */ /* sanity check */
if (share->base.keystart > 65535 || share->base.rec_reflength > 8) if (share->base.keystart > 65535 || share->base.rec_reflength > 8)
{ {
...@@ -796,6 +807,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -796,6 +807,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
if (!(m_info= maria_clone_internal(share, mode, data_file))) if (!(m_info= maria_clone_internal(share, mode, data_file)))
goto err; goto err;
pthread_mutex_unlock(&THR_LOCK_maria); pthread_mutex_unlock(&THR_LOCK_maria);
DBUG_RETURN(m_info); DBUG_RETURN(m_info);
...@@ -805,6 +817,8 @@ err: ...@@ -805,6 +817,8 @@ err:
(save_errno == HA_ERR_CRASHED_ON_USAGE) || (save_errno == HA_ERR_CRASHED_ON_USAGE) ||
(save_errno == HA_ERR_CRASHED_ON_REPAIR)) (save_errno == HA_ERR_CRASHED_ON_REPAIR))
_ma_report_error(save_errno, name); _ma_report_error(save_errno, 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) { switch (errpos) {
case 5: case 5:
if (data_file >= 0) if (data_file >= 0)
......
...@@ -548,6 +548,7 @@ struct st_maria_handler ...@@ -548,6 +548,7 @@ struct st_maria_handler
#define STATE_NOT_OPTIMIZED_ROWS 64 #define STATE_NOT_OPTIMIZED_ROWS 64
#define STATE_NOT_ZEROFILLED 128 #define STATE_NOT_ZEROFILLED 128
#define STATE_NOT_MOVABLE 256 #define STATE_NOT_MOVABLE 256
#define STATE_MOVED 512 /* set if base->uuid != maria_uuid */
/* options to maria_read_cache */ /* options to maria_read_cache */
......
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