diff options
author | unknown <gopal.shankar@oracle.com> | 2012-04-11 15:53:17 +0530 |
---|---|---|
committer | unknown <gopal.shankar@oracle.com> | 2012-04-11 15:53:17 +0530 |
commit | 99b18a036cfb6d990e2f26bb43774735e2a9c7ab (patch) | |
tree | 5351d27e52955b31c1d107afd9480b37224c2b8d /storage/example | |
parent | 26713f5a154e1f43ac4154b643ce5090a29b35b1 (diff) | |
download | mariadb-git-99b18a036cfb6d990e2f26bb43774735e2a9c7ab.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/example')
-rw-r--r-- | storage/example/ha_example.cc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 3b0100510b8..c4ed4d5d2c2 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -103,6 +103,12 @@ static handler *example_create_handler(handlerton *hton, handlerton *example_hton; +/* Interface to mysqld, to check system tables supported by SE */ +static const char* example_system_database(); +static bool example_is_supported_system_table(const char *db, + const char *table_name, + bool is_sql_layer_system_table); + /* Variables for example share methods */ /* @@ -165,6 +171,8 @@ static int example_init_func(void *p) example_hton->state= SHOW_OPTION_YES; example_hton->create= example_create_handler; example_hton->flags= HTON_CAN_RECREATE; + example_hton->system_database= example_system_database; + example_hton->is_supported_system_table= example_is_supported_system_table; DBUG_RETURN(0); } @@ -298,6 +306,65 @@ const char **ha_example::bas_ext() const return ha_example_exts; } +/* + Following handler function provides access to + system database specific to SE. This interface + is optional, so every SE need not implement it. +*/ +const char* ha_example_system_database= NULL; +const char* example_system_database() +{ + return ha_example_system_database; +} + +/* + List of all system tables specific to the SE. + Array element would look like below, + { "<database_name>", "<system table name>" }, + The last element MUST be, + { (const char*)NULL, (const char*)NULL } + + This array is optional, so every SE need not implement it. +*/ +static st_system_tablename ha_example_system_tables[]= { + {(const char*)NULL, (const char*)NULL} +}; + +/** + @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. + + @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 example_is_supported_system_table(const char *db, + const char *table_name, + bool is_sql_layer_system_table) +{ + st_system_tablename *systab; + + // Does this SE support "ALL" SQL layer system tables ? + if (is_sql_layer_system_table) + return false; + + // Check if this is SE layer system tables + systab= ha_example_system_tables; + while (systab && systab->db) + { + if (systab->db == db && + strcmp(systab->tablename, table_name) == 0) + return true; + systab++; + } + + return false; +} + /** @brief |