File: system_tables_myisam.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 (310 lines) | stat: -rw-r--r-- 12,129 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#
--source include/have_udf.inc
--source include/not_valgrind.inc
--source include/force_restart.inc

--echo #
--echo # Bug#30248138 - adding a function once mysql.func is converted to myisam
--echo #                leads to crash
--echo #

CALL mtr.add_suppression("Column count of");
CALL mtr.add_suppression("Incorrect definition of table");
CALL mtr.add_suppression("Cannot load from");
CALL mtr.add_suppression("Storage engine 'MyISAM' does not");

--echo #-----------------------------------------------------------------------
--echo # Test cases to verify system table's behavior with storage engines
--echo # InnoDB and MyISAM.
--echo #-----------------------------------------------------------------------
--source include/system_tables_storage_engine_tests.inc


--echo #-----------------------------------------------------------------------
--echo # Test case to verify forbidden operations when
--echo #
--echo #   1 System table is created in the MyISAM engine.
--echo #   2 System table is in InnoDB engine but table definition is changed.
--echo #-----------------------------------------------------------------------
CREATE USER 'user1'@'%';
CREATE TABLE t1 (f1 INT);

# mysql.func
--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
eval CREATE FUNCTION sequence RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB";
RENAME TABLE mysql.func TO mysql.func_bkp;
CREATE TABLE mysql.func ENGINE='MyISAM' AS SELECT * FROM mysql.func_bkp;
--echo # Without the fix, following statement results in the assert
--echo # condition failure.
--error ER_UNSUPPORTED_ENGINE
CREATE FUNCTION udf_func RETURNS STRING SONAME 'udf_func.so';
--error ER_UNSUPPORTED_ENGINE
DROP FUNCTION sequence;

ALTER TABLE mysql.func ENGINE='InnoDB',
                       DROP COLUMN ret;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
CREATE FUNCTION udf_func RETURNS STRING SONAME 'udf_func.so';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
DROP FUNCTION sequence;
DROP TABLE mysql.func;
RENAME TABLE mysql.func_bkp TO mysql.func;
DROP FUNCTION sequence;

# mysql.plugin
RENAME TABLE mysql.plugin TO mysql.plugin_bkp;
CREATE TABLE mysql.plugin ENGINE='MyISAM' AS SELECT * FROM mysql.plugin_bkp;
--error ER_UNSUPPORTED_ENGINE
INSTALL PLUGIN my_plug soname 'some_plugin.so';
--error ER_UNSUPPORTED_ENGINE
UNINSTALL PLUGIN my_plug;

ALTER TABLE mysql.plugin ENGINE=InnoDB,
                         MODIFY dl CHAR(64);
--error ER_CANNOT_LOAD_FROM_TABLE_V2
INSTALL PLUGIN my_plug soname 'some_plugin.so';
--error ER_CANNOT_LOAD_FROM_TABLE_V2
UNINSTALL PLUGIN my_plug;
DROP TABLE mysql.plugin;
RENAME TABLE mysql.plugin_bkp TO mysql.plugin;

# mysql.servers
RENAME TABLE mysql.servers TO mysql.servers_bkp;
CREATE TABLE mysql.servers ENGINE='MyISAM' AS SELECT * FROM mysql.servers_bkp;
--error ER_UNSUPPORTED_ENGINE
CREATE SERVER fedlnk FOREIGN DATA WRAPPER mysql OPTIONS
       (USER 'fed_user', HOST 'remote_host', PORT 9306, DATABASE 'federated');
--error ER_UNSUPPORTED_ENGINE
DROP SERVER fedlnk;
--error ER_UNSUPPORTED_ENGINE
ALTER SERVER fedlnk OPTIONS (USER 'sally');

ALTER TABLE mysql.servers ENGINE='InnoDB',
                          MODIFY WRAPPER varchar(128);
--error ER_CANNOT_LOAD_FROM_TABLE_V2
CREATE SERVER fedlnk FOREIGN DATA WRAPPER mysql OPTIONS
       (USER 'fed_user', HOST 'remote_host', PORT 9306, DATABASE 'federated');
--error ER_CANNOT_LOAD_FROM_TABLE_V2
DROP SERVER fedlnk;
--error ER_CANNOT_LOAD_FROM_TABLE_V2
ALTER SERVER fedlnk OPTIONS (USER 'sally');
DROP TABLE mysql.servers;
RENAME TABLE mysql.servers_bkp TO mysql.servers;

# mysql.user
RENAME TABLE mysql.user TO mysql.user_bkp;
CREATE TABLE mysql.user ENGINE='MyISAM' AS SELECT * FROM mysql.user_bkp;
--error ER_UNSUPPORTED_ENGINE
CREATE USER 'user2'@'%';
--error ER_UNSUPPORTED_ENGINE
DROP USER 'user1'@'%';
--error ER_UNSUPPORTED_ENGINE
ALTER USER 'user1'@'%' PASSWORD EXPIRE;
--error ER_UNSUPPORTED_ENGINE
GRANT SELECT ON t1 TO 'user1'@'%';
--error ER_UNSUPPORTED_ENGINE
REVOKE SELECT ON t1 FROM 'user1'@'%';
--error ER_UNSUPPORTED_ENGINE
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user1'@'%';
--error ER_UNSUPPORTED_ENGINE
SET PASSWORD FOR 'user1'@'%' = '123';
--error ER_UNSUPPORTED_ENGINE
RENAME USER 'user1'@'%' TO 'user1'@'%';

