Commit 17a1b194 authored by Marko Mäkelä's avatar Marko Mäkelä

Fix some GCC 6.3.0 warnings in MyISAM and Maria.

The C++ standard does not allow references to be NULL.
Assign the return value of THD::alloc() to a pointer,
not to a reference.
parent 30cac41c
/* Copyright (C) 2004-2008 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
Copyright (C) 2008-2009 Sun Microsystems, Inc.
Copyright (c) 2009, 2014, SkySQL Ab.
Copyright (c) 2009, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -1271,75 +1271,75 @@ int ha_maria::write_row(uchar * buf)
int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
{
int error;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
MARIA_SHARE *share= file->s;
const char *old_proc_info;
TRN *old_trn= file->trn;
if (!file || !&param) return HA_ADMIN_INTERNAL_ERROR;
if (!file || !param) return HA_ADMIN_INTERNAL_ERROR;
maria_chk_init(&param);
param.thd= thd;
param.op_name= "check";
param.db_name= table->s->db.str;
param.table_name= table->alias.c_ptr();
param.testflag= check_opt->flags | T_CHECK | T_SILENT;
param.stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
maria_chk_init(param);
param->thd= thd;
param->op_name= "check";
param->db_name= table->s->db.str;
param->table_name= table->alias.c_ptr();
param->testflag= check_opt->flags | T_CHECK | T_SILENT;
param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
if (!(table->db_stat & HA_READ_ONLY))
param.testflag |= T_STATISTICS;
param.using_global_keycache= 1;
param->testflag |= T_STATISTICS;
param->using_global_keycache= 1;
if (!maria_is_crashed(file) &&
(((param.testflag & T_CHECK_ONLY_CHANGED) &&
(((param->testflag & T_CHECK_ONLY_CHANGED) &&
!(share->state.changed & (STATE_CHANGED | STATE_CRASHED_FLAGS |
STATE_IN_REPAIR)) &&
share->state.open_count == 0) ||
((param.testflag & T_FAST) && (share->state.open_count ==
((param->testflag & T_FAST) && (share->state.open_count ==
(uint) (share->global_changed ? 1 :
0)))))
return HA_ADMIN_ALREADY_DONE;
maria_chk_init_for_check(&param, file);
maria_chk_init_for_check(param, file);
if ((file->s->state.changed & (STATE_CRASHED_FLAGS | STATE_MOVED)) ==
STATE_MOVED)
{
_ma_check_print_error(&param, "%s", zerofill_error_msg);
_ma_check_print_error(param, "%s", zerofill_error_msg);
return HA_ADMIN_CORRUPT;
}
old_proc_info= thd_proc_info(thd, "Checking status");
thd_progress_init(thd, 3);
error= maria_chk_status(&param, file); // Not fatal
if (maria_chk_size(&param, file))
error= maria_chk_status(param, file); // Not fatal
if (maria_chk_size(param, file))
error= 1;
if (!error)
error|= maria_chk_del(&param, file, param.testflag);
error|= maria_chk_del(param, file, param->testflag);
thd_proc_info(thd, "Checking keys");
thd_progress_next_stage(thd);
if (!error)
error= maria_chk_key(&param, file);
error= maria_chk_key(param, file);
thd_proc_info(thd, "Checking data");
thd_progress_next_stage(thd);
if (!error)
{
if ((!(param.testflag & T_QUICK) &&
if ((!(param->testflag & T_QUICK) &&
((share->options &
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ||
(param.testflag & (T_EXTEND | T_MEDIUM)))) || maria_is_crashed(file))
(param->testflag & (T_EXTEND | T_MEDIUM)))) || maria_is_crashed(file))
{
ulonglong old_testflag= param.testflag;
param.testflag |= T_MEDIUM;
if (!(error= init_io_cache(&param.read_cache, file->dfile.file,
ulonglong old_testflag= param->testflag;
param->testflag |= T_MEDIUM;
if (!(error= init_io_cache(&param->read_cache, file->dfile.file,
my_default_record_cache_size, READ_CACHE,
share->pack.header_length, 1, MYF(MY_WME))))
{
error= maria_chk_data_link(&param, file,
test(param.testflag & T_EXTEND));
end_io_cache(&(param.read_cache));
error= maria_chk_data_link(param, file,
test(param->testflag & T_EXTEND));
end_io_cache(&param->read_cache);
}
param.testflag= old_testflag;
param->testflag= old_testflag;
}
}
if (!error)
......@@ -1347,7 +1347,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
if ((share->state.changed & (STATE_CHANGED |
STATE_CRASHED_FLAGS |
STATE_IN_REPAIR | STATE_NOT_ANALYZED)) ||
(param.testflag & T_STATISTICS) || maria_is_crashed(file))
(param->testflag & T_STATISTICS) || maria_is_crashed(file))
{
file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
mysql_mutex_lock(&share->intern_lock);
......@@ -1355,7 +1355,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED_FLAGS |
STATE_IN_REPAIR);
if (!(table->db_stat & HA_READ_ONLY))
error= maria_update_state_info(&param, file,
error= maria_update_state_info(param, file,
UPDATE_TIME | UPDATE_OPEN_COUNT |
UPDATE_STAT);
mysql_mutex_unlock(&share->intern_lock);
......@@ -1386,33 +1386,33 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt)
{
int error= 0;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
MARIA_SHARE *share= file->s;
const char *old_proc_info;
if (!&param)
if (!param)
return HA_ADMIN_INTERNAL_ERROR;
maria_chk_init(&param);
param.thd= thd;
param.op_name= "analyze";
param.db_name= table->s->db.str;
param.table_name= table->alias.c_ptr();
param.testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
maria_chk_init(param);
param->thd= thd;
param->op_name= "analyze";
param->db_name= table->s->db.str;
param->table_name= table->alias.c_ptr();
param->testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
T_DONT_CHECK_CHECKSUM);
param.using_global_keycache= 1;
param.stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
param->using_global_keycache= 1;
param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
if (!(share->state.changed & STATE_NOT_ANALYZED))
return HA_ADMIN_ALREADY_DONE;
old_proc_info= thd_proc_info(thd, "Scanning");
thd_progress_init(thd, 1);
error= maria_chk_key(&param, file);
error= maria_chk_key(param, file);
if (!error)
{
mysql_mutex_lock(&share->intern_lock);
error= maria_update_state_info(&param, file, UPDATE_STAT);
error= maria_update_state_info(param, file, UPDATE_STAT);
mysql_mutex_unlock(&share->intern_lock);
}
else if (!maria_is_crashed(file) && !thd->killed)
......@@ -1425,44 +1425,44 @@ int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt)
int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
ha_rows start_records;
const char *old_proc_info;
if (!file || !&param)
if (!file || !param)
return HA_ADMIN_INTERNAL_ERROR;
maria_chk_init(&param);
param.thd= thd;
param.op_name= "repair";
param.testflag= ((check_opt->flags & ~(T_EXTEND)) |
maria_chk_init(param);
param->thd= thd;
param->op_name= "repair";
param->testflag= ((check_opt->flags & ~(T_EXTEND)) |
T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM |
(check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT));
param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
param.backup_time= check_opt->start_time;
param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
param->backup_time= check_opt->start_time;
start_records= file->state->records;
old_proc_info= thd_proc_info(thd, "Checking table");
thd_progress_init(thd, 1);
while ((error= repair(thd, &param, 0)) && param.retry_repair)
while ((error= repair(thd, param, 0)) && param->retry_repair)
{
param.retry_repair= 0;
if (test_all_bits(param.testflag,
param->retry_repair= 0;
if (test_all_bits(param->testflag,
(uint) (T_RETRY_WITHOUT_QUICK | T_QUICK)))
{
param.testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
param->testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
/* Ensure we don't loose any rows when retrying without quick */
param.testflag|= T_SAFE_REPAIR;
param->testflag|= T_SAFE_REPAIR;
if (thd->vio_ok())
_ma_check_print_info(&param, "Retrying repair without quick");
_ma_check_print_info(param, "Retrying repair without quick");
else
sql_print_information("Retrying repair of: '%s' without quick",
table->s->path.str);
continue;
}
param.testflag &= ~T_QUICK;
if ((param.testflag & T_REP_BY_SORT))
param->testflag &= ~T_QUICK;
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_information("Retrying repair of: '%s' with keycache",
table->s->path.str);
continue;
......@@ -1486,20 +1486,20 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt)
int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
TRN *old_trn;
MARIA_SHARE *share= file->s;
if (!file || !&param)
if (!file || !param)
return HA_ADMIN_INTERNAL_ERROR;
old_trn= file->trn;
maria_chk_init(&param);
param.thd= thd;
param.op_name= "zerofill";
param.testflag= check_opt->flags | T_SILENT | T_ZEROFILL;
param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
error=maria_zerofill(&param, file, share->open_file_name.str);
maria_chk_init(param);
param->thd= thd;
param->op_name= "zerofill";
param->testflag= check_opt->flags | T_SILENT | T_ZEROFILL;
param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
error=maria_zerofill(param, file, share->open_file_name.str);
/* Reset trn, that may have been set by repair */
_ma_set_trn_for_table(file, old_trn);
......@@ -1509,7 +1509,7 @@ int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
TrID create_trid= trnman_get_min_safe_trid();
mysql_mutex_lock(&share->intern_lock);
share->state.changed|= STATE_NOT_MOVABLE;
maria_update_state_info(&param, file, UPDATE_TIME | UPDATE_OPEN_COUNT);
maria_update_state_info(param, file, UPDATE_TIME | UPDATE_OPEN_COUNT);
_ma_update_state_lsns_sub(share, LSN_IMPOSSIBLE, create_trid,
TRUE, TRUE);
mysql_mutex_unlock(&share->intern_lock);
......@@ -1520,24 +1520,24 @@ int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
if (!file || !&param)
if (!file || !param)
return HA_ADMIN_INTERNAL_ERROR;
maria_chk_init(&param);
param.thd= thd;
param.op_name= "optimize";
param.testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
maria_chk_init(param);
param->thd= thd;
param->op_name= "optimize";
param->testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX);
param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
thd_progress_init(thd, 1);
if ((error= repair(thd, &param, 1)) && param.retry_repair)
if ((error= repair(thd, param, 1)) && param->retry_repair)
{
sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying",
my_errno, param.db_name, param.table_name);
param.testflag &= ~T_REP_BY_SORT;
error= repair(thd, &param, 0);
my_errno, param->db_name, param->table_name);
param->testflag &= ~T_REP_BY_SORT;
error= repair(thd, param, 0);
}
thd_progress_end(thd);
return error;
......@@ -1782,17 +1782,17 @@ int ha_maria::assign_to_keycache(THD * thd, HA_CHECK_OPT *check_opt)
if (error != HA_ADMIN_OK)
{
/* Send error to user */
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
if (!&param)
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
if (!param)
return HA_ADMIN_INTERNAL_ERROR;
maria_chk_init(&param);
param.thd= thd;
param.op_name= "assign_to_keycache";
param.db_name= table->s->db.str;
param.table_name= table->s->table_name.str;
param.testflag= 0;
_ma_check_print_error(&param, errmsg);
maria_chk_init(param);
param->thd= thd;
param->op_name= "assign_to_keycache";
param->db_name= table->s->db.str;
param->table_name= table->s->table_name.str;
param->testflag= 0;
_ma_check_print_error(param, errmsg);
}
DBUG_RETURN(error);
#else
......@@ -1846,17 +1846,17 @@ int ha_maria::preload_keys(THD * thd, HA_CHECK_OPT *check_opt)
errmsg= buf;
}
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
if (!&param)
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
if (!param)
return HA_ADMIN_INTERNAL_ERROR;
maria_chk_init(&param);
param.thd= thd;
param.op_name= "preload_keys";
param.db_name= table->s->db.str;
param.table_name= table->s->table_name.str;
param.testflag= 0;
_ma_check_print_error(&param, "%s", errmsg);
maria_chk_init(param);
param->thd= thd;
param->op_name= "preload_keys";
param->db_name= table->s->db.str;
param->table_name= table->s->table_name.str;
param->testflag= 0;
_ma_check_print_error(param, "%s", errmsg);
DBUG_RETURN(HA_ADMIN_FAILED);
}
DBUG_RETURN(HA_ADMIN_OK);
......@@ -1957,22 +1957,22 @@ int ha_maria::enable_indexes(uint mode)
else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE)
{
THD *thd= table->in_use;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
if (!&param)
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
if (!param)
return HA_ADMIN_INTERNAL_ERROR;
const char *save_proc_info= thd_proc_info(thd, "Creating index");
maria_chk_init(&param);
param.op_name= "recreating_index";
param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
maria_chk_init(param);
param->op_name= "recreating_index";
param->testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
T_CREATE_MISSING_KEYS | T_SAFE_REPAIR);
/*
Don't lock and unlock table if it's locked.
Normally table should be locked. This test is mostly for safety.
*/
if (likely(file->lock_type != F_UNLCK))
param.testflag|= T_NO_LOCKS;
param->testflag|= T_NO_LOCKS;
if (bulk_insert_single_undo == BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR)
{
......@@ -1981,23 +1981,23 @@ int ha_maria::enable_indexes(uint mode)
Don't bump create_rename_lsn, because UNDO_BULK_INSERT
should not be skipped in case of crash during repair.
*/
param.testflag|= T_NO_CREATE_RENAME_LSN;
param->testflag|= T_NO_CREATE_RENAME_LSN;
}
param.myf_rw &= ~MY_WAIT_IF_FULL;
param.sort_buffer_length= THDVAR(thd,sort_buffer_size);
param.stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
param.tmpdir= &mysql_tmpdir_list;
if ((error= (repair(thd, &param, 0) != HA_ADMIN_OK)) && param.retry_repair)
param->myf_rw &= ~MY_WAIT_IF_FULL;
param->sort_buffer_length= THDVAR(thd,sort_buffer_size);
param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
param->tmpdir= &mysql_tmpdir_list;
if ((error= (repair(thd, param, 0) != HA_ADMIN_OK)) && param->retry_repair)
{
sql_print_warning("Warning: Enabling keys got errno %d on %s.%s, "
"retrying",
my_errno, param.db_name, param.table_name);
my_errno, param->db_name, param->table_name);
/* This should never fail normally */
DBUG_ASSERT(thd->killed != 0);
/* Repairing by sort failed. Now try standard repair method. */
param.testflag &= ~T_REP_BY_SORT;
error= (repair(thd, &param, 0) != HA_ADMIN_OK);
param->testflag &= ~T_REP_BY_SORT;
error= (repair(thd, param, 0) != HA_ADMIN_OK);
/*
If the standard repair succeeded, clear all error messages which
might have been set by the first repair. They can still be seen
......
/*
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
Copyright (c) 2009, 2014, SkySQL Ab.
Copyright (c) 2009, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -856,59 +856,59 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
{
if (!file) return HA_ADMIN_INTERNAL_ERROR;
int error;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
MYISAM_SHARE* share = file->s;
const char *old_proc_info=thd->proc_info;
if (!&param)
if (!param)
return HA_ADMIN_INTERNAL_ERROR;
thd_proc_info(thd, "Checking table");
myisamchk_init(&param);
param.thd = thd;
param.op_name = "check";
param.db_name= table->s->db.str;
param.table_name= table->alias.c_ptr();
param.testflag = check_opt->flags | T_CHECK | T_SILENT;
param.stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
myisamchk_init(param);
param->thd = thd;
param->op_name = "check";
param->db_name= table->s->db.str;
param->table_name= table->alias.c_ptr();
param->testflag = check_opt->flags | T_CHECK | T_SILENT;
param->stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
if (!(table->db_stat & HA_READ_ONLY))
param.testflag|= T_STATISTICS;
param.using_global_keycache = 1;
param->testflag|= T_STATISTICS;
param->using_global_keycache = 1;
if (!mi_is_crashed(file) &&
(((param.testflag & T_CHECK_ONLY_CHANGED) &&
(((param->testflag & T_CHECK_ONLY_CHANGED) &&
!(share->state.changed & (STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR)) &&
share->state.open_count == 0) ||
((param.testflag & T_FAST) && (share->state.open_count ==
((param->testflag & T_FAST) && (share->state.open_count ==
(uint) (share->global_changed ? 1 : 0)))))
return HA_ADMIN_ALREADY_DONE;
error = chk_status(&param, file); // Not fatal
error = chk_size(&param, file);
error = chk_status(param, file); // Not fatal
error = chk_size(param, file);
if (!error)
error |= chk_del(&param, file, param.testflag);
error |= chk_del(param, file, param->testflag);
if (!error)
error = chk_key(&param, file);
error = chk_key(param, file);
if (!error)
{
if ((!(param.testflag & T_QUICK) &&
if ((!(param->testflag & T_QUICK) &&
((share->options &
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ||
(param.testflag & (T_EXTEND | T_MEDIUM)))) ||
(param->testflag & (T_EXTEND | T_MEDIUM)))) ||
mi_is_crashed(file))
{
ulonglong old_testflag= param.testflag;
param.testflag|=T_MEDIUM;
if (!(error= init_io_cache(&param.read_cache, file->dfile,
ulonglong old_testflag= param->testflag;
param->testflag|=T_MEDIUM;
if (!(error= init_io_cache(&param->read_cache, file->dfile,
my_default_record_cache_size, READ_CACHE,
share->pack.header_length, 1, MYF(MY_WME))))
{
error= chk_data_link(&param, file, test(param.testflag & T_EXTEND));
end_io_cache(&(param.read_cache));
error= chk_data_link(param, file, test(param->testflag & T_EXTEND));
end_io_cache(&(param->read_cache));
}
param.testflag= old_testflag;
param->testflag= old_testflag;
}
}
if (!error)
......@@ -916,7 +916,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
if ((share->state.changed & (STATE_CHANGED |
STATE_CRASHED_ON_REPAIR |
STATE_CRASHED | STATE_NOT_ANALYZED)) ||
(param.testflag & T_STATISTICS) ||
(param->testflag & T_STATISTICS) ||
mi_is_crashed(file))
{
file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
......@@ -924,7 +924,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR);
if (!(table->db_stat & HA_READ_ONLY))
error=update_state_info(&param,file,UPDATE_TIME | UPDATE_OPEN_COUNT |
error=update_state_info(param,file,UPDATE_TIME | UPDATE_OPEN_COUNT |
UPDATE_STAT);
mysql_mutex_unlock(&share->intern_lock);
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
......@@ -951,30 +951,30 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
{
int error=0;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
MYISAM_SHARE* share = file->s;
if (!&param)
if (!param)
return HA_ADMIN_INTERNAL_ERROR;
myisamchk_init(&param);
param.thd = thd;
param.op_name= "analyze";
param.db_name= table->s->db.str;
param.table_name= table->alias.c_ptr();
param.testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
myisamchk_init(param);
param->thd = thd;
param->op_name= "analyze";
param->db_name= table->s->db.str;
param->table_name= table->alias.c_ptr();
param->testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
T_DONT_CHECK_CHECKSUM);
param.using_global_keycache = 1;
param.stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
param->using_global_keycache = 1;
param->stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
if (!(share->state.changed & STATE_NOT_ANALYZED))
return HA_ADMIN_ALREADY_DONE;
error = chk_key(&param, file);
error = chk_key(param, file);
if (!error)
{
mysql_mutex_lock(&share->intern_lock);
error=update_state_info(&param,file,UPDATE_STAT);
error=update_state_info(param,file,UPDATE_STAT);
mysql_mutex_unlock(&share->intern_lock);
}
else if (!mi_is_crashed(file) && !thd->killed)
......@@ -986,37 +986,37 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
{
int error;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
ha_rows start_records;
if (!file || !&param) return HA_ADMIN_INTERNAL_ERROR;
if (!file || !param) return HA_ADMIN_INTERNAL_ERROR;
myisamchk_init(&param);
param.thd = thd;
param.op_name= "repair";
param.testflag= ((check_opt->flags & ~(T_EXTEND)) |
myisamchk_init(param);
param->thd = thd;
param->op_name= "repair";
param->testflag= ((check_opt->flags & ~(T_EXTEND)) |
T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM |
(check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT));
param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
param.backup_time= check_opt->start_time;
param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
param->backup_time= check_opt->start_time;
start_records=file->state->records;
while ((error=repair(thd,param,0)) && param.retry_repair)
while ((error=repair(thd,*param,0)) && param->retry_repair)
{
param.retry_repair=0;
if (test_all_bits(param.testflag,
param->retry_repair=0;
if (test_all_bits(param->testflag,
(uint) (T_RETRY_WITHOUT_QUICK | T_QUICK)))
{
param.testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
param->testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
/* Ensure we don't loose any rows when retrying without quick */
param.testflag|= T_SAFE_REPAIR;
param->testflag|= T_SAFE_REPAIR;
sql_print_information("Retrying repair of: '%s' including modifying data file",
table->s->path.str);
continue;
}
param.testflag&= ~T_QUICK;
if ((param.testflag & T_REP_BY_SORT))
param->testflag&= ~T_QUICK;
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_information("Retrying repair of: '%s' with keycache",
table->s->path.str);
continue;
......@@ -1038,22 +1038,22 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt)
{
int error;
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
if (!file || !&param) return HA_ADMIN_INTERNAL_ERROR;
if (!file || !param) return HA_ADMIN_INTERNAL_ERROR;
myisamchk_init(&param);
param.thd = thd;
param.op_name= "optimize";
param.testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
myisamchk_init(param);
param->thd = thd;
param->op_name= "optimize";
param->testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX);
param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
if ((error= repair(thd,param,1)) && param.retry_repair)
param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
if ((error= repair(thd,*param,1)) && param->retry_repair)
{
sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying",
my_errno, param.db_name, param.table_name);
param.testflag&= ~T_REP_BY_SORT;
error= repair(thd,param,1);
my_errno, param->db_name, param->table_name);
param->testflag&= ~T_REP_BY_SORT;
error= repair(thd,*param,1);
}
return error;
}
......@@ -1253,17 +1253,17 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
if (error != HA_ADMIN_OK)
{
/* Send error to user */
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
if (!&param)
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
if (!param)
return HA_ADMIN_INTERNAL_ERROR;
myisamchk_init(&param);
param.thd= thd;
param.op_name= "assign_to_keycache";
param.db_name= table->s->db.str;
param.table_name= table->s->table_name.str;
param.testflag= 0;
mi_check_print_error(&param, errmsg);
myisamchk_init(param);
param->thd= thd;
param->op_name= "assign_to_keycache";
param->db_name= table->s->db.str;
param->table_name= table->s->table_name.str;
param->testflag= 0;
mi_check_print_error(param, errmsg);
}
DBUG_RETURN(error);
}
......@@ -1320,16 +1320,16 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
err:
{
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
if (!&param)
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
if (!param)
return HA_ADMIN_INTERNAL_ERROR;
myisamchk_init(&param);
param.thd= thd;
param.op_name= "preload_keys";
param.db_name= table->s->db.str;
param.table_name= table->s->table_name.str;
param.testflag= 0;
mi_check_print_error(&param, errmsg);
myisamchk_init(param);
param->thd= thd;
param->op_name= "preload_keys";
param->db_name= table->s->db.str;
param->table_name= table->s->table_name.str;
param->testflag= 0;
mi_check_print_error(param, errmsg);
DBUG_RETURN(error);
}
}
......@@ -1434,42 +1434,42 @@ int ha_myisam::enable_indexes(uint mode)
{
THD *thd= table->in_use;
int was_error= thd->is_error();
HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
const char *save_proc_info=thd->proc_info;
if (!&param)
if (!param)
DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
thd_proc_info(thd, "Creating index");
myisamchk_init(&param);
param.op_name= "recreating_index";
param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
myisamchk_init(param);
param->op_name= "recreating_index";
param->testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
T_CREATE_MISSING_KEYS);
/*
Don't lock and unlock table if it's locked.
Normally table should be locked. This test is mostly for safety.
*/
if (likely(file->lock_type != F_UNLCK))
param.testflag|= T_NO_LOCKS;
param->testflag|= T_NO_LOCKS;
param.myf_rw&= ~MY_WAIT_IF_FULL;
param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
param.stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
param.tmpdir=&mysql_tmpdir_list;
if ((error= (repair(thd,param,0) != HA_ADMIN_OK)) && param.retry_repair)
param->myf_rw&= ~MY_WAIT_IF_FULL;
param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
param->stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
param->tmpdir=&mysql_tmpdir_list;
if ((error= (repair(thd,*param,0) != HA_ADMIN_OK)) && param->retry_repair)
{
sql_print_warning("Warning: Enabling keys got errno %d on %s.%s, retrying",
my_errno, param.db_name, param.table_name);
my_errno, param->db_name, param->table_name);
/*
Repairing by sort failed. Now try standard repair method.
Still we want to fix only index file. If data file corruption
was detected (T_RETRY_WITHOUT_QUICK), we shouldn't do much here.
Let implicit repair do this job.
*/
if (!(param.testflag & T_RETRY_WITHOUT_QUICK))
if (!(param->testflag & T_RETRY_WITHOUT_QUICK))
{
param.testflag&= ~T_REP_BY_SORT;
error= (repair(thd,param,0) != HA_ADMIN_OK);
param->testflag&= ~T_REP_BY_SORT;
error= (repair(thd,*param,0) != HA_ADMIN_OK);
}
/*
If the standard repair succeeded, clear all error messages which
......
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