summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_myisam.cc21
-rw-r--r--sql/ha_myisammrg.cc26
-rw-r--r--sql/ha_myisammrg.h1
-rw-r--r--sql/share/errmsg.txt3
-rw-r--r--sql/sql_error.cc4
-rw-r--r--sql/sql_error.h2
-rw-r--r--sql/sql_table.cc49
7 files changed, 65 insertions, 41 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 9a397ffbbac..5e953092436 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -109,6 +109,14 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
}
length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) -
name);
+ /*
+ TODO: switch from protocol to push_warning here. The main reason we didn't
+ it yet is parallel repair. Due to following trace:
+ mi_check_print_msg/push_warning/sql_alloc/my_pthread_getspecific_ptr.
+
+ Also we likely need to lock mutex here (in both cases with protocol and
+ push_warning).
+ */
protocol->prepare_for_resend();
protocol->store(name, length, system_charset_info);
protocol->store(param->op_name, system_charset_info);
@@ -1138,11 +1146,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
/* We only come here when the user did specify an index map */
key_map kmap;
if (get_key_map_from_key_list(&kmap, table, table_list->use_index))
- {
- errmsg= thd->net.last_error;
- error= HA_ADMIN_FAILED;
- goto err;
- }
+ DBUG_RETURN(HA_ADMIN_FAILED);
map= kmap.to_ulonglong();
}
@@ -1155,7 +1159,6 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
error= HA_ADMIN_CORRUPT;
}
- err:
if (error != HA_ADMIN_OK)
{
/* Send error to user */
@@ -1192,11 +1195,7 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
key_map kmap;
get_key_map_from_key_list(&kmap, table, table_list->use_index);
if (kmap.is_set_all())
- {
- errmsg= thd->net.last_error;
- error= HA_ADMIN_FAILED;
- goto err;
- }
+ DBUG_RETURN(HA_ADMIN_FAILED);
if (!kmap.is_clear_all())
map= kmap.to_ulonglong();
}
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index 1202a733a16..e7baa6705ee 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -72,6 +72,13 @@ extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
uint t1_keys, uint t1_recs,
MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo,
uint t2_keys, uint t2_recs, bool strict);
+extern "C" void myrg_print_wrong_table(const char *table_name)
+{
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE),
+ table_name);
+}
+
const char **ha_myisammrg::bas_ext() const
{
@@ -121,6 +128,8 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
{
DBUG_PRINT("error",("reclength: %lu mean_rec_length: %lu",
table->s->reclength, mean_rec_length));
+ if (test_if_locked & HA_OPEN_FOR_REPAIR)
+ myrg_print_wrong_table(file->open_tables->table->filename);
error= HA_ERR_WRONG_MRG_TABLE_DEF;
goto err;
}
@@ -139,12 +148,19 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
u_table->table->s->base.keys,
u_table->table->s->base.fields, false))
{
- my_free((gptr) recinfo, MYF(0));
error= HA_ERR_WRONG_MRG_TABLE_DEF;
- goto err;
+ if (test_if_locked & HA_OPEN_FOR_REPAIR)
+ myrg_print_wrong_table(u_table->table->filename);
+ else
+ {
+ my_free((gptr) recinfo, MYF(0));
+ goto err;
+ }
}
}
my_free((gptr) recinfo, MYF(0));
+ if (error == HA_ERR_WRONG_MRG_TABLE_DEF)
+ goto err;
#if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4
/* Merge table has more than 2G rows */
if (table->s->crashed)
@@ -597,3 +613,9 @@ void ha_myisammrg::append_create_info(String *packet)
}
packet->append(')');
}
+
+
+int ha_myisammrg::check(THD* thd, HA_CHECK_OPT* check_opt)
+{
+ return HA_ADMIN_OK;
+}
diff --git a/sql/ha_myisammrg.h b/sql/ha_myisammrg.h
index 16c734e2682..2ba5b6b551e 100644
--- a/sql/ha_myisammrg.h
+++ b/sql/ha_myisammrg.h
@@ -81,4 +81,5 @@ class ha_myisammrg: public handler
void update_create_info(HA_CREATE_INFO *create_info);
void append_create_info(String *packet);
MYRG_INFO *myrg_info() { return file; }
+ int check(THD* thd, HA_CHECK_OPT* check_opt);
};
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 1230287656e..a52ffa8216c 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5633,4 +5633,5 @@ ER_WRONG_STRING_LENGTH
eng "String '%-.70s' is too long for %s (should be no longer than %d)"
ER_NON_INSERTABLE_TABLE
eng "The target table %-.100s of the %s is not insertable-into"
-
+ER_ADMIN_WRONG_MRG_TABLE
+ eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist"
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 61a7581908c..a25c82c7721 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -205,8 +205,8 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
TRUE Error sending data to client
*/
-static const char *warning_level_names[]= {"Note", "Warning", "Error", "?"};
-static int warning_level_length[]= { 4, 7, 5, 1 };
+const char *warning_level_names[]= {"Note", "Warning", "Error", "?"};
+int warning_level_length[]= { 4, 7, 5, 1 };
bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
{
diff --git a/sql/sql_error.h b/sql/sql_error.h
index 28d946f14f8..4dbf3ada8f0 100644
--- a/sql/sql_error.h
+++ b/sql/sql_error.h
@@ -39,3 +39,5 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
uint code, const char *format, ...);
void mysql_reset_errors(THD *thd, bool force);
bool mysqld_show_warnings(THD *thd, ulong levels_to_show);
+extern const char *warning_level_names[];
+extern int warning_level_length[];
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 079cc0d6456..2456c3818a2 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2283,33 +2283,16 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
*/
if (!table->table)
{
- char buf[ERRMSGSIZE+ERRMSGSIZE+2];
- const char *err_msg;
- protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
- protocol->store(operator_name, system_charset_info);
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
- if (!(err_msg=thd->net.last_error))
- err_msg=ER(ER_CHECK_NO_SUCH_TABLE);
+ if (!thd->warn_list.elements)
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_CHECK_NO_SUCH_TABLE, ER(ER_CHECK_NO_SUCH_TABLE));
/* if it was a view will check md5 sum */
if (table->view &&
view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM)
- {
- strxmov(buf, err_msg, "; ", ER(ER_VIEW_CHECKSUM), NullS);
- err_msg= (const char *)buf;
- }
- protocol->store(err_msg, system_charset_info);
- lex->cleanup_after_one_table_open();
- thd->clear_error();
- /*
- View opening can be interrupted in the middle of process so some
- tables can be left opening
- */
- close_thread_tables(thd);
- lex->reset_query_tables_list(FALSE);
- if (protocol->write())
- goto err;
- continue;
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM));
+ result_code= HA_ADMIN_CORRUPT;
+ goto send_result;
}
if (table->view)
@@ -2391,6 +2374,22 @@ send_result:
lex->cleanup_after_one_table_open();
thd->clear_error(); // these errors shouldn't get client
+ {
+ List_iterator_fast<MYSQL_ERROR> it(thd->warn_list);
+ MYSQL_ERROR *err;
+ while ((err= it++))
+ {
+ protocol->prepare_for_resend();
+ protocol->store(table_name, system_charset_info);
+ protocol->store((char*) operator_name, system_charset_info);
+ protocol->store(warning_level_names[err->level],
+ warning_level_length[err->level], system_charset_info);
+ protocol->store(err->msg, system_charset_info);
+ if (protocol->write())
+ goto err;
+ }
+ mysql_reset_errors(thd, true);
+ }
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
@@ -2924,7 +2923,7 @@ bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
DBUG_ENTER("mysql_check_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
"check", lock_type,
- 0, HA_OPEN_FOR_REPAIR, 0, 0,
+ 0, 0, HA_OPEN_FOR_REPAIR, 0,
&handler::ha_check, &view_checksum));
}