ALTER TABLE mysql.user ENGINE='InnoDB',
                       DROP COLUMN max_updates;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
CREATE USER 'user2'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
DROP USER 'user1'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
ALTER USER 'user1'@'%' PASSWORD EXPIRE;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
GRANT SELECT ON t1 TO 'user1'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
REVOKE SELECT ON t1 FROM 'user1'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user1'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
SET PASSWORD FOR 'user1'@'%' = '123';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
RENAME USER 'user1'@'%' TO 'user1'@'%';
DROP TABLE mysql.user;
RENAME TABLE mysql.user_bkp TO mysql.user;

# mysql.columns_priv
RENAME TABLE mysql.columns_priv TO mysql.columns_priv_bkp;
CREATE TABLE mysql.columns_priv ENGINE='MyISAM' AS SELECT * FROM mysql.columns_priv_bkp;
--error ER_UNSUPPORTED_ENGINE
GRANT SELECT(f1) ON t1 TO 'user1'@'%';
--error ER_UNSUPPORTED_ENGINE
REVOKE SELECT ON t1.f1 FROM 'user1'@'%';

ALTER TABLE mysql.columns_priv ENGINE='InnoDB',
                               DROP COLUMN Timestamp;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
GRANT SELECT(f1) ON t1 TO 'user1'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
REVOKE SELECT ON t1.f1 FROM 'user1'@'%';
DROP TABLE mysql.columns_priv;
RENAME TABLE mysql.columns_priv_bkp TO mysql.columns_priv;

# mysql.tables_priv
RENAME TABLE mysql.tables_priv TO mysql.tables_priv_bkp;
CREATE TABLE mysql.tables_priv ENGINE='MyISAM' AS SELECT * FROM mysql.tables_priv_bkp;
--error ER_UNSUPPORTED_ENGINE
GRANT SELECT ON t1 TO 'user1'@'%';
--error ER_UNSUPPORTED_ENGINE
REVOKE SELECT ON t1 FROM 'user1'@'%';

ALTER TABLE mysql.tables_priv ENGINE='InnoDB',
                              DROP COLUMN Timestamp;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
GRANT SELECT ON t1 TO 'user1'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
REVOKE SELECT ON t1 FROM 'user1'@'%';
DROP TABLE mysql.tables_priv;
RENAME TABLE mysql.tables_priv_bkp TO mysql.tables_priv;

# mysql.procs_priv
CREATE FUNCTION f1() RETURNS INT return 1;
RENAME TABLE mysql.procs_priv TO mysql.procs_priv_bkp;
CREATE TABLE mysql.procs_priv ENGINE='MyISAM' AS SELECT * FROM mysql.procs_priv_bkp;
--error ER_UNSUPPORTED_ENGINE
GRANT EXECUTE ON FUNCTION f1 TO 'user1'@'%';
--error ER_UNSUPPORTED_ENGINE
REVOKE EXECUTE ON FUNCTION f1 FROM 'user1'@'%';

ALTER TABLE mysql.procs_priv ENGINE='InnoDB',
                             DROP COLUMN timestamp;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
GRANT EXECUTE ON FUNCTION f1 TO 'user1'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
REVOKE EXECUTE ON FUNCTION f1 FROM 'user1'@'%';
DROP TABLE mysql.procs_priv;
RENAME TABLE mysql.procs_priv_bkp TO mysql.procs_priv;

# mysql.proxies_priv
RENAME TABLE mysql.proxies_priv TO mysql.proxies_priv_bkp;
CREATE TABLE mysql.proxies_priv ENGINE='MyISAM' AS SELECT * FROM mysql.proxies_priv_bkp;
--error ER_UNSUPPORTED_ENGINE
GRANT PROXY ON 'user1'@'%' TO 'user2'@'%';
--error ER_UNSUPPORTED_ENGINE
REVOKE PROXY ON 'user1'@'%' FROM 'user2'@'%';

ALTER TABLE mysql.proxies_priv ENGINE='InnoDB',
                               DROP COLUMN timestamp;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
GRANT PROXY ON 'user1'@'%' TO 'user2'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
REVOKE PROXY ON 'user1'@'%' FROM 'user2'@'%';
DROP TABLE mysql.proxies_priv;
RENAME TABLE mysql.proxies_priv_bkp TO mysql.proxies_priv;

# mysql.component
RENAME TABLE mysql.component TO mysql.component_bkp;
CREATE TABLE mysql.component ENGINE='MyISAM' AS SELECT * FROM mysql.component_bkp;
--error ER_UNSUPPORTED_ENGINE
INSTALL COMPONENT "file://component_log_sink_json";
--error ER_UNSUPPORTED_ENGINE
UNINSTALL COMPONENT "file://component_log_sink_json";

