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 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
|
#
# WL#6391: Hide DD tables.
#
# Prohibit access to the DD tables from user submitted
# SQL statements, but allow DD initialization to execute
# such statements.
#
# DD schema DDL
DROP SCHEMA mysql;
ERROR HY000: Access to system schema 'mysql' is rejected.
CREATE SCHEMA mysql;
ERROR HY000: Access to system schema 'mysql' is rejected.
ALTER SCHEMA mysql DEFAULT COLLATE utf8_general_ci;
ERROR HY000: Access to system schema 'mysql' is rejected.
# DD tablespace DDL
DROP TABLESPACE mysql;
ERROR 42000: InnoDB: `mysql` is a reserved tablespace name.
CREATE TABLESPACE mysql ADD DATAFILE 'new_file.ibd';
ERROR 42000: InnoDB: `mysql` is a reserved tablespace name.
ALTER TABLESPACE mysql ADD DATAFILE 'new_file.ibd';
ERROR HY000: Failed to alter: TABLESPACE mysql
# Create a non- white listed table in the DD tablespace
CREATE TABLE table_not_white_listed (pk INTEGER PRIMARY KEY) TABLESPACE mysql;
ERROR HY000: The table 'table_not_white_listed' may not be created in the reserved tablespace 'mysql'.
USE mysql;
CREATE TABLE t (pk BIGINT UNSIGNED PRIMARY KEY);
#
# DD table access in LOAD statements.
#
LOAD DATA INFILE 'no_such_file' INTO TABLE mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access in HANDLER statements.
#
HANDLER mysql.dd_properties OPEN;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table visibility in I_S.
#
# A SELECT statement will not fail, since the table names are submitted as strings in WHERE clauses.
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'mysql.dd_properties' AND TABLE_SCHEMA = 'mysql';
COUNT(*)
0
# A SHOW statement will fail because the table name is interpreted as a table name, not as a string.
SHOW CREATE TABLE mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access in DDL.
#
DROP TABLE mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
CREATE TABLE mysql.dd_properties (i INTEGER);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
CREATE TABLE new_tab LIKE mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
CREATE TABLE new_tab SELECT * FROM mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
ALTER TABLE mysql.dd_properties ADD COLUMN (new_col INTEGER);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
TRUNCATE TABLE mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
RENAME TABLE mysql.dd_properties TO new_tab;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
RENAME TABLE t TO mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access in DML.
#
SELECT * from mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
SELECT * from t WHERE t.pk = (SELECT COUNT(*) FROM mysql.dd_properties);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
DELETE FROM mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
UPDATE mysql.dd_properties SET id= 0 WHERE ID= 1;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
INSERT INTO mysql.dd_properties VALUES (1);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from views.
#
CREATE VIEW new_view AS SELECT * FROM mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from stored programs.
#
CREATE PROCEDURE dd_access() SELECT * FROM mysql.dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
CREATE FUNCTION dd_access() RETURNS INTEGER RETURN (SELECT COUNT(*) FROM mysql.dd_properties);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from prepared statements (the '?' placeholders cannot be used for meta data).
#
PREPARE ps FROM 'DROP TABLE mysql.dd_properties';;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
PREPARE ps FROM 'SELECT * FROM mysql.dd_properties';;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from triggers
#
CREATE TRIGGER trg BEFORE INSERT ON mysql.dd_properties FOR EACH ROW SET @count = @count + 1;;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from foreign keys
#
ALTER TABLE t ADD CONSTRAINT FOREIGN KEY (pk) REFERENCES mysql.dd_properties (id);;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access in LOAD statements.
#
LOAD DATA INFILE 'no_such_file' INTO TABLE dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access in HANDLER statements.
#
HANDLER dd_properties OPEN;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table visibility in I_S.
#
# A SELECT statement will not fail, since the table names are submitted as strings in WHERE clauses.
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'dd_properties' AND TABLE_SCHEMA = 'mysql';
COUNT(*)
0
# A SHOW statement will fail because the table name is interpreted as a table name, not as a string.
SHOW CREATE TABLE dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access in DDL.
#
DROP TABLE dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
CREATE TABLE dd_properties (i INTEGER);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
CREATE TABLE new_tab LIKE dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
CREATE TABLE new_tab SELECT * FROM dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
ALTER TABLE dd_properties ADD COLUMN (new_col INTEGER);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
TRUNCATE TABLE dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
RENAME TABLE dd_properties TO new_tab;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
RENAME TABLE t TO dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access in DML.
#
SELECT * from dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
SELECT * from t WHERE t.pk = (SELECT COUNT(*) FROM dd_properties);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
DELETE FROM dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
UPDATE dd_properties SET id= 0 WHERE ID= 1;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
INSERT INTO dd_properties VALUES (1);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from views.
#
CREATE VIEW new_view AS SELECT * FROM dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from stored programs.
#
CREATE PROCEDURE dd_access() SELECT * FROM dd_properties;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
CREATE FUNCTION dd_access() RETURNS INTEGER RETURN (SELECT COUNT(*) FROM dd_properties);
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from prepared statements (the '?' placeholders cannot be used for meta data).
#
PREPARE ps FROM 'DROP TABLE dd_properties';;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
PREPARE ps FROM 'SELECT * FROM dd_properties';;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from triggers
#
CREATE TRIGGER trg BEFORE INSERT ON dd_properties FOR EACH ROW SET @count = @count + 1;;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access from foreign keys
#
ALTER TABLE t ADD CONSTRAINT FOREIGN KEY (pk) REFERENCES dd_properties (id);;
ERROR HY000: Access to data dictionary table 'mysql.dd_properties' is rejected.
#
# DD table access in LOAD statements.
#
LOAD DATA INFILE 'no_such_file' INTO TABLE mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access in HANDLER statements.
#
HANDLER mysql.indexes OPEN;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table visibility in I_S.
#
# A SELECT statement will not fail, since the table names are submitted as strings in WHERE clauses.
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'mysql.indexes' AND TABLE_SCHEMA = 'mysql';
COUNT(*)
0
# A SHOW statement will fail because the table name is interpreted as a table name, not as a string.
SHOW CREATE TABLE mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access in DDL.
#
DROP TABLE mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
CREATE TABLE mysql.indexes (i INTEGER);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
CREATE TABLE new_tab LIKE mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
CREATE TABLE new_tab SELECT * FROM mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
ALTER TABLE mysql.indexes ADD COLUMN (new_col INTEGER);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
TRUNCATE TABLE mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
RENAME TABLE mysql.indexes TO new_tab;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
RENAME TABLE t TO mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access in DML.
#
SELECT * from mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
SELECT * from t WHERE t.pk = (SELECT COUNT(*) FROM mysql.indexes);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
DELETE FROM mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
UPDATE mysql.indexes SET id= 0 WHERE ID= 1;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
INSERT INTO mysql.indexes VALUES (1);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from views.
#
CREATE VIEW new_view AS SELECT * FROM mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from stored programs.
#
CREATE PROCEDURE dd_access() SELECT * FROM mysql.indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
CREATE FUNCTION dd_access() RETURNS INTEGER RETURN (SELECT COUNT(*) FROM mysql.indexes);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from prepared statements (the '?' placeholders cannot be used for meta data).
#
PREPARE ps FROM 'DROP TABLE mysql.indexes';;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
PREPARE ps FROM 'SELECT * FROM mysql.indexes';;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from triggers
#
CREATE TRIGGER trg BEFORE INSERT ON mysql.indexes FOR EACH ROW SET @count = @count + 1;;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from foreign keys
#
ALTER TABLE t ADD CONSTRAINT FOREIGN KEY (pk) REFERENCES mysql.indexes (id);;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access in LOAD statements.
#
LOAD DATA INFILE 'no_such_file' INTO TABLE indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access in HANDLER statements.
#
HANDLER indexes OPEN;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table visibility in I_S.
#
# A SELECT statement will not fail, since the table names are submitted as strings in WHERE clauses.
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'indexes' AND TABLE_SCHEMA = 'mysql';
COUNT(*)
0
# A SHOW statement will fail because the table name is interpreted as a table name, not as a string.
SHOW CREATE TABLE indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access in DDL.
#
DROP TABLE indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
CREATE TABLE indexes (i INTEGER);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
CREATE TABLE new_tab LIKE indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
CREATE TABLE new_tab SELECT * FROM indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
ALTER TABLE indexes ADD COLUMN (new_col INTEGER);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
TRUNCATE TABLE indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
RENAME TABLE indexes TO new_tab;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
RENAME TABLE t TO indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access in DML.
#
SELECT * from indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
SELECT * from t WHERE t.pk = (SELECT COUNT(*) FROM indexes);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
DELETE FROM indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
UPDATE indexes SET id= 0 WHERE ID= 1;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
INSERT INTO indexes VALUES (1);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from views.
#
CREATE VIEW new_view AS SELECT * FROM indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from stored programs.
#
CREATE PROCEDURE dd_access() SELECT * FROM indexes;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
CREATE FUNCTION dd_access() RETURNS INTEGER RETURN (SELECT COUNT(*) FROM indexes);
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from prepared statements (the '?' placeholders cannot be used for meta data).
#
PREPARE ps FROM 'DROP TABLE indexes';;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
PREPARE ps FROM 'SELECT * FROM indexes';;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from triggers
#
CREATE TRIGGER trg BEFORE INSERT ON indexes FOR EACH ROW SET @count = @count + 1;;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
#
# DD table access from foreign keys
#
ALTER TABLE t ADD CONSTRAINT FOREIGN KEY (pk) REFERENCES indexes (id);;
ERROR HY000: Access to data dictionary table 'mysql.indexes' is rejected.
# Turn off innodb_stats_auto_recalc to avoid conflicting updates.
SET @@global.innodb_stats_auto_recalc= OFF;
# Check that we may query and update mysql.innodb_index_stats.
SELECT @old_description:= stat_description FROM mysql.innodb_index_stats
WHERE database_name= 'mysql' AND table_name= 't' AND
index_name= 'PRIMARY' AND stat_name= 'size';
@old_description:= stat_description
Number of pages in the index
Warnings:
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
UPDATE mysql.innodb_index_stats SET stat_description= 'Updated'
WHERE database_name= 'mysql' AND table_name= 't' AND
index_name= 'PRIMARY' AND stat_name= 'size';
SELECT stat_description FROM mysql.innodb_index_stats
WHERE database_name= 'mysql' AND table_name= 't' AND
index_name= 'PRIMARY' AND stat_name= 'size';
stat_description
Updated
UPDATE mysql.innodb_index_stats SET stat_description= @old_description
WHERE database_name= 'mysql' AND table_name= 't' AND
index_name= 'PRIMARY' AND stat_name= 'size';
# Check that we may not DROP or CREATE mysql.innodb_index_stats.
DROP TABLE mysql.innodb_index_stats;
ERROR HY000: Access to system table 'mysql.innodb_index_stats' is rejected.
CREATE TABLE mysql.innodb_index_stats(i INTEGER);
ERROR HY000: Access to system table 'mysql.innodb_index_stats' is rejected.
# Check that we may CREATE FROM mysql.innodb_index_stats.
CREATE TABLE t1 SELECT * FROM mysql.innodb_index_stats;
DROP TABLE t1;
# Check that we may not CREATE LIKE mysql.innodb_index_stats
# due to restricted tablespace.
CREATE TABLE t1 LIKE mysql.innodb_index_stats;
ERROR HY000: The table 't1' may not be created in the reserved tablespace 'mysql'.
# Check access from stored programs.
CREATE PROCEDURE ddse_access() CREATE TABLE mysql.innodb_index_stats(i INTEGER);
ERROR HY000: Access to system table 'mysql.innodb_index_stats' is rejected.
CREATE PROCEDURE ddse_access() DROP TABLE mysql.innodb_index_stats(i INTEGER);
ERROR HY000: Access to system table 'mysql.innodb_index_stats' is rejected.
# Check access from prepared statements.
PREPARE ps FROM 'CREATE TABLE mysql.innodb_index_stats(i INTEGER)';;
ERROR HY000: Access to system table 'mysql.innodb_index_stats' is rejected.
PREPARE ps FROM 'DROP TABLE mysql.innodb_index_stats';;
ERROR HY000: Access to system table 'mysql.innodb_index_stats' is rejected.
# But ALTER and CHECK is allowed.
ALTER TABLE mysql.innodb_index_stats COMMENT 'Altered';
SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='innodb_index_stats';
TABLE_NAME TABLE_COMMENT
innodb_index_stats Altered
# Test CHECK TABLE mysql.innodb_index_stats.
CHECK TABLE mysql.innodb_index_stats;
Table Op Msg_type Msg_text
mysql.innodb_index_stats check status OK
# Reset innodb_index_stats
ALTER TABLE mysql.innodb_index_stats COMMENT '';
# Reset innodb_stats_auto_recalc.
SET @@global.innodb_stats_auto_recalc= default;
DROP TABLE t;
|