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 /sql/handler.h | |
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 'sql/handler.h')
-rw-r--r-- | sql/handler.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sql/handler.h b/sql/handler.h index cbdfc231ed5..0b970a1349d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -382,6 +382,25 @@ enum enum_binlog_command { /** Unused. Reserved for future versions. */ #define HA_CREATE_USED_PAGE_CHECKSUM (1L << 21) + +/* + This is master database for most of system tables. However there + can be other databases which can hold system tables. Respective + storage engines define their own system database names. +*/ +extern const char *mysqld_system_database; + +/* + Structure to hold list of system_database.system_table. + This is used at both mysqld and storage engine layer. +*/ +struct st_system_tablename +{ + const char *db; + const char *tablename; +}; + + typedef ulonglong my_xid; // this line is the same as in log_event.h #define MYSQL_XID_PREFIX "MySQLXid" #define MYSQL_XID_PREFIX_LEN 8 // must be a multiple of 8 @@ -800,6 +819,39 @@ struct handlerton const char *wild, bool dir, List<LEX_STRING> *files); int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db, const char *name); + + /** + 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 } + + @see ha_example_system_tables in ha_example.cc + + This interface is optional, so every SE need not implement it. + */ + const char* (*system_database)(); + + /** + 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. + + @see example_is_supported_system_table in ha_example.cc + + is_sql_layer_system_table is supplied to make more efficient + checks possible for SEs that support all SQL layer tables. + + This interface is optional, so every SE need not implement it. + */ + bool (*is_supported_system_table)(const char *db, + const char *table_name, + bool is_sql_layer_system_table); + uint32 license; /* Flag for Engine License */ void *data; /* Location for engines to keep personal structures */ }; @@ -2238,6 +2290,8 @@ int ha_discover(THD* thd, const char* dbname, const char* name, int ha_find_files(THD *thd,const char *db,const char *path, const char *wild, bool dir, List<LEX_STRING>* files); int ha_table_exists_in_engine(THD* thd, const char* db, const char* name); +bool ha_check_if_supported_system_table(handlerton *hton, const char* db, + const char* table_name); /* key cache */ extern "C" int ha_init_key_cache(const char *name, KEY_CACHE *key_cache); |