File: no_engine_substitution.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (235 lines) | stat: -rw-r--r-- 6,073 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
--source include/have_example_plugin.inc

--echo #
--echo # Bug#27502530: DISABLING NO_ENGINE_SUBSTITUTION DOES NOT BEHAVE AS
--echo #               DOCUMENTED
--echo #

--echo # Started the server by disabling InnoDB using system variable 'disabled_storage_engines'
SELECT @@disabled_storage_engines;
SET DEFAULT_STORAGE_ENGINE= MyISAM;
SELECT @@default_storage_engine;

--echo
--echo # NO_ENGINE_SUBSTITUTION enabled
--disable_warnings
SET SQL_MODE= 'NO_ENGINE_SUBSTITUTION';
--enable_warnings

CREATE TABLE t1(c1 INT) ENGINE= MyISAM;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES(1);

--error ER_DISABLED_STORAGE_ENGINE
CREATE TABLE t2(c1 INT) ENGINE= InnoDB;

--error ER_DISABLED_STORAGE_ENGINE
CREATE TEMPORARY TABLE t2(c1 INT) ENGINE= InnoDB;

--error ER_DISABLED_STORAGE_ENGINE
ALTER TABLE t1 ENGINE= InnoDB;

--echo # Create a table in MYISAM, which will become disabled after restart
CREATE TABLE t2 (c1 INT) ENGINE=MYISAM;

--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc

--echo # Restart the server disabling the myisam storage engine using variable 'disabled_storage_engines'
--exec echo "restart: --disabled_storage_engines=myisam,example" >$MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

SELECT @@disabled_storage_engines;
SET @old_default_engine= @@default_storage_engine;

--echo # Changing the default engine to InnoDB
SET DEFAULT_STORAGE_ENGINE= InnoDB;
SELECT @@default_storage_engine;

--error ER_DISABLED_STORAGE_ENGINE
CREATE TABLE t2(c1 INT) ENGINE= MyISAM;

SELECT * FROM t1;

--error ER_UNKNOWN_STORAGE_ENGINE
ALTER TABLE t2 ENGINE=example;

SET SQL_MODE='';
ALTER TABLE t2 ENGINE=example;
SHOW CREATE TABLE t2;
SET SQL_MODE= 'NO_ENGINE_SUBSTITUTION';

--echo # Checking table creation with dynamic storage plugins
--replace_regex /\.dll/.so/
eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';

--error ER_DISABLED_STORAGE_ENGINE
ALTER TABLE t2 ENGINE=example;

SET SQL_MODE='';

ALTER TABLE t2 ENGINE=example;
SHOW CREATE TABLE t2;
DROP TABLE t2;
SET SQL_MODE= 'NO_ENGINE_SUBSTITUTION';

--ERROR ER_DISABLED_STORAGE_ENGINE
CREATE TABLE t1(a int) ENGINE=EXAMPLE;

--echo
--echo # NO_ENGINE_SUBSTITUTION disabled
--disable_warnings
SET SQL_MODE='';
--enable_warnings

--echo # The disabled engine is substituted with the default engine for the table.

# Engine for the table substituted to InnoDB
CREATE TABLE t2(c1 INT) ENGINE= MyISAM;
SHOW CREATE TABLE t2;

CREATE TABLE t3 LIKE t1;
SHOW CREATE TABLE t3;

CREATE TEMPORARY TABLE t4(c1 INT) ENGINE= MyISAM;
SHOW CREATE TABLE t4;

CREATE TABLE t5 (c1 INT) ENGINE= ARCHIVE;
--echo # ALTER TABLE ... ENGINE reports a warning and the table is not altered.
ALTER TABLE t5 ENGINE= MyISAM;
SHOW CREATE TABLE t5;

DELIMITER /;
CREATE PROCEDURE p1()
BEGIN
  CREATE TABLE t6(c1 INT) ENGINE= MyISAM;
END /

DELIMITER ;/
CALL p1();
SHOW CREATE TABLE t6;

