1
# suite/funcs_1/t/is_schemata.test
3
# Check the layout of information_schema.schemata, permissions and the impact of
4
# CREATE/ALTER/DROP SCHEMA on it.
7
# This test is not intended
8
# - to show information about the all time existing databases
9
# information_schema and mysql
10
# - for checking storage engine properties
13
# 2008-01-23 mleich WL#4203 Reorganize and fix the data dictionary tests of
15
# Create this script based on older scripts and new code.
18
# --source suite/funcs_1/datadict/datadict.pre
20
let $is_table = SCHEMATA;
22
# The table INFORMATION_SCHEMA.SCHEMATA must exist
23
eval SHOW TABLES FROM information_schema LIKE '$is_table';
25
--echo #######################################################################
26
--echo # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
27
--echo #######################################################################
28
# Ensure that every INFORMATION_SCHEMA table can be queried with a SELECT
29
# statement, just as if it were an ordinary user-defined table.
31
--source suite/funcs_1/datadict/is_table_query.inc
34
--echo #########################################################################
35
--echo # Testcase 3.2.9.1: INFORMATION_SCHEMA.SCHEMATA layout;
36
--echo #########################################################################
37
# Ensure that the INFORMATION_SCHEMA.SCHEMATA table has the following columns,
38
# in the following order:
40
# CATALOG_NAME (always shows NULL),
41
# SCHEMA_NAME (shows the name of a database, or schema, on which the current
42
# user or PUBLIC has privileges),
43
# DEFAULT_CHARACTER_SET_NAME (shows the name of that database's default
45
# DEFAULT_COLLATION_NAME (shows the database defaul collation)
46
# SQL_PATH (always shows NULL).
48
--source suite/funcs_1/datadict/datadict_bug_12777.inc
49
eval DESCRIBE information_schema.$is_table;
50
--source suite/funcs_1/datadict/datadict_bug_12777.inc
51
eval SHOW CREATE TABLE information_schema.$is_table;
52
--source suite/funcs_1/datadict/datadict_bug_12777.inc
53
eval SHOW COLUMNS FROM information_schema.$is_table;
55
# Note: Retrieval of information within information_schema.columns about
56
# information_schema.schemata is in is_columns_is.test.
58
# Show that CATALOG_NAME and SQL_PATH are always NULL.
59
SELECT catalog_name, schema_name, sql_path
60
FROM information_schema.schemata
61
WHERE catalog_name IS NOT NULL or sql_path IS NOT NULL;
64
--echo ###############################################################################
65
--echo # Testcases 3.2.9.2+3.2.9.3: INFORMATION_SCHEMA.SCHEMATA accessible information
66
--echo ###############################################################################
67
# 3.2.9.2 Ensure that the table shows the relevant information for every
68
# database on which the current user or PUBLIC have privileges.
69
# 3.2.9.3 Ensure that the table does not show any information on any databases
70
# on which the current user and PUBLIC have no privileges.
72
# Note: Check of content within information_schema.schemata about the databases
73
# information_schema and mysql is in
74
# suite/funcs_1/t/is_schemata_is_mysql.test.
77
DROP DATABASE IF EXISTS db_datadict_1;
78
DROP DATABASE IF EXISTS db_datadict_2;
80
CREATE DATABASE db_datadict_1;
81
CREATE DATABASE db_datadict_2;
83
--error 0,ER_CANNOT_USER
84
DROP USER 'testuser1'@'localhost';
85
CREATE USER 'testuser1'@'localhost';
86
--error 0,ER_CANNOT_USER
87
DROP USER 'testuser2'@'localhost';
88
CREATE USER 'testuser2'@'localhost';
89
--error 0,ER_CANNOT_USER
90
DROP USER 'testuser3'@'localhost';
91
CREATE USER 'testuser3'@'localhost';
93
GRANT SELECT ON db_datadict_1.* to 'testuser1'@'localhost';
94
GRANT SELECT ON db_datadict_1.* to 'testuser2'@'localhost';
95
GRANT SELECT ON db_datadict_2.* to 'testuser2'@'localhost';
97
let $my_select = SELECT * FROM information_schema.schemata
98
WHERE schema_name LIKE 'db_datadict_%' ORDER BY schema_name;
99
let $my_show = SHOW DATABASES LIKE 'db_datadict_%';
105
--echo # Establish connection testuser1 (user=testuser1)
106
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
107
connect (testuser1, localhost, testuser1, , db_datadict_1);
108
# Shows db_datadict_1
113
--echo # Establish connection testuser2 (user=testuser2)
114
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
115
connect (testuser2, localhost, testuser2, , db_datadict_2);
116
# Shows db_datadict_1 and db_datadict_2
121
--echo # Establish connection testuser3 (user=testuser3)
122
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
123
connect (testuser3, localhost, testuser3, , test);
124
# Shows neither db_datadict_1 nor db_datadict_2
130
--echo # Switch to connection default and close connections testuser1,testuser2,testuser3
132
disconnect testuser1;
133
disconnect testuser2;
134
disconnect testuser3;
135
DROP USER 'testuser1'@'localhost';
136
DROP USER 'testuser2'@'localhost';
137
DROP USER 'testuser3'@'localhost';
138
DROP DATABASE db_datadict_1;
139
DROP DATABASE db_datadict_2;
142
--echo #################################################################################
143
--echo # Testcases 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.SCHEMATA modifications
144
--echo #################################################################################
145
# 3.2.1.13: Ensure that the creation of any new database object (e.g. table or
146
# column) automatically inserts all relevant information on that
147
# object into every appropriate INFORMATION_SCHEMA table.
148
# 3.2.1.14: Ensure that the alteration of any existing database object
149
# automatically updates all relevant information on that object in
150
# every appropriate INFORMATION_SCHEMA table.
151
# 3.2.1.15: Ensure that the dropping of any existing database object
152
# automatically deletes all relevant information on that object from
153
# every appropriate INFORMATION_SCHEMA table.
156
DROP DATABASE IF EXISTS db_datadict;
159
SELECT * FROM information_schema.schemata WHERE schema_name = 'db_datadict';
160
CREATE DATABASE db_datadict CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';
161
SELECT * FROM information_schema.schemata WHERE schema_name = 'db_datadict';
163
# Check modify default CHARACTER SET
164
SELECT schema_name, default_character_set_name
165
FROM information_schema.schemata WHERE schema_name = 'db_datadict';
166
ALTER SCHEMA db_datadict CHARACTER SET 'utf8';
167
SELECT schema_name, default_character_set_name
168
FROM information_schema.schemata WHERE schema_name = 'db_datadict';
169
ALTER SCHEMA db_datadict CHARACTER SET 'latin1';
171
# Check modify default COLLATION
172
SELECT schema_name, default_collation_name FROM information_schema.schemata
173
WHERE schema_name = 'db_datadict';
174
ALTER SCHEMA db_datadict COLLATE 'latin1_general_cs';
175
SELECT schema_name, default_collation_name FROM information_schema.schemata
176
WHERE schema_name = 'db_datadict';
178
# Check DROP DATABASE
180
FROM information_schema.schemata WHERE schema_name = 'db_datadict';
181
DROP DATABASE db_datadict;
183
FROM information_schema.schemata WHERE schema_name = 'db_datadict';
186
--echo ########################################################################
187
--echo # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
188
--echo # DDL on INFORMATION_SCHEMA tables are not supported
189
--echo ########################################################################
190
# 3.2.1.3: Ensure that no user may execute an INSERT statement on any
191
# INFORMATION_SCHEMA table.
192
# 3.2.1.4: Ensure that no user may execute an UPDATE statement on any
193
# INFORMATION_SCHEMA table.
194
# 3.2.1.5: Ensure that no user may execute a DELETE statement on any
195
# INFORMATION_SCHEMA table.
196
# 3.2.1.8: Ensure that no user may create an index on an INFORMATION_SCHEMA table.
197
# 3.2.1.9: Ensure that no user may alter the definition of an
198
# INFORMATION_SCHEMA table.
199
# 3.2.1.10: Ensure that no user may drop an INFORMATION_SCHEMA table.
200
# 3.2.1.11: Ensure that no user may move an INFORMATION_SCHEMA table to any
202
# 3.2.1.12: Ensure that no user may directly add to, alter, or delete any data
203
# in an INFORMATION_SCHEMA table.
206
DROP DATABASE IF EXISTS db_datadict;
208
CREATE DATABASE db_datadict CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';
210
--error ER_DBACCESS_DENIED_ERROR
211
INSERT INTO information_schema.schemata
212
(catalog_name, schema_name, default_character_set_name, sql_path)
213
VALUES (NULL, 'db1', 'latin1', NULL);
214
--error ER_DBACCESS_DENIED_ERROR
215
INSERT INTO information_schema.schemata
216
SELECT * FROM information_schema.schemata;
218
--error ER_DBACCESS_DENIED_ERROR
219
UPDATE information_schema.schemata
220
SET default_character_set_name = 'utf8'
221
WHERE schema_name = 'db_datadict';
222
--error ER_DBACCESS_DENIED_ERROR
223
UPDATE information_schema.schemata SET catalog_name = 't_4711';
225
--error ER_DBACCESS_DENIED_ERROR
226
DELETE FROM information_schema.schemata WHERE schema_name = 'db_datadict';
227
--error ER_DBACCESS_DENIED_ERROR
228
TRUNCATE information_schema.schemata;
230
--error ER_DBACCESS_DENIED_ERROR
231
CREATE INDEX i1 ON information_schema.schemata(schema_name);
233
--error ER_DBACCESS_DENIED_ERROR
234
ALTER TABLE information_schema.schemata ADD f1 INT;
236
--error ER_DBACCESS_DENIED_ERROR
237
DROP TABLE information_schema.schemata;
239
--error ER_DBACCESS_DENIED_ERROR
240
ALTER TABLE information_schema.schemata RENAME db_datadict.schemata;
241
--error ER_DBACCESS_DENIED_ERROR
242
ALTER TABLE information_schema.schemata RENAME information_schema.xschemata;
245
DROP DATABASE db_datadict;