summaryrefslogtreecommitdiff
path: root/sql/sql_base.h
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2013-03-01 18:01:44 +0200
committerMichael Widenius <monty@askmonty.org>2013-03-01 18:01:44 +0200
commit8ed283d882e7147b1caa3f90f708720c94446024 (patch)
tree6331e41475ba0f8408cde0700b86d44f04ff32fa /sql/sql_base.h
parentb917fdb9f1427786ec54adfeb963fabd6bf11f74 (diff)
downloadmariadb-git-8ed283d882e7147b1caa3f90f708720c94446024.tar.gz
Fixed bug MPDEV-628 / LP:989055 - Querying myisam table metadata may corrupt the table.
The issue was that there was that SHOW commands could open the table in the store engine, even in cases where it should not be allowed to do that (ie, the storage engines meta data for that table was under big changes). The cases where this should not be allowed are: - ALTER TABLE DISABLE KEYS - ALTER TABLE ENABLE KEYS - REPAIR TABLE - OPTIMIZE TABLE - DROP TABLE This patch adds a new mode, protected_against_usage(). If this is used then the SHOW command will wait until the table is accessable. This is implemented by re-using the already exising 'version' flag for TABLE_SHARE. It also added functions to be used to change TABLE_SHARE->version instead of changing it directly. mysql-test/r/myisam-metadata.result: Added test case mysql-test/t/myisam-metadata.test: Added test case sql/mysqld.cc: Start from refresh_version 2 as 0 and 1 are reserved. sql/sql_admin.cc: Added MYSQL_OPEN_FOR_REPAIR Updated call to wait_while_table_is_used() sql/sql_base.cc: Updated call to wait_while_table_is_used() - Allow one to specify how the table should be removed (for all commands except show or for all commands). - Don't allow one to reopen the table if one has called share->protect_against_usage() sql/sql_base.h: Added TDC_RT_REMOVE_NOT_OWN_AND_MARK_NOT_USABLE, which is used to mark that no one can reopen this table, except with MYSQL_OPEN_FOR_REPAIR . - Added MYSQL_OPEN_FOR_REPAIR - Updated prototype for wait_while_table_is_used() sql/sql_table.cc: Updated call to wait_while_table_is_used() Use MYSQL_OPEN_FOR_REPAIR for open tables that where repaired. sql/sql_truncate.cc: Updated call to wait_while_table_is_used() sql/table.cc: Use set_refresh_version() sql/table.h: Added functions to be used to change TABLE_SHARE->version instead of changing it directly
Diffstat (limited to 'sql/sql_base.h')
-rw-r--r--sql/sql_base.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/sql/sql_base.h b/sql/sql_base.h
index 45d41777fea..2a39c67b350 100644
--- a/sql/sql_base.h
+++ b/sql/sql_base.h
@@ -60,7 +60,8 @@ enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
IGNORE_EXCEPT_NON_UNIQUE};
enum enum_tdc_remove_table_type {TDC_RT_REMOVE_ALL, TDC_RT_REMOVE_NOT_OWN,
- TDC_RT_REMOVE_UNUSED};
+ TDC_RT_REMOVE_UNUSED,
+ TDC_RT_REMOVE_NOT_OWN_AND_MARK_NOT_USABLE};
/* bits for last argument to remove_table_from_cache() */
#define RTFC_NO_FLAG 0x0000
@@ -128,6 +129,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
*/
#define MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK 0x1000
#define MYSQL_LOCK_NOT_TEMPORARY 0x2000
+#define MYSQL_OPEN_FOR_REPAIR 0x4000
/** Please refer to the internals manual. */
#define MYSQL_OPEN_REOPEN (MYSQL_OPEN_IGNORE_FLUSH |\
@@ -229,7 +231,9 @@ bool setup_tables_and_check_access(THD *thd,
ulong want_access,
bool full_table_list);
bool wait_while_table_is_used(THD *thd, TABLE *table,
- enum ha_extra_function function);
+ enum ha_extra_function function,
+ enum_tdc_remove_table_type remove_type=
+ TDC_RT_REMOVE_NOT_OWN);
void drop_open_table(THD *thd, TABLE *table, const char *db_name,
const char *table_name);