Skip to content

Commit

Permalink
Bug#11815557 60269: MYSQL SHOULD REJECT ATTEMPTS TO CREATE SYSTEM
Browse files Browse the repository at this point in the history
                    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.
--BZR--
revision-id: [email protected]
property-branch-nick: systemtables-5.5
testament3-sha1: deb681c59075b83266b2dc28cd3f3d15a39c87be
  • Loading branch information
gopshank committed Apr 11, 2012
1 parent 888d1ee commit d3d5394
Show file tree
Hide file tree
Showing 10 changed files with 628 additions and 134 deletions.
55 changes: 55 additions & 0 deletions mysql-test/r/alter_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -1433,3 +1433,58 @@ rename table t2 to t1;
execute stmt1;
deallocate prepare stmt1;
drop table t2;
#
# Bug#11815557 60269: MYSQL SHOULD REJECT ATTEMPTS TO CREATE SYSTEM
# TABLES IN INCORRECT ENGINE
#
# Note: This test assumes that only MyISAM supports system tables.
# If other engines are made to support system tables,
# then this test needs to be updated
#
use mysql;
ALTER TABLE db ENGINE=innodb;
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.db]
ALTER TABLE user ENGINE=memory;
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.user]
ALTER TABLE proc ENGINE=heap;
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.proc]
ALTER TABLE func ENGINE=csv;
ERROR HY000: Storage engine 'CSV' does not support system tables. [mysql.func]
ALTER TABLE event ENGINE=merge;
ERROR HY000: Storage engine 'MRG_MYISAM' does not support system tables. [mysql.event]
ALTER TABLE servers ENGINE=innodb;
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.servers]
ALTER TABLE procs_priv ENGINE=memory;
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.procs_priv]
ALTER TABLE tables_priv ENGINE=heap;
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.tables_priv]
ALTER TABLE columns_priv ENGINE=csv;
ERROR HY000: Storage engine 'CSV' does not support system tables. [mysql.columns_priv]
ALTER TABLE time_zone ENGINE=merge;
ERROR HY000: Storage engine 'MRG_MYISAM' does not support system tables. [mysql.time_zone]
ALTER TABLE help_topic ENGINE=innodb;
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.help_topic]
CREATE TABLE db (dummy int) ENGINE=innodb;
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.db]
CREATE TABLE user (dummy int) ENGINE=memory;
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.user]
CREATE TABLE proc (dummy int) ENGINE=heap;
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.proc]
CREATE TABLE func (dummy int) ENGINE=csv;
ERROR HY000: Storage engine 'CSV' does not support system tables. [mysql.func]
CREATE TABLE event (dummy int) ENGINE=merge;
ERROR HY000: Storage engine 'MRG_MYISAM' does not support system tables. [mysql.event]
CREATE TABLE servers (dummy int) ENGINE=innodb;
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.servers]
CREATE TABLE procs_priv (dummy int) ENGINE=memory;
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.procs_priv]
CREATE TABLE tables_priv (dummy int) ENGINE=heap;
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.tables_priv]
CREATE TABLE columns_priv (dummy int) ENGINE=csv;
ERROR HY000: Storage engine 'CSV' does not support system tables. [mysql.columns_priv]
CREATE TABLE time_zone (dummy int) ENGINE=merge;
ERROR HY000: Storage engine 'MRG_MYISAM' does not support system tables. [mysql.time_zone]
CREATE TABLE help_topic (dummy int) ENGINE=innodb;
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.help_topic]
use test;
# End of Bug#11815557
94 changes: 0 additions & 94 deletions mysql-test/r/help.result
Original file line number Diff line number Diff line change
Expand Up @@ -148,100 +148,6 @@ help 'impossible_category_1';
source_category_name name is_it_category
impossible_category_1 impossible_function_1 N
impossible_category_1 impossible_function_2 N
alter table mysql.help_relation engine=innodb;
alter table mysql.help_keyword engine=innodb;
alter table mysql.help_topic engine=innodb;
alter table mysql.help_category engine=innodb;
help 'function_of_my_dream';
name is_it_category
help '%possible_f%';
name is_it_category
impossible_function_1 N
impossible_function_2 N
impossible_function_3 N
impossible_function_4 N
impossible_function_7 N
help 'impossible_func%';
name is_it_category
impossible_function_1 N
impossible_function_2 N
impossible_function_3 N
impossible_function_4 N
impossible_function_7 N
help 'impossible_category%';
name is_it_category
impossible_category_1 Y
impossible_category_2 Y
impossible_category_3 Y
help 'impossible_%';
name is_it_category
impossible_function_1 N
impossible_function_2 N
impossible_function_3 N
impossible_function_4 N
impossible_function_7 N
impossible_category_1 Y
impossible_category_2 Y
impossible_category_3 Y
help '%function_1';
name description example
impossible_function_1 description of
impossible_function1
example of
impossible_function1
help '%function_2';
name description example
impossible_function_2 description of
impossible_function2
example of
impossible_function2
help '%function_3';
name description example
impossible_function_3 description of
impossible_function3
example of
impossible_function3
help '%function_4';
name description example
impossible_function_4 description of
impossible_function4
example of
impossible_function4
help '%function_5';
name description example
impossible_function_1 description of
impossible_function1
example of
impossible_function1
help '%function_6';
name is_it_category
impossible_function_3 N
impossible_function_4 N
help '%function_7';
name description example
impossible_function_7 description of
impossible_function5
example of
impossible_function7
help '%category_2';
source_category_name name is_it_category
impossible_category_2 impossible_function_3 N
impossible_category_2 impossible_function_4 N
impossible_category_2 impossible_category_3 Y
help 'impossible_function_1';
name description example
impossible_function_1 description of
impossible_function1
example of
impossible_function1
help 'impossible_category_1';
source_category_name name is_it_category
impossible_category_1 impossible_function_1 N
impossible_category_1 impossible_function_2 N
alter table mysql.help_relation engine=myisam;
alter table mysql.help_keyword engine=myisam;
alter table mysql.help_topic engine=myisam;
alter table mysql.help_category engine=myisam;
delete from mysql.help_topic where help_topic_id=@topic1_id;
delete from mysql.help_topic where help_topic_id=@topic2_id;
delete from mysql.help_topic where help_topic_id=@topic3_id;
Expand Down
58 changes: 58 additions & 0 deletions mysql-test/t/alter_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -1203,3 +1203,61 @@ rename table t2 to t1;
execute stmt1;
deallocate prepare stmt1;
drop table t2;

