Debian Codegraph @

mysql-test/suite/funcs_1/r/is_table_privileges.result

raw
1 SHOW TABLES FROM information_schema LIKE 'TABLE_PRIVILEGES';
2 Tables_in_information_schema (TABLE_PRIVILEGES)
3 TABLE_PRIVILEGES
4 #######################################################################
5 # Testcase 3.2.1.1: INFORMATION_SCHEMA tables can be queried via SELECT
6 #######################################################################
7 DROP VIEW IF EXISTS test.v1;
8 DROP PROCEDURE IF EXISTS test.p1;
9 DROP FUNCTION IF EXISTS test.f1;
10 CREATE VIEW test.v1 AS SELECT * FROM information_schema.TABLE_PRIVILEGES;
11 CREATE PROCEDURE test.p1() SELECT * FROM information_schema.TABLE_PRIVILEGES;
12 CREATE FUNCTION test.f1() returns BIGINT
13 BEGIN
14 DECLARE counter BIGINT DEFAULT NULL;
15 SELECT COUNT(*) INTO counter FROM information_schema.TABLE_PRIVILEGES;
16 RETURN counter;
17 END//
18 # Attention: The printing of the next result sets is disabled.
19 SELECT * FROM information_schema.TABLE_PRIVILEGES;
20 SELECT * FROM test.v1;
21 CALL test.p1;
22 SELECT test.f1();
23 DROP VIEW test.v1;
24 DROP PROCEDURE test.p1;
25 DROP FUNCTION test.f1;
26 #########################################################################
27 # Testcase 3.2.11.1: INFORMATION_SCHEMA.TABLE_PRIVILEGES layout
28 #########################################################################
29 DESCRIBE information_schema.TABLE_PRIVILEGES;
30 Field Type Null Key Default Extra
31 GRANTEE varchar(292) NO
32 TABLE_CATALOG varchar(512) NO
33 TABLE_SCHEMA varchar(64) NO
34 TABLE_NAME varchar(64) NO
35 PRIVILEGE_TYPE varchar(64) NO
36 IS_GRANTABLE varchar(3) NO
37 SHOW CREATE TABLE information_schema.TABLE_PRIVILEGES;
38 Table Create Table
39 TABLE_PRIVILEGES CREATE TEMPORARY TABLE `TABLE_PRIVILEGES` (
40 `GRANTEE` varchar(292) NOT NULL DEFAULT '',
41 `TABLE_CATALOG` varchar(512) NOT NULL DEFAULT '',
42 `TABLE_SCHEMA` varchar(64) NOT NULL DEFAULT '',
43 `TABLE_NAME` varchar(64) NOT NULL DEFAULT '',
44 `PRIVILEGE_TYPE` varchar(64) NOT NULL DEFAULT '',
45 `IS_GRANTABLE` varchar(3) NOT NULL DEFAULT ''
46 ) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3
47 SHOW COLUMNS FROM information_schema.TABLE_PRIVILEGES;
48 Field Type Null Key Default Extra
49 GRANTEE varchar(292) NO
50 TABLE_CATALOG varchar(512) NO
51 TABLE_SCHEMA varchar(64) NO
52 TABLE_NAME varchar(64) NO
53 PRIVILEGE_TYPE varchar(64) NO
54 IS_GRANTABLE varchar(3) NO
55 SELECT table_catalog, table_schema, table_name, privilege_type
56 FROM information_schema.table_privileges WHERE table_catalog IS NOT NULL;
57 table_catalog table_schema table_name privilege_type
58 def mysql user SELECT
59 def sys sys_config SELECT
60 ######################################################################
61 # Testcase 3.2.11.2+3.2.11.3+3.2.11.4:
62 # INFORMATION_SCHEMA.TABLE_PRIVILEGES accessible information
63 ######################################################################
64 DROP DATABASE IF EXISTS db_datadict;
65 CREATE DATABASE db_datadict;
66 CREATE TABLE db_datadict.tb1(f1 INT, f2 INT, f3 INT)
67 ENGINE = <engine_type>;
68 DROP USER 'testuser1'@'localhost';
69 CREATE USER 'testuser1'@'localhost';
70 GRANT CREATE, SELECT ON db_datadict.*
71 TO 'testuser1'@'localhost' WITH GRANT OPTION;
72 GRANT SELECT ON db_datadict.tb1 TO 'testuser1'@'localhost';
73 DROP USER 'testuser2'@'localhost';
74 CREATE USER 'testuser2'@'localhost';
75 GRANT ALL ON db_datadict.tb1 TO 'testuser2'@'localhost' WITH GRANT OPTION;
76 DROP USER 'testuser3'@'localhost';
77 CREATE USER 'testuser3'@'localhost';
78 # Establish connection testuser1 (user=testuser1)
79 CREATE TABLE tb3 (f1 TEXT)
80 ENGINE = <other_engine_type>;
81 GRANT SELECT ON db_datadict.tb3 TO 'testuser3'@'localhost';
82 SELECT * FROM information_schema.table_privileges
83 WHERE table_name LIKE 'tb%'
84 ORDER BY grantee,table_schema,table_name,privilege_type;
85 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
86 'testuser1'@'localhost' def db_datadict tb1 SELECT NO
87 SHOW GRANTS FOR 'testuser1'@'localhost';
88 Grants for testuser1@localhost
89 GRANT USAGE ON *.* TO `testuser1`@`localhost`
90 GRANT SELECT, CREATE ON `db_datadict`.* TO `testuser1`@`localhost` WITH GRANT OPTION
91 GRANT SELECT ON `db_datadict`.`tb1` TO `testuser1`@`localhost`
92 # Establish connection testuser2 (user=testuser3)
93 SELECT * FROM information_schema.table_privileges
94 WHERE table_name LIKE 'tb%'
95 ORDER BY grantee,table_schema,table_name,privilege_type;
96 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
97 'testuser2'@'localhost' def db_datadict tb1 ALTER YES
98 'testuser2'@'localhost' def db_datadict tb1 CREATE YES
99 'testuser2'@'localhost' def db_datadict tb1 CREATE VIEW YES
100 'testuser2'@'localhost' def db_datadict tb1 DELETE YES
101 'testuser2'@'localhost' def db_datadict tb1 DROP YES
102 'testuser2'@'localhost' def db_datadict tb1 INDEX YES
103 'testuser2'@'localhost' def db_datadict tb1 INSERT YES
104 'testuser2'@'localhost' def db_datadict tb1 REFERENCES YES
105 'testuser2'@'localhost' def db_datadict tb1 SELECT YES
106 'testuser2'@'localhost' def db_datadict tb1 SHOW VIEW YES
107 'testuser2'@'localhost' def db_datadict tb1 TRIGGER YES
108 'testuser2'@'localhost' def db_datadict tb1 UPDATE YES
109 SHOW GRANTS FOR 'testuser2'@'localhost';
110 Grants for testuser2@localhost
111 GRANT USAGE ON *.* TO `testuser2`@`localhost`
112 GRANT ALL PRIVILEGES ON `db_datadict`.`tb1` TO `testuser2`@`localhost` WITH GRANT OPTION
113 # Establish connection testuser3 (user=testuser3)
114 SELECT * FROM information_schema.table_privileges
115 WHERE table_name LIKE 'tb%'
116 ORDER BY grantee,table_schema,table_name,privilege_type;
117 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
118 'testuser3'@'localhost' def db_datadict tb3 SELECT NO
119 SHOW GRANTS FOR 'testuser3'@'localhost';
120 Grants for testuser3@localhost
121 GRANT USAGE ON *.* TO `testuser3`@`localhost`
122 GRANT SELECT ON `db_datadict`.`tb3` TO `testuser3`@`localhost`
123 # Switch to connection default and close the other connections
124 SELECT * FROM information_schema.table_privileges
125 WHERE table_name LIKE 'tb%'
126 ORDER BY grantee,table_schema,table_name,privilege_type;
127 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
128 'testuser1'@'localhost' def db_datadict tb1 SELECT NO
129 'testuser2'@'localhost' def db_datadict tb1 ALTER YES
130 'testuser2'@'localhost' def db_datadict tb1 CREATE YES
131 'testuser2'@'localhost' def db_datadict tb1 CREATE VIEW YES
132 'testuser2'@'localhost' def db_datadict tb1 DELETE YES
133 'testuser2'@'localhost' def db_datadict tb1 DROP YES
134 'testuser2'@'localhost' def db_datadict tb1 INDEX YES
135 'testuser2'@'localhost' def db_datadict tb1 INSERT YES
136 'testuser2'@'localhost' def db_datadict tb1 REFERENCES YES
137 'testuser2'@'localhost' def db_datadict tb1 SELECT YES
138 'testuser2'@'localhost' def db_datadict tb1 SHOW VIEW YES
139 'testuser2'@'localhost' def db_datadict tb1 TRIGGER YES
140 'testuser2'@'localhost' def db_datadict tb1 UPDATE YES
141 'testuser3'@'localhost' def db_datadict tb3 SELECT NO
142 SHOW GRANTS FOR 'testuser1'@'localhost';
143 Grants for testuser1@localhost
144 GRANT USAGE ON *.* TO `testuser1`@`localhost`
145 GRANT SELECT, CREATE ON `db_datadict`.* TO `testuser1`@`localhost` WITH GRANT OPTION
146 GRANT SELECT ON `db_datadict`.`tb1` TO `testuser1`@`localhost`
147 SHOW GRANTS FOR 'testuser2'@'localhost';
148 Grants for testuser2@localhost
149 GRANT USAGE ON *.* TO `testuser2`@`localhost`
150 GRANT ALL PRIVILEGES ON `db_datadict`.`tb1` TO `testuser2`@`localhost` WITH GRANT OPTION
151 SHOW GRANTS FOR 'testuser3'@'localhost';
152 Grants for testuser3@localhost
153 GRANT USAGE ON *.* TO `testuser3`@`localhost`
154 GRANT SELECT ON `db_datadict`.`tb3` TO `testuser3`@`localhost`
155 DROP USER 'testuser1'@'localhost';
156 DROP USER 'testuser2'@'localhost';
157 DROP USER 'testuser3'@'localhost';
158 DROP DATABASE db_datadict;
159 ################################################################################
160 # 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.TABLE_PRIVILEGES modifications
161 ################################################################################
162 DROP TABLE IF EXISTS test.t1_table;
163 DROP VIEW IF EXISTS test.t1_view;
164 DROP DATABASE IF EXISTS db_datadict;
165 CREATE DATABASE db_datadict;
166 CREATE TABLE test.t1_table (f1 BIGINT)
167 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci
168 COMMENT = 'Initial Comment' ENGINE = <engine_type>;
169 CREATE VIEW test.t1_view AS SELECT 1;
170 DROP USER 'testuser1'@'localhost';
171 CREATE USER 'testuser1'@'localhost';
172 DROP USER 'the_user'@'localhost';
173 SELECT table_name FROM information_schema.table_privileges
174 WHERE table_name LIKE 't1_%';
175 table_name
176 GRANT ALL ON test.t1_table TO 'testuser1'@'localhost';
177 GRANT ALL ON test.t1_view TO 'testuser1'@'localhost';
178 SELECT * FROM information_schema.table_privileges
179 WHERE table_name LIKE 't1_%'
180 ORDER BY grantee, table_schema, table_name, privilege_type;
181 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
182 'testuser1'@'localhost' def test t1_table ALTER NO
183 'testuser1'@'localhost' def test t1_table CREATE NO
184 'testuser1'@'localhost' def test t1_table CREATE VIEW NO
185 'testuser1'@'localhost' def test t1_table DELETE NO
186 'testuser1'@'localhost' def test t1_table DROP NO
187 'testuser1'@'localhost' def test t1_table INDEX NO
188 'testuser1'@'localhost' def test t1_table INSERT NO
189 'testuser1'@'localhost' def test t1_table REFERENCES NO
190 'testuser1'@'localhost' def test t1_table SELECT NO
191 'testuser1'@'localhost' def test t1_table SHOW VIEW NO
192 'testuser1'@'localhost' def test t1_table TRIGGER NO
193 'testuser1'@'localhost' def test t1_table UPDATE NO
194 'testuser1'@'localhost' def test t1_view ALTER NO
195 'testuser1'@'localhost' def test t1_view CREATE NO
196 'testuser1'@'localhost' def test t1_view CREATE VIEW NO
197 'testuser1'@'localhost' def test t1_view DELETE NO
198 'testuser1'@'localhost' def test t1_view DROP NO
199 'testuser1'@'localhost' def test t1_view INDEX NO
200 'testuser1'@'localhost' def test t1_view INSERT NO
201 'testuser1'@'localhost' def test t1_view REFERENCES NO
202 'testuser1'@'localhost' def test t1_view SELECT NO
203 'testuser1'@'localhost' def test t1_view SHOW VIEW NO
204 'testuser1'@'localhost' def test t1_view TRIGGER NO
205 'testuser1'@'localhost' def test t1_view UPDATE NO
206 SELECT DISTINCT grantee, table_name FROM information_schema.table_privileges
207 WHERE table_name LIKE 't1_%'
208 ORDER BY grantee, table_name;
209 grantee table_name
210 'testuser1'@'localhost' t1_table
211 'testuser1'@'localhost' t1_view
212 RENAME USER 'testuser1'@'localhost' TO 'the_user'@'localhost';
213 FLUSH PRIVILEGES;
214 SELECT DISTINCT grantee, table_name FROM information_schema.table_privileges
215 WHERE table_name LIKE 't1_%'
216 ORDER BY grantee, table_name;
217 grantee table_name
218 'the_user'@'localhost' t1_table
219 'the_user'@'localhost' t1_view
220 SHOW GRANTS FOR 'testuser1'@'localhost';
221 ERROR 42000: There is no such grant defined for user 'testuser1' on host 'localhost'
222 SHOW GRANTS FOR 'the_user'@'localhost';
223 Grants for the_user@localhost
224 GRANT ALL PRIVILEGES ON `test`.`t1_table` TO `the_user`@`localhost`
225 GRANT ALL PRIVILEGES ON `test`.`t1_view` TO `the_user`@`localhost`
226 GRANT USAGE ON *.* TO `the_user`@`localhost`
227 SELECT DISTINCT table_schema,table_name FROM information_schema.table_privileges
228 WHERE table_name LIKE 't1_%'
229 ORDER BY table_schema,table_name;
230 table_schema table_name
231 test t1_table
232 test t1_view
233 RENAME TABLE test.t1_table TO db_datadict.t1_table;
234 RENAME TABLE test.t1_view TO db_datadict.t1_view;
235 ERROR HY000: Changing schema from 'test' to 'db_datadict' is not allowed.
236 SELECT DISTINCT table_schema,table_name FROM information_schema.table_privileges
237 WHERE table_name LIKE 't1_%'
238 ORDER BY table_schema,table_name;
239 table_schema table_name
240 test t1_table
241 test t1_view
242 SHOW GRANTS FOR 'the_user'@'localhost';
243 Grants for the_user@localhost
244 GRANT ALL PRIVILEGES ON `test`.`t1_table` TO `the_user`@`localhost`
245 GRANT ALL PRIVILEGES ON `test`.`t1_view` TO `the_user`@`localhost`
246 GRANT USAGE ON *.* TO `the_user`@`localhost`
247 REVOKE ALL PRIVILEGES ON test.t1_table FROM 'the_user'@'localhost';
248 REVOKE ALL PRIVILEGES ON test.t1_view FROM 'the_user'@'localhost';
249 DROP VIEW test.t1_view;
250 CREATE VIEW db_datadict.t1_view AS SELECT 1;
251 GRANT ALL ON db_datadict.t1_table TO 'the_user'@'localhost';
252 GRANT ALL ON db_datadict.t1_view TO 'the_user'@'localhost';
253 SELECT DISTINCT table_name FROM information_schema.table_privileges
254 WHERE table_name LIKE 't1_%'
255 ORDER BY table_name;
256 table_name
257 t1_table
258 t1_view
259 RENAME TABLE db_datadict.t1_table TO db_datadict.t1_tablex;
260 RENAME TABLE db_datadict.t1_view TO db_datadict.t1_viewx;
261 SELECT DISTINCT table_name FROM information_schema.table_privileges
262 WHERE table_name LIKE 't1_%'
263 ORDER BY table_name;
264 table_name
265 t1_table
266 t1_view
267 RENAME TABLE db_datadict.t1_tablex TO db_datadict.t1_table;
268 RENAME TABLE db_datadict.t1_viewx TO db_datadict.t1_view;
269 SELECT DISTINCT table_name FROM information_schema.table_privileges
270 WHERE table_name LIKE 't1_%'
271 ORDER BY table_name;
272 table_name
273 t1_table
274 t1_view
275 DROP TABLE db_datadict.t1_table;
276 DROP VIEW db_datadict.t1_view;
277 SELECT DISTINCT table_name FROM information_schema.table_privileges
278 WHERE table_name LIKE 't1_%'
279 ORDER BY table_name;
280 table_name
281 t1_table
282 t1_view
283 CREATE TABLE db_datadict.t1_table
284 ENGINE = <engine_type> AS
285 SELECT 1;
286 CREATE VIEW db_datadict.t1_view AS SELECT 1;
287 GRANT ALL ON db_datadict.t1_table TO 'the_user'@'localhost';
288 GRANT ALL ON db_datadict.t1_view TO 'the_user'@'localhost';
289 SELECT DISTINCT table_name FROM information_schema.table_privileges
290 WHERE table_name LIKE 't1_%'
291 ORDER BY table_name;
292 table_name
293 t1_table
294 t1_view
295 DROP DATABASE db_datadict;
296 SELECT DISTINCT table_name FROM information_schema.table_privileges
297 WHERE table_name LIKE 't1_%'
298 ORDER BY table_name;
299 table_name
300 t1_table
301 t1_view
302 DROP USER 'the_user'@'localhost';
303 ########################################################################
304 # Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and
305 # DDL on INFORMATION_SCHEMA table are not supported
306 ########################################################################
307 DROP DATABASE IF EXISTS db_datadict;
308 CREATE DATABASE db_datadict;
309 CREATE TABLE db_datadict.t1 (f1 BIGINT, f2 BIGINT)
310 ENGINE = <engine_type>;
311 DROP USER 'testuser1'@'localhost';
312 CREATE USER 'testuser1'@'localhost';
313 GRANT SELECT (f1) ON db_datadict.t1 TO 'testuser1'@'localhost';
314 INSERT INTO information_schema.table_privileges
315 SELECT * FROM information_schema.table_privileges;
316 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
317 UPDATE information_schema.table_privileges SET table_schema = 'test'
318 WHERE table_name = 't1';
319 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
320 DELETE FROM information_schema.table_privileges WHERE table_name = 't1';
321 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
322 TRUNCATE information_schema.table_privileges;
323 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
324 CREATE INDEX my_idx_on_tables
325 ON information_schema.table_privileges(table_schema);
326 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
327 ALTER TABLE information_schema.table_privileges ADD f1 INT;
328 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
329 DROP TABLE information_schema.table_privileges;
330 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
331 ALTER TABLE information_schema.table_privileges
332 RENAME db_datadict.table_privileges;
333 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
334 ALTER TABLE information_schema.table_privileges
335 RENAME information_schema.xtable_privileges;
336 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
337 DROP DATABASE db_datadict;
338 DROP USER 'testuser1'@'localhost';