|
| 1 | +# |
| 2 | +# WL#8594 - Provide an option to reject creation of user tables for specified |
| 3 | +# storage engines. |
| 4 | +# |
| 5 | + |
| 6 | +# Test SQL statements 'CREATE [TEMPORARY] TABLE', 'ALTER TABLE ... ENGINE' |
| 7 | +# and 'CREATE/ALTER TABLESPACE' shall fail with the error "Storage engine |
| 8 | +# 'storage engine name' is disabled (Table creation is disallowed.)" for the |
| 9 | +# storage engines specified by disabled-storage-engine option. |
| 10 | + |
| 11 | +--source include/have_example_plugin.inc |
| 12 | +--source include/not_embedded.inc |
| 13 | + |
| 14 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 15 | +CREATE TABLE t1(c1 int) ENGINE=HEAP; |
| 16 | + |
| 17 | +CREATE TABLE t1 (c1 int) ENGINE=MYISAM; |
| 18 | +INSERT INTO t1 VALUES(1); |
| 19 | + |
| 20 | +CREATE TABLESPACE tb1 ADD DATAFILE 't1.ibd' ENGINE=INNODB; |
| 21 | +CREATE TABLE tp1 (c1 int) PARTITION BY KEY (c1) PARTITIONS 1; |
| 22 | + |
| 23 | +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 24 | +--shutdown_server |
| 25 | +--source include/wait_until_disconnected.inc |
| 26 | + |
| 27 | +# Restart server along with myisam storage engine disabled and check alter |
| 28 | +# table on existing myisam table t1 created above is allowed. |
| 29 | +--exec echo "restart: --disabled_storage_engines=innodb,myisam,heap,example" >$MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 30 | +--enable_reconnect |
| 31 | +--source include/wait_until_connected_again.inc |
| 32 | + |
| 33 | +SHOW VARIABLES LIKE 'disabled_storage_engines'; |
| 34 | +SELECT * FROM t1; |
| 35 | +ALTER TABLE t1 ENGINE=MyISAM, ADD COLUMN c2 INT; |
| 36 | +ALTER TABLE t1 ADD COLUMN c3 INT; |
| 37 | +DROP TABLESPACE tb1; |
| 38 | + |
| 39 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 40 | +CREATE TABLE t2 LIKE t1; |
| 41 | + |
| 42 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 43 | +CREATE TABLE t2 AS SELECT * FROM t1; |
| 44 | + |
| 45 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 46 | +ALTER TABLE t1 ENGINE=InnoDB; |
| 47 | + |
| 48 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 49 | +ALTER TABLE t1 ENGINE=HEAP; |
| 50 | + |
| 51 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 52 | +CREATE TABLE t2(c1 int) ENGINE=INNODB SELECT c1 FROM t1; |
| 53 | + |
| 54 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 55 | +CREATE TABLE t2(c1 int) ENGINE=HEAP SELECT c1 FROM t1; |
| 56 | + |
| 57 | +TRUNCATE TABLE t1; |
| 58 | +DROP TABLE t1; |
| 59 | + |
| 60 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 61 | +CREATE TABLESPACE t1 ADD DATAFILE 't1.ibd' ENGINE=INNODB; |
| 62 | + |
| 63 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 64 | +CREATE TABLESPACE t1 ADD DATAFILE 't1.ibd' ENGINE=HEAP; |
| 65 | + |
| 66 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 67 | +ALTER TABLESPACE ts ADD DATAFILE 'ts.ibd' ENGINE=INNODB; |
| 68 | + |
| 69 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 70 | +ALTER TABLESPACE ts ADD DATAFILE 'ts.ibd' ENGINE=HEAP; |
| 71 | + |
| 72 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 73 | +ALTER TABLESPACE ts ADD DATAFILE 'ts.ibd'; |
| 74 | + |
| 75 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 76 | +CREATE TEMPORARY TABLE t1 (c1 int) ENGINE=INNODB; |
| 77 | + |
| 78 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 79 | +CREATE TEMPORARY TABLE t1 (c1 int) ENGINE=HEAP; |
| 80 | + |
| 81 | +delimiter |; |
| 82 | +CREATE PROCEDURE p1() |
| 83 | +BEGIN |
| 84 | + CREATE TABLE t1 (c1 int) ENGINE=MYISAM; |
| 85 | +END | |
| 86 | + |
| 87 | +delimiter ;| |
| 88 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 89 | +CALL p1(); |
| 90 | +DROP PROCEDURE p1; |
| 91 | + |
| 92 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 93 | +CREATE TABLE t1 (c1 int) PARTITION BY KEY (c1) PARTITIONS 1; |
| 94 | + |
| 95 | +INSERT INTO tp1 VALUES(1); |
| 96 | +DROP TABLE tp1; |
| 97 | +# Check creation of table is disallowed under a dynamic storage plugin. |
| 98 | +--replace_regex /\.dll/.so/ |
| 99 | +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; |
| 100 | + |
| 101 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 102 | +CREATE TABLE t1(a int) ENGINE=EXAMPLE; |
| 103 | +UNINSTALL PLUGIN example; |
| 104 | + |
| 105 | +# Reload the plugin and ensure table creation is disallowed. |
| 106 | +--replace_regex /\.dll/.so/ |
| 107 | +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; |
| 108 | + |
| 109 | +--ERROR ER_DISABLED_STORAGE_ENGINE |
| 110 | +CREATE TABLE t1(a int) ENGINE=EXAMPLE; |
| 111 | +UNINSTALL PLUGIN example; |
| 112 | + |
| 113 | +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 114 | +--shutdown_server |
| 115 | +--source include/wait_until_disconnected.inc |
| 116 | + |
| 117 | +--exec echo "restart: --skip-grant-tables --disabled_storage_engines=innodb,myisam,heap,example" >$MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 118 | +--enable_reconnect |
| 119 | +--source include/wait_until_connected_again.inc |
| 120 | +CREATE TABLE t1(a int) ENGINE=MYISAM; |
| 121 | +DROP TABLE t1; |
| 122 | + |
| 123 | +--source include/restart_mysqld.inc |
0 commit comments