Skip to content

Commit aeb122d

Browse files
committed
WL#13369: Read only schema
Implement support for setting a single schema with all of its contents to be 'read only' using the SQL statement: ALTER SCHEMA <schema name> READ ONLY [=] {0,1,DEFAULT} Setting a schema to read only means that DDL modifying the schema or any schema qualified entities will fail. It also means that write operations on user data stored in one of the tables in the schema will fail. The read only option is ignored by bootstrap threads, upgrade code, and slave replication threads. In addition to the above functionality, some unrelated issues found during testing have been fixed: * While updating the validity of referencing views, we acquire referencing views and their schema based on object ids, and use their names to acquire MDL, both for the view and for the schema. However, we did this using the lettercase stored in the DD, whereas this should be lowercased when lower_case_table_names == 2. * If an error was raised when the event scheduler was trying to schedule a new event, the scheduler would stop without logging an error message stating what the error was. Change-Id: I7722bfecf6c97e3253ce795851e5ce1d5aa61f15
1 parent 7995809 commit aeb122d

File tree

64 files changed

+4973
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+4973
-85
lines changed

mysql-test/include/schema_read_only.inc

+1,001
Large diffs are not rendered by default.

mysql-test/r/dd_is_compatibility_ci.result

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ ROLE_ROUTINE_GRANTS
182182
ROLE_TABLE_GRANTS
183183
ROUTINES
184184
SCHEMATA
185+
SCHEMATA_EXTENSIONS
185186
SCHEMA_PRIVILEGES
186187
STATISTICS
187188
ST_GEOMETRY_COLUMNS

mysql-test/r/dd_is_compatibility_cs.result

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ ROLE_ROUTINE_GRANTS
182182
ROLE_TABLE_GRANTS
183183
ROUTINES
184184
SCHEMATA
185+
SCHEMATA_EXTENSIONS
185186
SCHEMA_PRIVILEGES
186187
STATISTICS
187188
ST_GEOMETRY_COLUMNS

mysql-test/r/dd_is_debug.result

+23
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,26 @@ ERROR 42S02: Table 'test.t2' doesn't exist
9090
DROP TABLE t1;
9191
DROP PREPARE stmt;
9292
SET DEBUG_SYNC=RESET;
93+
#
94+
# WL#13369: Read only schema
95+
#
96+
# Test parsing of corrupted property string.
97+
#
98+
CREATE SCHEMA s;
99+
SELECT SCHEMA_NAME, OPTIONS FROM INFORMATION_SCHEMA.SCHEMATA_EXTENSIONS
100+
WHERE SCHEMA_NAME = 's';
101+
SCHEMA_NAME OPTIONS
102+
s
103+
SET debug = '+d,skip_dd_table_access_check';
104+
UPDATE mysql.schemata SET options = 'abc' WHERE name = 's';
105+
SELECT options FROM mysql.schemata WHERE name = 's';
106+
options
107+
abc
108+
SET debug = '+d,continue_on_property_string_parse_failure';
109+
SELECT SCHEMA_NAME, OPTIONS FROM INFORMATION_SCHEMA.SCHEMATA_EXTENSIONS
110+
WHERE SCHEMA_NAME = 's';
111+
SCHEMA_NAME OPTIONS
112+
s
113+
SET debug = DEFAULT;
114+
DROP SCHEMA s;
115+
Pattern "Could not parse key-value pairs in property string 'abc'" found

mysql-test/r/information_schema_ci.result

+5-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ ROLE_ROUTINE_GRANTS
8989
ROLE_TABLE_GRANTS
9090
ROUTINES
9191
SCHEMATA
92+
SCHEMATA_EXTENSIONS
9293
SCHEMA_PRIVILEGES
9394
STATISTICS
9495
ST_GEOMETRY_COLUMNS
@@ -884,7 +885,7 @@ table_schema IN ('mysql', 'information_schema', 'test', 'mysqltest')
884885
AND table_name not like 'ndb%' AND table_name COLLATE utf8_general_ci not like 'innodb_%'
885886
GROUP BY TABLE_SCHEMA;
886887
TABLE_SCHEMA count(*)
887-
information_schema 47
888+
information_schema 48
888889
mysql 31
889890
create table t1 (i int, j int);
890891
create trigger trg1 before insert on t1 for each row
@@ -1362,6 +1363,7 @@ ROLE_ROUTINE_GRANTS information_schema.ROLE_ROUTINE_GRANTS 1
13621363
ROLE_TABLE_GRANTS information_schema.ROLE_TABLE_GRANTS 1
13631364
ROUTINES information_schema.ROUTINES 1
13641365
SCHEMATA information_schema.SCHEMATA 1
1366+
SCHEMATA_EXTENSIONS information_schema.SCHEMATA_EXTENSIONS 1
13651367
SCHEMA_PRIVILEGES information_schema.SCHEMA_PRIVILEGES 1
13661368
STATISTICS information_schema.STATISTICS 1
13671369
ST_GEOMETRY_COLUMNS information_schema.ST_GEOMETRY_COLUMNS 1
@@ -2490,6 +2492,7 @@ ROLE_ROUTINE_GRANTS SPECIFIC_SCHEMA
24902492
ROLE_TABLE_GRANTS TABLE_SCHEMA
24912493
ROUTINES ROUTINE_SCHEMA
24922494
SCHEMATA SCHEMA_NAME
2495+
SCHEMATA_EXTENSIONS SCHEMA_NAME
24932496
SCHEMA_PRIVILEGES TABLE_SCHEMA
24942497
STATISTICS TABLE_SCHEMA
24952498
ST_GEOMETRY_COLUMNS TABLE_SCHEMA
@@ -2556,6 +2559,7 @@ ROLE_ROUTINE_GRANTS SPECIFIC_SCHEMA
25562559
ROLE_TABLE_GRANTS TABLE_SCHEMA
25572560
ROUTINES ROUTINE_SCHEMA
25582561
SCHEMATA SCHEMA_NAME
2562+
SCHEMATA_EXTENSIONS SCHEMA_NAME
25592563
SCHEMA_PRIVILEGES TABLE_SCHEMA
25602564
STATISTICS TABLE_SCHEMA
25612565
ST_GEOMETRY_COLUMNS TABLE_SCHEMA