CREATE TABLE t7 (c1 INT) ENGINE= EXAMPLE;
SHOW CREATE TABLE t7;

# If disabled engine and the default engine are the same.
SET DEFAULT_STORAGE_ENGINE= MyISAM;
--error ER_DISABLED_STORAGE_ENGINE
CREATE TABLE t8 (c1 INT) ENGINE= MyISAM;

# If disabled engine and default engine both are in the disabled SE list.
--error ER_DISABLED_STORAGE_ENGINE
CREATE TABLE t8 (c1 INT) ENGINE= EXAMPLE;

--echo #
--echo # Bug#29899151: CORE AT CREATE TABLE WITH FK FOR TABLE TRANSFERRED
--echo # FROM MYISAM TO INNODB
--echo #

--echo # Allow engine substitution
SET sql_mode = "";
SET DEFAULT_STORAGE_ENGINE= InnoDB;
CREATE TABLE parent_table (i INT PRIMARY KEY);

CREATE TABLE child_table (
i INT,

CONSTRAINT fk_parent_table
FOREIGN KEY (i)
REFERENCES parent_table (i) ON DELETE CASCADE
) ENGINE=MyISAM;

DROP TABLE child_table;
DROP TABLE parent_table;

--echo # Verify that creating a temporary table LIKE a table in a storage
--echo # engine which does not support temporary tables, defaults to the 
--echo # default_tmp_storage_engine, even with no_substitution.
CREATE TEMPORARY TABLE tt1 LIKE performance_schema.setup_consumers;
SHOW CREATE TABLE tt1;
DROP TABLE tt1;

SET default_tmp_storage_engine=MYISAM;

--error ER_DISABLED_STORAGE_ENGINE
CREATE TEMPORARY TABLE tt1(c1 INT);

--error ER_ILLEGAL_HA_CREATE_OPTION
CREATE TEMPORARY TABLE tt1 LIKE performance_schema.setup_consumers;


# Cleanup
UNINSTALL PLUGIN EXAMPLE;
DROP PROCEDURE p1;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
DROP TABLE t5;
DROP TABLE t6;
DROP TABLE t7;

SET @@default_storage_engine=@old_default_engine;
--disable_warnings
SET sql_mode= DEFAULT;
--enable_warnings

--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc

--echo # Restart the server disabling archive engine via '--skip-archive or --archive=off'
--exec echo "restart: --archive=off" >$MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

SET @old_default_engine= @@default_storage_engine;
SET DEFAULT_STORAGE_ENGINE= MyISAM;
SET DEFAULT_TMP_STORAGE_ENGINE= MyISAM;

--echo
--echo # NO_ENGINE_SUBSTITUTION enabled
--disable_warnings
SET SQL_MODE='NO_ENGINE_SUBSTITUTION';
--enable_warnings

--error ER_UNKNOWN_STORAGE_ENGINE
CREATE TABLE t1 (c1 INT) ENGINE= ARCHIVE;

--error ER_UNKNOWN_STORAGE_ENGINE
CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE= ARCHIVE;

CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
--error ER_UNKNOWN_STORAGE_ENGINE
ALTER TABLE t1 ENGINE= ARCHIVE;

--echo
--echo # NO_ENGINE_SUBSTITUTION disabled
--disable_warnings
SET SQL_MODE='';
--enable_warnings

CREATE TABLE t2 (c1 INT) ENGINE=ARCHIVE;
SHOW CREATE TABLE t2;

CREATE TEMPORARY TABLE t3 (c1 INT) ENGINE= ARCHIVE;
SHOW CREATE TABLE t3;

--echo # ALTER TABLE .. ENGINE reports a warning and the table is not altered.
ALTER TABLE t1 ENGINE= ARCHIVE;
SHOW CREATE TABLE t1;

--echo
# Cleanup
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;

SET @@default_storage_engine= @old_default_engine;
--disable_warnings
SET sql_mode = DEFAULT;
--enable_warnings

--source include/restart_mysqld.inc