ALTER TABLE mysql.component ENGINE='InnoDB',
                            DROP COLUMN component_urn;
--error ER_COMPONENT_TABLE_INCORRECT
INSTALL COMPONENT "file://component_log_sink_json";
--error ER_COMPONENT_TABLE_INCORRECT
UNINSTALL COMPONENT "file://component_log_sink_json";
DROP TABLE mysql.component;
RENAME TABLE mysql.component_bkp TO mysql.component;

# mysql.db
RENAME TABLE mysql.db TO mysql.db_bkp;
CREATE TABLE mysql.db ENGINE='MyISAM' AS SELECT * FROM mysql.db_bkp;
--error ER_UNSUPPORTED_ENGINE
GRANT ALL ON db.* TO 'user1'@'%';

ALTER TABLE mysql.db ENGINE='InnoDB',
                     DROP COLUMN Select_priv;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
GRANT ALL ON db.* TO 'user1'@'%';
DROP TABLE mysql.db;
RENAME TABLE mysql.db_bkp TO mysql.db;

# mysql.default_roles
RENAME TABLE mysql.default_roles TO mysql.default_roles_bkp;
CREATE TABLE mysql.default_roles ENGINE='MyISAM' AS SELECT * FROM mysql.default_roles_bkp;
--error ER_UNSUPPORTED_ENGINE
SET DEFAULT ROLE ALL TO 'user1'@'%';

ALTER TABLE mysql.default_roles ENGINE='InnoDB',
                                DROP COLUMN DEFAULT_ROLE_USER;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
SET DEFAULT ROLE ALL TO 'user1'@'%';
DROP TABLE mysql.default_roles;
RENAME TABLE mysql.default_roles_bkp TO mysql.default_roles;

# mysql.global_grants
RENAME TABLE mysql.global_grants TO mysql.global_grants_bkp;
CREATE TABLE mysql.global_grants ENGINE='MyISAM' AS SELECT * FROM mysql.global_grants_bkp;
--error ER_UNSUPPORTED_ENGINE
GRANT PROCESS ON *.* TO 'user1'@'%';
--error ER_UNSUPPORTED_ENGINE
REVOKE PROCESS ON *.* FROM 'user1'@'%';

ALTER TABLE mysql.global_grants ENGINE='InnoDB',
                                DROP COLUMN WITH_GRANT_OPTION;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
GRANT PROCESS ON *.* TO 'user1'@'%';
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
REVOKE PROCESS ON *.* FROM 'user1'@'%';
DROP TABLE mysql.global_grants;
RENAME TABLE mysql.global_grants_bkp TO mysql.global_grants;

# mysql.role_edges
RENAME TABLE mysql.role_edges TO mysql.role_edges_bkp;
CREATE TABLE mysql.role_edges ENGINE='MyISAM' AS SELECT * FROM mysql.role_edges_bkp;
--error ER_UNSUPPORTED_ENGINE
SET DEFAULT ROLE ALL TO 'user1'@'%';

ALTER TABLE mysql.role_edges ENGINE='InnoDB',
                             DROP COLUMN TO_USER;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
SET DEFAULT ROLE ALL TO 'user1'@'%';
DROP TABLE mysql.role_edges;
RENAME TABLE mysql.role_edges_bkp TO mysql.role_edges;

# mysql.password_history
SET GLOBAL default_password_lifetime = 2;
RENAME TABLE mysql.password_history TO mysql.password_history_bkp;
CREATE TABLE mysql.password_history ENGINE='MyISAM' AS SELECT * FROM mysql.password_history_bkp;
--error ER_UNSUPPORTED_ENGINE
ALTER USER 'user1'@'%' IDENTIFIED BY 'password';

ALTER TABLE mysql.password_history ENGINE='InnoDB',
                                   DROP COLUMN Password_timestamp;
--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
ALTER USER 'user1'@'%' IDENTIFIED BY 'password';
DROP TABLE mysql.password_history;
RENAME TABLE mysql.password_history_bkp TO mysql.password_history;
SET GLOBAL default_password_lifetime = DEFAULT;

#Cleanup
DROP TABLE t1;
DROP FUNCTION f1;
DROP USER 'user1'@'%';


--echo #-----------------------------------------------------------------------
--echo # Test case to verify logical upgrade from 5.7 dump file.
--echo #-----------------------------------------------------------------------
--exec $MYSQL < $MYSQL_TEST_DIR/std_data/mysqldump_57.sql
SELECT table_schema, table_name, engine FROM information_schema.tables
                                        WHERE table_schema='mysql'
                                              AND engine='MyISAM';
--let $restart_parameters = restart:--upgrade=FORCE
--let $wait_counter= 10000
--source include/restart_mysqld.inc
SELECT table_schema, table_name, engine FROM information_schema.tables
                                        WHERE table_schema='mysql'
                                              AND engine='MyISAM';