mysql-test/r/information_schema_cs.result

+5-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ ROLE_ROUTINE_GRANTS
8989
ROLE_TABLE_GRANTS
9090
ROUTINES
9191
SCHEMATA
92+
SCHEMATA_EXTENSIONS
9293
SCHEMA_PRIVILEGES
9394
STATISTICS
9495
ST_GEOMETRY_COLUMNS
@@ -884,7 +885,7 @@ table_schema IN ('mysql', 'information_schema', 'test', 'mysqltest')
884885
AND table_name not like 'ndb%' AND table_name COLLATE utf8_general_ci not like 'innodb_%'
885886
GROUP BY TABLE_SCHEMA;
886887
TABLE_SCHEMA count(*)
887-
information_schema 47
888+
information_schema 48
888889
mysql 31
889890
create table t1 (i int, j int);
890891
create trigger trg1 before insert on t1 for each row
@@ -1362,6 +1363,7 @@ ROLE_ROUTINE_GRANTS information_schema.ROLE_ROUTINE_GRANTS 1
13621363
ROLE_TABLE_GRANTS information_schema.ROLE_TABLE_GRANTS 1
13631364
ROUTINES information_schema.ROUTINES 1
13641365
SCHEMATA information_schema.SCHEMATA 1
1366+
SCHEMATA_EXTENSIONS information_schema.SCHEMATA_EXTENSIONS 1
13651367
SCHEMA_PRIVILEGES information_schema.SCHEMA_PRIVILEGES 1
13661368
STATISTICS information_schema.STATISTICS 1
13671369
ST_GEOMETRY_COLUMNS information_schema.ST_GEOMETRY_COLUMNS 1
@@ -2490,6 +2492,7 @@ ROLE_ROUTINE_GRANTS SPECIFIC_SCHEMA
24902492
ROLE_TABLE_GRANTS TABLE_SCHEMA
24912493
ROUTINES ROUTINE_SCHEMA
24922494
SCHEMATA SCHEMA_NAME
2495+
SCHEMATA_EXTENSIONS SCHEMA_NAME
24932496
SCHEMA_PRIVILEGES TABLE_SCHEMA
24942497
STATISTICS TABLE_SCHEMA
24952498
ST_GEOMETRY_COLUMNS TABLE_SCHEMA
@@ -2556,6 +2559,7 @@ ROLE_ROUTINE_GRANTS SPECIFIC_SCHEMA
25562559
ROLE_TABLE_GRANTS TABLE_SCHEMA
25572560
ROUTINES ROUTINE_SCHEMA
25582561
SCHEMATA SCHEMA_NAME
2562+
SCHEMATA_EXTENSIONS SCHEMA_NAME
25592563
SCHEMA_PRIVILEGES TABLE_SCHEMA
25602564
STATISTICS TABLE_SCHEMA
25612565
ST_GEOMETRY_COLUMNS TABLE_SCHEMA

mysql-test/r/mysqlshow_ci.result

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Database: information_schema
140140
| ROUTINES |
141141
| SCHEMA_PRIVILEGES |
142142
| SCHEMATA |
143+
| SCHEMATA_EXTENSIONS |
143144
| ST_GEOMETRY_COLUMNS |
144145
| ST_SPATIAL_REFERENCE_SYSTEMS |
145146
| ST_UNITS_OF_MEASURE |
@@ -223,6 +224,7 @@ Database: INFORMATION_SCHEMA
223224
| ROUTINES |
224225
| SCHEMA_PRIVILEGES |
225226
| SCHEMATA |
227+
| SCHEMATA_EXTENSIONS |
226228
| ST_GEOMETRY_COLUMNS |
227229
| ST_SPATIAL_REFERENCE_SYSTEMS |
228230
| ST_UNITS_OF_MEASURE |

mysql-test/r/mysqlshow_cs.result

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ Database: information_schema
139139
| ROLE_TABLE_GRANTS |
140140
| ROUTINES |
141141
| SCHEMATA |
142+
| SCHEMATA_EXTENSIONS |
142143
| SCHEMA_PRIVILEGES |
143144
| STATISTICS |
144145
| ST_GEOMETRY_COLUMNS |
@@ -222,6 +223,7 @@ Database: INFORMATION_SCHEMA
222223
| ROLE_TABLE_GRANTS |
223224
| ROUTINES |
224225
| SCHEMATA |
226+
| SCHEMATA_EXTENSIONS |
225227
| SCHEMA_PRIVILEGES |
226228
| STATISTICS |
227229
| ST_GEOMETRY_COLUMNS |

0 commit comments

Comments
 (0)