summaryrefslogtreecommitdiff
path: root/sql/sql_admin.cc
diff options
context:
space:
mode:
authorGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-10-04 15:42:16 +0300
committerGeorgi Kodinov <Georgi.Kodinov@Oracle.com>2010-10-04 15:42:16 +0300
commit8789c7972339340feb6a49903ff247de580bc5dd (patch)
tree0b41fbab5c8e486500b5c53bbe818e62f6f583f2 /sql/sql_admin.cc
parent5f9c629da0c08cd742a16419f4f66cdb18505302 (diff)
parent40ee088f68a452ac2ed19622481c73d6d38c7ec3 (diff)
downloadmariadb-git-8789c7972339340feb6a49903ff247de580bc5dd.tar.gz
merge
Diffstat (limited to 'sql/sql_admin.cc')
-rw-r--r--sql/sql_admin.cc46
1 files changed, 39 insertions, 7 deletions
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 1f96f1cf0e4..21a05a5baca 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -111,9 +111,6 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
table= &tmp_table;
}
- /* A MERGE table must not come here. */
- DBUG_ASSERT(table->file->ht->db_type != DB_TYPE_MRG_MYISAM);
-
/*
REPAIR TABLE ... USE_FRM for temporary tables makes little sense.
*/
@@ -151,6 +148,9 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
if (!ext[0] || !ext[1])
goto end; // No data file
+ /* A MERGE table must not come here. */
+ DBUG_ASSERT(table->file->ht->db_type != DB_TYPE_MRG_MYISAM);
+
// Name of data file
strxmov(from, table->s->normalized_path.str, ext[1], NullS);
if (!mysql_file_stat(key_file_misc, from, &stat_info, MYF(0)))
@@ -231,6 +231,26 @@ end:
}
+/**
+ Check if a given error is something that could occur during
+ open_and_lock_tables() that does not indicate table corruption.
+
+ @param sql_errno Error number to check.
+
+ @retval TRUE Error does not indicate table corruption.
+ @retval FALSE Error could indicate table corruption.
+*/
+
+static inline bool table_not_corrupt_error(uint sql_errno)
+{
+ return (sql_errno == ER_NO_SUCH_TABLE ||
+ sql_errno == ER_FILE_NOT_FOUND ||
+ sql_errno == ER_LOCK_WAIT_TIMEOUT ||
+ sql_errno == ER_LOCK_DEADLOCK ||
+ sql_errno == ER_CANT_LOCK_LOG_TABLE ||
+ sql_errno == ER_OPEN_AS_READONLY);
+}
+
/*
RETURN VALUES
@@ -311,7 +331,13 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
lex->query_tables= table;
lex->query_tables_last= &table->next_global;
lex->query_tables_own_last= 0;
- thd->no_warnings_for_error= no_warnings_for_error;
+ /*
+ Under locked tables, we know that the table can be opened,
+ so any errors opening the table are logical errors.
+ In these cases it makes sense to report them.
+ */
+ if (!thd->locked_tables_mode)
+ thd->no_warnings_for_error= no_warnings_for_error;
if (view_operator_func == NULL)
table->required_type=FRMTYPE_TABLE;
@@ -320,6 +346,14 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
table->next_global= save_next_global;
table->next_local= save_next_local;
thd->open_options&= ~extra_open_options;
+
+ /*
+ If open_and_lock_tables() failed, close_thread_tables() will close
+ the table and table->table can therefore be invalid.
+ */
+ if (open_error)
+ table->table= NULL;
+
/*
Under locked tables, we know that the table can be opened,
so any errors opening the table are logical errors.
@@ -418,9 +452,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM));
if (thd->stmt_da->is_error() &&
- (thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE ||
- thd->stmt_da->sql_errno() == ER_FILE_NOT_FOUND))
- /* A missing table is just issued as a failed command */
+ table_not_corrupt_error(thd->stmt_da->sql_errno()))
result_code= HA_ADMIN_FAILED;
else
/* Default failure code is corrupt table */