--echo #
--echo # Bug#11815557 60269: MYSQL SHOULD REJECT ATTEMPTS TO CREATE SYSTEM
--echo # TABLES IN INCORRECT ENGINE
--echo #
--echo # Note: This test assumes that only MyISAM supports system tables.
--echo # If other engines are made to support system tables,
--echo # then this test needs to be updated
--echo #

use mysql;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE db ENGINE=innodb;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE user ENGINE=memory;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE proc ENGINE=heap;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE func ENGINE=csv;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE event ENGINE=merge;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE servers ENGINE=innodb;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE procs_priv ENGINE=memory;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE tables_priv ENGINE=heap;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE columns_priv ENGINE=csv;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE time_zone ENGINE=merge;
--error ER_UNSUPPORTED_ENGINE
ALTER TABLE help_topic ENGINE=innodb;

--error ER_UNSUPPORTED_ENGINE
CREATE TABLE db (dummy int) ENGINE=innodb;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE user (dummy int) ENGINE=memory;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE proc (dummy int) ENGINE=heap;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE func (dummy int) ENGINE=csv;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE event (dummy int) ENGINE=merge;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE servers (dummy int) ENGINE=innodb;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE procs_priv (dummy int) ENGINE=memory;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE tables_priv (dummy int) ENGINE=heap;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE columns_priv (dummy int) ENGINE=csv;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE time_zone (dummy int) ENGINE=merge;
--error ER_UNSUPPORTED_ENGINE
CREATE TABLE help_topic (dummy int) ENGINE=innodb;
use test;
--echo # End of Bug#11815557
32 changes: 0 additions & 32 deletions mysql-test/t/help.test
Original file line number Diff line number Diff line change
Expand Up @@ -63,38 +63,6 @@ help 'impossible_function_1';
help 'impossible_category_1';
##############

--disable_warnings
alter table mysql.help_relation engine=innodb;
alter table mysql.help_keyword engine=innodb;
alter table mysql.help_topic engine=innodb;
alter table mysql.help_category engine=innodb;
--enable_warnings

##############
help 'function_of_my_dream';
help '%possible_f%';
help 'impossible_func%';
help 'impossible_category%';
help 'impossible_%';

help '%function_1';
help '%function_2';
help '%function_3';
help '%function_4';
help '%function_5';
help '%function_6';
help '%function_7';

help '%category_2';
help 'impossible_function_1';
help 'impossible_category_1';
##############

alter table mysql.help_relation engine=myisam;
alter table mysql.help_keyword engine=myisam;
alter table mysql.help_topic engine=myisam;
alter table mysql.help_category engine=myisam;

delete from mysql.help_topic where help_topic_id=@topic1_id;
delete from mysql.help_topic where help_topic_id=@topic2_id;
delete from mysql.help_topic where help_topic_id=@topic3_id;
Expand Down
Loading

0 comments on commit d3d5394

Please sign in to comment.