-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-6858: enforce_storage_engine option
Merge from Percona Server enforced use of a specific storage engine authored by Stewart Smith. Modified to be session variable and modifiable only by SUPER. Use similar implementation as default_storage_engine.
- Loading branch information
Jan Lindström
committed
Mar 12, 2015
1 parent
ba3573c
commit 8249dca
Showing
16 changed files
with
351 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
drop table if exists t1; | ||
SET SESSION enforce_storage_engine=MyISAM; | ||
select @@session.enforce_storage_engine; | ||
@@session.enforce_storage_engine | ||
MyISAM | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=Memory; | ||
Warnings: | ||
Note 1266 Using storage engine MyISAM for table 't1' | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`c1` int(11) NOT NULL AUTO_INCREMENT, | ||
`c2` varchar(10) DEFAULT NULL, | ||
PRIMARY KEY (`c1`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | ||
DROP TABLE t1; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=MyISAM; | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`c1` int(11) NOT NULL AUTO_INCREMENT, | ||
`c2` varchar(10) DEFAULT NULL, | ||
PRIMARY KEY (`c1`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | ||
DROP TABLE t1; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)); | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`c1` int(11) NOT NULL AUTO_INCREMENT, | ||
`c2` varchar(10) DEFAULT NULL, | ||
PRIMARY KEY (`c1`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | ||
DROP TABLE t1; | ||
SET SESSION sql_mode='NO_ENGINE_SUBSTITUTION'; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=MyISAM; | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`c1` int(11) NOT NULL AUTO_INCREMENT, | ||
`c2` varchar(10) DEFAULT NULL, | ||
PRIMARY KEY (`c1`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | ||
INSERT INTO t1 values (1,'abba'); | ||
CREATE TABLE t2 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=Memory; | ||
ERROR 42000: Unknown storage engine 'MEMORY' | ||
SET SESSION sql_mode=''; | ||
SET SESSION enforce_storage_engine=MyISAM; | ||
select @@session.enforce_storage_engine; | ||
@@session.enforce_storage_engine | ||
MyISAM | ||
select * from t1; | ||
c1 c2 | ||
1 abba | ||
drop table t1; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)); | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`c1` int(11) NOT NULL AUTO_INCREMENT, | ||
`c2` varchar(10) DEFAULT NULL, | ||
PRIMARY KEY (`c1`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | ||
DROP TABLE t1; | ||
SET SESSION enforce_storage_engine=FooBar; | ||
ERROR 42000: Unknown storage engine 'FooBar' | ||
select @@session.enforce_storage_engine; | ||
@@session.enforce_storage_engine | ||
MyISAM | ||
SET SESSION enforce_storage_engine=MyISAM; | ||
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation | ||
SET SESSION enforce_storage_engine=NULL; | ||
SET SESSION sql_mode='NO_ENGINE_SUBSTITUTION'; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=Memory; | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`c1` int(11) NOT NULL AUTO_INCREMENT, | ||
`c2` varchar(10) DEFAULT NULL, | ||
PRIMARY KEY (`c1`) | ||
) ENGINE=MEMORY DEFAULT CHARSET=latin1 | ||
DROP TABLE t1; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=MyISAM; | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`c1` int(11) NOT NULL AUTO_INCREMENT, | ||
`c2` varchar(10) DEFAULT NULL, | ||
PRIMARY KEY (`c1`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | ||
DROP TABLE t1; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)); | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`c1` int(11) NOT NULL AUTO_INCREMENT, | ||
`c2` varchar(10) DEFAULT NULL, | ||
PRIMARY KEY (`c1`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | ||
DROP TABLE t1; | ||
SET GLOBAL enforce_storage_engine=NULL; | ||
ERROR HY000: Variable 'enforce_storage_engine' is a SESSION variable and can't be used with SET GLOBAL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
mysql-test/suite/sys_vars/r/enforce_storage_engine_basic.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
SET @start_session_value = @@session.enforce_storage_engine; | ||
SET @@session.enforce_storage_engine = INNODB; | ||
SET @@session.enforce_storage_engine = DEFAULT; | ||
SELECT @@session.enforce_storage_engine; | ||
@@session.enforce_storage_engine | ||
NULL | ||
SET @@session.enforce_storage_engine = MYISAM; | ||
SELECT @@session.enforce_storage_engine; | ||
@@session.enforce_storage_engine | ||
MyISAM | ||
SET @@session.enforce_storage_engine = MERGE; | ||
SELECT @@session.enforce_storage_engine; | ||
@@session.enforce_storage_engine | ||
MRG_MyISAM | ||
SET @@session.enforce_storage_engine = MEMORY; | ||
SELECT @@session.enforce_storage_engine; | ||
@@session.enforce_storage_engine | ||
MEMORY | ||
SET @@session.enforce_storage_engine = INNODB; | ||
SELECT @@session.enforce_storage_engine; | ||
@@session.enforce_storage_engine | ||
InnoDB | ||
SET @@session.enforce_storage_engine = 8199; | ||
ERROR 42000: Incorrect argument type to variable 'enforce_storage_engine' | ||
SET @@session.enforce_storage_engine = 65530.34; | ||
ERROR 42000: Incorrect argument type to variable 'enforce_storage_engine' | ||
SET @@session.enforce_storage_engine = RECORD; | ||
ERROR 42000: Unknown storage engine 'RECORD' | ||
SELECT @@session.enforce_storage_engine = | ||
VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES | ||
WHERE VARIABLE_NAME='enforce_storage_engine'; | ||
@@session.enforce_storage_engine = | ||
VARIABLE_VALUE | ||
1 | ||
SET @@session.enforce_storage_engine = TRUE; | ||
ERROR 42000: Incorrect argument type to variable 'enforce_storage_engine' | ||
SET @@session.enforce_storage_engine = FALSE; | ||
ERROR 42000: Incorrect argument type to variable 'enforce_storage_engine' | ||
SET @@session.enforce_storage_engine = @start_session_value; |
45 changes: 45 additions & 0 deletions
45
mysql-test/suite/sys_vars/r/innodb_instrument_semaphores_basic.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# | ||
# innodb_instrument_semaphores | ||
# | ||
# save the initial value | ||
SET @innodb_instrument_semaphores_global_saved = @@global.innodb_instrument_semaphores; | ||
# default | ||
SELECT @@global.innodb_instrument_semaphores; | ||
@@global.innodb_instrument_semaphores | ||
0 | ||
|
||
# scope | ||
SELECT @@session.innodb_instrument_semaphores; | ||
ERROR HY000: Variable 'innodb_instrument_semaphores' is a GLOBAL variable | ||
SET @@global.innodb_instrument_semaphores=OFF; | ||
SELECT @@global.innodb_instrument_semaphores; | ||
@@global.innodb_instrument_semaphores | ||
0 | ||
SET @@global.innodb_instrument_semaphores=ON; | ||
SELECT @@global.innodb_instrument_semaphores; | ||
@@global.innodb_instrument_semaphores | ||
1 | ||
|
||
# valid values | ||
SET @@global.innodb_instrument_semaphores='OFF'; | ||
SELECT @@global.innodb_instrument_semaphores; | ||
@@global.innodb_instrument_semaphores | ||
0 | ||
SET @@global.innodb_instrument_semaphores=ON; | ||
SELECT @@global.innodb_instrument_semaphores; | ||
@@global.innodb_instrument_semaphores | ||
1 | ||
SET @@global.innodb_instrument_semaphores=default; | ||
SELECT @@global.innodb_instrument_semaphores; | ||
@@global.innodb_instrument_semaphores | ||
0 | ||
|
||
# invalid values | ||
SET @@global.innodb_instrument_semaphores=NULL; | ||
ERROR 42000: Variable 'innodb_instrument_semaphores' can't be set to the value of 'NULL' | ||
SET @@global.innodb_instrument_semaphores='junk'; | ||
ERROR 42000: Variable 'innodb_instrument_semaphores' can't be set to the value of 'junk' | ||
|
||
# restore the initial value | ||
SET @@global.innodb_instrument_semaphores = @innodb_instrument_semaphores_global_saved; | ||
# End of test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
mysql-test/suite/sys_vars/t/enforce_storage_engine_basic.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--source include/not_embedded.inc | ||
--source include/have_innodb.inc | ||
--source include/load_sysvars.inc | ||
|
||
SET @start_session_value = @@session.enforce_storage_engine; | ||
|
||
SET @@session.enforce_storage_engine = INNODB; | ||
SET @@session.enforce_storage_engine = DEFAULT; | ||
|
||
SELECT @@session.enforce_storage_engine; | ||
|
||
SET @@session.enforce_storage_engine = MYISAM; | ||
SELECT @@session.enforce_storage_engine; | ||
SET @@session.enforce_storage_engine = MERGE; | ||
SELECT @@session.enforce_storage_engine; | ||
SET @@session.enforce_storage_engine = MEMORY; | ||
SELECT @@session.enforce_storage_engine; | ||
SET @@session.enforce_storage_engine = INNODB; | ||
SELECT @@session.enforce_storage_engine; | ||
|
||
--Error ER_WRONG_TYPE_FOR_VAR | ||
SET @@session.enforce_storage_engine = 8199; | ||
|
||
--Error ER_WRONG_TYPE_FOR_VAR | ||
SET @@session.enforce_storage_engine = 65530.34; | ||
|
||
--Error ER_UNKNOWN_STORAGE_ENGINE | ||
SET @@session.enforce_storage_engine = RECORD; | ||
|
||
SELECT @@session.enforce_storage_engine = | ||
VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES | ||
WHERE VARIABLE_NAME='enforce_storage_engine'; | ||
|
||
--Error ER_WRONG_TYPE_FOR_VAR | ||
SET @@session.enforce_storage_engine = TRUE; | ||
|
||
--Error ER_WRONG_TYPE_FOR_VAR | ||
SET @@session.enforce_storage_engine = FALSE; | ||
|
||
SET @@session.enforce_storage_engine = @start_session_value; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
-- source include/not_embedded.inc | ||
|
||
--disable_warnings | ||
drop table if exists t1; | ||
--enable_warnings | ||
|
||
SET SESSION enforce_storage_engine=MyISAM; | ||
select @@session.enforce_storage_engine; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=Memory; | ||
SHOW CREATE TABLE t1; | ||
DROP TABLE t1; | ||
|
||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=MyISAM; | ||
SHOW CREATE TABLE t1; | ||
DROP TABLE t1; | ||
|
||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)); | ||
SHOW CREATE TABLE t1; | ||
DROP TABLE t1; | ||
|
||
SET SESSION sql_mode='NO_ENGINE_SUBSTITUTION'; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=MyISAM; | ||
SHOW CREATE TABLE t1; | ||
INSERT INTO t1 values (1,'abba'); | ||
|
||
--error 1286 | ||
CREATE TABLE t2 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=Memory; | ||
|
||
SET SESSION sql_mode=''; | ||
|
||
SET SESSION enforce_storage_engine=MyISAM; | ||
select @@session.enforce_storage_engine; | ||
select * from t1; | ||
drop table t1; | ||
|
||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)); | ||
SHOW CREATE TABLE t1; | ||
DROP TABLE t1; | ||
|
||
--error 1286 | ||
SET SESSION enforce_storage_engine=FooBar; | ||
|
||
select @@session.enforce_storage_engine; | ||
|
||
--source include/add_anonymous_users.inc | ||
|
||
connect (con1,localhost,user_1,,); | ||
connection con1; | ||
--error 1227 | ||
SET SESSION enforce_storage_engine=MyISAM; | ||
disconnect con1; | ||
|
||
connection default; | ||
|
||
--source include/delete_anonymous_users.inc | ||
|
||
SET SESSION enforce_storage_engine=NULL; | ||
|
||
SET SESSION sql_mode='NO_ENGINE_SUBSTITUTION'; | ||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=Memory; | ||
SHOW CREATE TABLE t1; | ||
DROP TABLE t1; | ||
|
||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=MyISAM; | ||
SHOW CREATE TABLE t1; | ||
DROP TABLE t1; | ||
|
||
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)); | ||
SHOW CREATE TABLE t1; | ||
DROP TABLE t1; | ||
|
||
--error 1228 | ||
SET GLOBAL enforce_storage_engine=NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.