# Test uses lower_case_table_names=2. So test needs case sensitive file system # # Bug#30248138 - adding a function once mysql.func is converted to myisam # leads to crash # #----------------------------------------------------------------------- # Test cases to verify system table's behavior with storage engines # InnoDB and MyISAM. # # Table name comparison is "case insensitive" with lower_case_table_name=2. # Run "system_tables_storage_engine_tests.inc" tests with upper case # system table names . #----------------------------------------------------------------------- CREATE TABLE system_tables (ID INT PRIMARY KEY AUTO_INCREMENT, table_name VARCHAR(100)); INSERT INTO system_tables(table_name) SELECT UPPER(concat(table_schema, ".", table_name)) FROM INFORMATION_SCHEMA.tables WHERE table_schema = 'mysql' AND table_name NOT IN('general_log', 'slow_log', 'ndb_binlog_index'); #----------------------------------------------------------------------- # Test case to verify altering system table's engine to MyISAM. Changing # system table's engine to MyISAM is not allowed. #----------------------------------------------------------------------- CREATE PROCEDURE test_system_table_alter_engine() BEGIN DECLARE n INT DEFAULT 0; DECLARE i INT DEFAULT 1; -- ER_UNSUPPORTED_ENGINE(1726) is reported for all the system engines except for -- innodb_index_stats and innodb_table_stats. ER_TOO_LONG_KEY(1071) is reported for -- innodb_index_stats and ER_NOT_ALLOWED_COMMAND(1148) is reported for innodb_table_stats -- for now. DECLARE CONTINUE HANDLER FOR 1726, 1071, 1148 BEGIN GET DIAGNOSTICS CONDITION 1 @message = MESSAGE_TEXT; SELECT @message AS ERROR; END; SELECT count(*) FROM system_tables INTO n; WHILE i <= n DO SELECT table_name FROM system_tables WHERE id = i INTO @table_name; SELECT @table_name; SET @sql_text = concat("ALTER TABLE ", @table_name, " ENGINE = MyISAM"); PREPARE stmt FROM @sql_text; EXECUTE stmt; DEALLOCATE PREPARE stmt; SET i = i + 1; END WHILE; END$ CALL test_system_table_alter_engine(); @table_name MYSQL.COLUMNS_PRIV ERROR Storage engine 'MyISAM' does not support system tables. [mysql.columns_priv] @table_name MYSQL.COMPONENT ERROR Storage engine 'MyISAM' does not support system tables. [mysql.component] @table_name MYSQL.DB ERROR Storage engine 'MyISAM' does not support system tables. [mysql.db] @table_name MYSQL.DEFAULT_ROLES ERROR Storage engine 'MyISAM' does not support system tables. [mysql.default_roles] @table_name MYSQL.ENGINE_COST ERROR Storage engine 'MyISAM' does not support system tables. [mysql.engine_cost] @table_name MYSQL.FUNC ERROR Storage engine 'MyISAM' does not support system tables. [mysql.func] @table_name MYSQL.GLOBAL_GRANTS ERROR Storage engine 'MyISAM' does not support system tables. [mysql.global_grants] @table_name MYSQL.GTID_EXECUTED ERROR Storage engine 'MyISAM' does not support system tables. [mysql.gtid_executed] @table_name MYSQL.HELP_CATEGORY ERROR Storage engine 'MyISAM' does not support system tables. [mysql.help_category] @table_name MYSQL.HELP_KEYWORD ERROR Storage engine 'MyISAM' does not support system tables. [mysql.help_keyword] @table_name MYSQL.HELP_RELATION ERROR Storage engine 'MyISAM' does not support system tables. [mysql.help_relation] @table_name MYSQL.HELP_TOPIC ERROR Storage engine 'MyISAM' does not support system tables. [mysql.help_topic] @table_name MYSQL.INNODB_INDEX_STATS ERROR Specified key was too long; max key length is 1000 bytes @table_name MYSQL.INNODB_TABLE_STATS ERROR The used command is not allowed with this MySQL version @table_name MYSQL.PASSWORD_HISTORY ERROR Storage engine 'MyISAM' does not support system tables. [mysql.password_history] @table_name MYSQL.PLUGIN ERROR Storage engine 'MyISAM' does not support system tables. [mysql.plugin] @table_name MYSQL.PROCS_PRIV ERROR Storage engine 'MyISAM' does not support system tables. [mysql.procs_priv] @table_name MYSQL.PROXIES_PRIV ERROR Storage engine 'MyISAM' does not support system tables. [mysql.proxies_priv] @table_name MYSQL.ROLE_EDGES ERROR Storage engine 'MyISAM' does not support system tables. [mysql.role_edges] @table_name MYSQL.SERVER_COST ERROR Storage engine 'MyISAM' does not support system tables. [mysql.server_cost] @table_name MYSQL.SERVERS ERROR Storage engine 'MyISAM' does not support system tables. [mysql.servers] @table_name MYSQL.SLAVE_MASTER_INFO ERROR Storage engine 'MyISAM' does not support system tables. [mysql.slave_master_info] @table_name MYSQL.SLAVE_RELAY_LOG_INFO ERROR Storage engine 'MyISAM' does not support system tables. [mysql.slave_relay_log_info] @table_name MYSQL.SLAVE_WORKER_INFO ERROR Storage engine 'MyISAM' does not support system tables. [mysql.slave_worker_info] @table_name MYSQL.TABLES_PRIV ERROR Storage engine 'MyISAM' does not support system tables. [mysql.tables_priv] @table_name MYSQL.TIME_ZONE ERROR Storage engine 'MyISAM' does not support system tables. [mysql.time_zone] @table_name MYSQL.TIME_ZONE_LEAP_SECOND ERROR Storage engine 'MyISAM' does not support system tables. [mysql.time_zone_leap_second] @table_name MYSQL.TIME_ZONE_NAME ERROR Storage engine 'MyISAM' does not support system tables. [mysql.time_zone_name] @table_name MYSQL.TIME_ZONE_TRANSITION ERROR Storage engine 'MyISAM' does not support system tables. [mysql.time_zone_transition] @table_name MYSQL.TIME_ZONE_TRANSITION_TYPE ERROR Storage engine 'MyISAM' does not support system tables. [mysql.time_zone_transition_type] @table_name MYSQL.USER ERROR Storage engine 'MyISAM' does not support system tables. [mysql.user] DROP PROCEDURE test_system_table_alter_engine; #----------------------------------------------------------------------- # Test case to verify system table creation in MyISAM engine. Creating # system table in MyISAM is allowed to support logical upgrade. #----------------------------------------------------------------------- CREATE PROCEDURE execute_stmt(stmt VARCHAR(255)) BEGIN SET @error_no = 0; SET @sql_stmt = stmt; PREPARE stmt FROM @sql_stmt; EXECUTE stmt; GET DIAGNOSTICS CONDITION 1 @error_no = MYSQL_ERRNO, @error_message = MESSAGE_TEXT; IF @error_no > 0 THEN SELECT "Warning" AS SEVERITY, @error_no as ERRNO, @error_message as MESSAGE; END IF; DEALLOCATE PREPARE stmt; END$ CREATE PROCEDURE test_create_system_table() BEGIN DECLARE n INT DEFAULT 0; DECLARE i INT DEFAULT 1; -- Error ER_NO_SYSTEM_TABLE_ACCESS(3554) is reported for innodb_table_stats and -- innodb_index_stats. For other tables ER_UNSUPPORTED_ENGINE "warning" is reported. -- Warning is handled in the execute_stmt(). DECLARE CONTINUE HANDLER FOR 3554 BEGIN GET DIAGNOSTICS CONDITION 1 @error = MYSQL_ERRNO, @error_message = MESSAGE_TEXT; END; SELECT count(*) FROM system_tables INTO n; WHILE i <= n DO SET @error = 0; SELECT table_name FROM system_tables WHERE id = i INTO @table_name; SET @sql_text = concat('RENAME TABLE ', @table_name, ' TO mysql.backup_table'); CALL execute_stmt(@sql_text); SET @sql_text = concat('CREATE TABLE ', @table_name, ' ENGINE=InnoDB AS SELECT * FROM mysql.backup_table'); CALL execute_stmt(@sql_text); SET @sql_text = concat('DROP TABLE ', @table_name); CALL execute_stmt(@sql_text); SET @sql_text = concat('CREATE TABLE ', @table_name, ' ENGINE=MyISAM AS SELECT * FROM mysql.backup_table'); CALL execute_stmt(@sql_text); IF @error > 0 THEN SELECT "ERROR" AS SEVERITY, @error AS ERRNO, @error_message AS MESSAGE; ELSE SET @sql_text = concat('DROP TABLE ', @table_name); CALL execute_stmt(@sql_text); END IF; SET @sql_text = concat('RENAME TABLE mysql.backup_table TO ', @table_name); CALL execute_stmt(@sql_text); SET i = i + 1; END WHILE; END$ CALL test_create_system_table(); SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.columns_priv] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.component] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.db] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.default_roles] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.engine_cost] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.func] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.global_grants] SEVERITY ERRNO MESSAGE Warning 3129 Please do not modify the gtid_executed table. This is a mysql internal system table to store GTIDs for committed transactions. Modifying it can lead to an inconsistent GTID state. SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.gtid_executed] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.help_category] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.help_keyword] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.help_relation] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.help_topic] SEVERITY ERRNO MESSAGE ERROR 3554 Access to system table 'mysql.innodb_index_stats' is rejected. SEVERITY ERRNO MESSAGE ERROR 3554 Access to system table 'mysql.innodb_table_stats' is rejected. SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.password_history] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.plugin] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.procs_priv] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.proxies_priv] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.role_edges] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.server_cost] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.servers] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.slave_master_info] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.slave_relay_log_info] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.slave_worker_info] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.tables_priv] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.time_zone] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.time_zone_leap_second] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.time_zone_name] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.time_zone_transition] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.time_zone_transition_type] SEVERITY ERRNO MESSAGE Warning 1726 Storage engine 'MyISAM' does not support system tables. [mysql.user] DROP PROCEDURE test_create_system_table; DROP PROCEDURE execute_stmt; DROP TABLE system_tables;