summaryrefslogtreecommitdiff
path: root/storage/myisam
diff options
context:
space:
mode:
authorgopal.shankar@oracle.com <>2012-04-11 15:53:17 +0530
committergopal.shankar@oracle.com <>2012-04-11 15:53:17 +0530
commit796fad1424dabed0d60cdbf353c8ce88c4066bb8 (patch)
tree5351d27e52955b31c1d107afd9480b37224c2b8d /storage/myisam
parentd3782bffbdd2c5cdda3d6760acfaebfe9549aeef (diff)
downloadmariadb-git-796fad1424dabed0d60cdbf353c8ce88c4066bb8.tar.gz
Bug#11815557 60269: MYSQL SHOULD REJECT ATTEMPTS TO CREATE SYSTEM
TABLES IN INCORRECT ENGINE PROBLEM: CREATE/ALTER TABLE currently can move system tables like mysql.db, user, host etc, to engines other than MyISAM. This is not completely supported as of now, by mysqld. When some of system tables like plugin, servers, event, func, *_priv, time_zone* are moved to innodb, mysqld restart crashes. Currently system tables can be moved to BLACKHOLE also!!!. ANALYSIS: The problem is that there is no check before creating or moving a system table to some particular engine. System tables are suppose to be residing in MyISAM. We can think of restricting system tables to exist only in MyISAM. But, there could be future needs of these system tables to be part of other engines by design. For eg, NDB cluster expects some tables to be on innodb or ndb engine. This calls for a solution, by which system tables can be supported by any desired engine, with minimal effort. FIX: The solution provides a handlerton interface using which, mysqld server can query particular storage engine handlerton for system tables that it supports. This way each storage engine layer can define their own system database and system tables. The check_engine() function uses the new handlerton function ha_check_if_supported_system_table() to check if db.tablename provided in the DDL is supported by the SE. Note: This fix has modified a test in help.test, which was moving mysql.help_* to innodb. The primary intention of the test was not to move them between engines.
Diffstat (limited to 'storage/myisam')
-rw-r--r--storage/myisam/ha_myisam.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 4d8f613b454..34532d39443 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -37,6 +37,11 @@
ulonglong myisam_recover_options;
static ulong opt_myisam_block_size;
+/* Interface to mysqld, to check system tables supported by SE */
+static bool myisam_is_supported_system_table(const char *db,
+ const char *table_name,
+ bool is_sql_layer_system_table);
+
/* bits in myisam_recover_options */
const char *myisam_recover_names[] =
{ "DEFAULT", "BACKUP", "FORCE", "QUICK", "OFF", NullS};
@@ -665,6 +670,42 @@ const char **ha_myisam::bas_ext() const
return ha_myisam_exts;
}
+/**
+ @brief Check if the given db.tablename is a system table for this SE.
+
+ @param db Database name to check.
+ @param table_name table name to check.
+ @param is_sql_layer_system_table if the supplied db.table_name is a SQL
+ layer system table.
+
+ @note Currently, only MYISAM engine supports all the SQL layer
+ system tables, and hence it returns true, when
+ is_sql_layer_system_table is set.
+
+ @note In case there is a need to define MYISAM specific system
+ database, then please see reference implementation in
+ ha_example.cc.
+
+ @return
+ @retval TRUE Given db.table_name is supported system table.
+ @retval FALSE Given db.table_name is not a supported system table.
+*/
+static bool myisam_is_supported_system_table(const char *db,
+ const char *table_name,
+ bool is_sql_layer_system_table)
+{
+ // Does MYISAM support "ALL" SQL layer system tables ?
+ if (is_sql_layer_system_table)
+ return true;
+
+ /*
+ Currently MYISAM does not support any other SE specific
+ system tables. If in future it does, please see ha_example.cc
+ for reference implementation.
+ */
+
+ return false;
+}
const char *ha_myisam::index_type(uint key_number)
{
@@ -2070,6 +2111,8 @@ static int myisam_init(void *p)
myisam_hton->create= myisam_create_handler;
myisam_hton->panic= myisam_panic;
myisam_hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES;
+ myisam_hton->is_supported_system_table= myisam_is_supported_system_table;
+
return 0;
}