| 1 |
SHOW TABLES FROM information_schema LIKE 'VIEWS'; |
| 2 |
Tables_in_information_schema (VIEWS) |
| 3 |
VIEWS |
| 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.VIEWS; |
| 11 |
CREATE PROCEDURE test.p1() SELECT * FROM information_schema.VIEWS; |
| 12 |
CREATE FUNCTION test.f1() returns BIGINT |
| 13 |
BEGIN |
| 14 |
DECLARE counter BIGINT DEFAULT NULL; |
| 15 |
SELECT COUNT(*) INTO counter FROM information_schema.VIEWS; |
| 16 |
RETURN counter; |
| 17 |
END// |
| 18 |
# Attention: The printing of the next result sets is disabled. |
| 19 |
SELECT * FROM information_schema.VIEWS; |
| 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.13.1: INFORMATION_SCHEMA.VIEWS layout |
| 28 |
######################################################################### |
| 29 |
DESCRIBE information_schema.VIEWS; |
| 30 |
Field Type Null Key Default Extra |
| 31 |
TABLE_CATALOG varchar(512) NO NULL |
| 32 |
TABLE_SCHEMA varchar(64) NO NULL |
| 33 |
TABLE_NAME varchar(64) NO NULL |
| 34 |
VIEW_DEFINITION longtext NO NULL |
| 35 |
CHECK_OPTION varchar(8) NO NULL |
| 36 |
IS_UPDATABLE varchar(3) NO NULL |
| 37 |
DEFINER varchar(384) NO NULL |
| 38 |
SECURITY_TYPE varchar(7) NO NULL |
| 39 |
CHARACTER_SET_CLIENT varchar(32) NO NULL |
| 40 |
COLLATION_CONNECTION varchar(64) NO NULL |
| 41 |
ALGORITHM varchar(10) NO NULL |
| 42 |
SHOW CREATE TABLE information_schema.VIEWS; |
| 43 |
Table Create Table |
| 44 |
VIEWS CREATE TEMPORARY TABLE `VIEWS` ( |
| 45 |
`TABLE_CATALOG` varchar(512) NOT NULL, |
| 46 |
`TABLE_SCHEMA` varchar(64) NOT NULL, |
| 47 |
`TABLE_NAME` varchar(64) NOT NULL, |
| 48 |
`VIEW_DEFINITION` longtext NOT NULL, |
| 49 |
`CHECK_OPTION` varchar(8) NOT NULL, |
| 50 |
`IS_UPDATABLE` varchar(3) NOT NULL, |
| 51 |
`DEFINER` varchar(384) NOT NULL, |
| 52 |
`SECURITY_TYPE` varchar(7) NOT NULL, |
| 53 |
`CHARACTER_SET_CLIENT` varchar(32) NOT NULL, |
| 54 |
`COLLATION_CONNECTION` varchar(64) NOT NULL, |
| 55 |
`ALGORITHM` varchar(10) NOT NULL |
| 56 |
) DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci |
| 57 |
SHOW COLUMNS FROM information_schema.VIEWS; |
| 58 |
Field Type Null Key Default Extra |
| 59 |
TABLE_CATALOG varchar(512) NO NULL |
| 60 |
TABLE_SCHEMA varchar(64) NO NULL |
| 61 |
TABLE_NAME varchar(64) NO NULL |
| 62 |
VIEW_DEFINITION longtext NO NULL |
| 63 |
CHECK_OPTION varchar(8) NO NULL |
| 64 |
IS_UPDATABLE varchar(3) NO NULL |
| 65 |
DEFINER varchar(384) NO NULL |
| 66 |
SECURITY_TYPE varchar(7) NO NULL |
| 67 |
CHARACTER_SET_CLIENT varchar(32) NO NULL |
| 68 |
COLLATION_CONNECTION varchar(64) NO NULL |
| 69 |
ALGORITHM varchar(10) NO NULL |
| 70 |
SELECT table_catalog, table_schema, table_name |
| 71 |
FROM information_schema.views WHERE table_catalog <> 'def'; |
| 72 |
table_catalog table_schema table_name |
| 73 |
################################################################################ |
| 74 |
# Testcase 3.2.13.2 + 3.2.13.3: INFORMATION_SCHEMA.VIEWS accessible information |
| 75 |
################################################################################ |
| 76 |
DROP DATABASE IF EXISTS db_datadict; |
| 77 |
CREATE DATABASE db_datadict; |
| 78 |
DROP USER 'testuser1'@'localhost'; |
| 79 |
CREATE USER 'testuser1'@'localhost'; |
| 80 |
DROP USER 'testuser2'@'localhost'; |
| 81 |
CREATE USER 'testuser2'@'localhost'; |
| 82 |
DROP USER 'test_no_views'@'localhost'; |
| 83 |
CREATE USER 'test_no_views'@'localhost'; |
| 84 |
CREATE TABLE db_datadict.t1(f1 INT, f2 INT, f3 INT) |
| 85 |
ENGINE = <engine_type>; |
| 86 |
CREATE VIEW db_datadict.v_granted_to_1 AS SELECT * FROM db_datadict.t1; |
| 87 |
CREATE VIEW db_datadict.v_granted_glob AS SELECT f2, f3 FROM db_datadict.t1; |
| 88 |
GRANT SELECT ON db_datadict.t1 TO 'testuser1'@'localhost'; |
| 89 |
GRANT SELECT ON db_datadict.v_granted_to_1 TO 'testuser1'@'localhost'; |
| 90 |
GRANT SHOW VIEW, CREATE VIEW ON db_datadict.* TO 'testuser2'@'localhost'; |
| 91 |
SELECT * FROM information_schema.views |
| 92 |
WHERE table_schema = 'db_datadict' ORDER BY table_name; |
| 93 |
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM |
| 94 |
def db_datadict v_granted_glob select `db_datadict`.`t1`.`f2` AS `f2`,`db_datadict`.`t1`.`f3` AS `f3` from `db_datadict`.`t1` NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED |
| 95 |
def db_datadict v_granted_to_1 select `db_datadict`.`t1`.`f1` AS `f1`,`db_datadict`.`t1`.`f2` AS `f2`,`db_datadict`.`t1`.`f3` AS `f3` from `db_datadict`.`t1` NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED |
| 96 |
connect testuser1, localhost, testuser1, ,"*NO-ONE*"; |
| 97 |
SELECT * FROM information_schema.views |
| 98 |
WHERE table_schema = 'db_datadict' ORDER BY table_name; |
| 99 |
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM |
| 100 |
def db_datadict v_granted_to_1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED |
| 101 |
connect testuser2, localhost, testuser2, ,"*NO-ONE*"; |
| 102 |
SELECT * FROM information_schema.views |
| 103 |
WHERE table_schema = 'db_datadict' ORDER BY table_name; |
| 104 |
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM |
| 105 |
def db_datadict v_granted_glob NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED |
| 106 |
def db_datadict v_granted_to_1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED |
| 107 |
connect test_no_views, localhost, test_no_views, ,"*NO-ONE*"; |
| 108 |
SELECT * FROM information_schema.views |
| 109 |
WHERE table_schema = 'db_datadict' ORDER BY table_name; |
| 110 |
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM |
| 111 |
connection default; |
| 112 |
disconnect testuser1; |
| 113 |
disconnect testuser2; |
| 114 |
disconnect test_no_views; |
| 115 |
DROP USER 'testuser1'@'localhost'; |
| 116 |
DROP USER 'testuser2'@'localhost'; |
| 117 |
DROP USER 'test_no_views'@'localhost'; |
| 118 |
DROP DATABASE db_datadict; |
| 119 |
######################################################################### |
| 120 |
# 3.2.1.13+3.2.1.14+3.2.1.15: INFORMATION_SCHEMA.VIEWS modifications |
| 121 |
######################################################################### |
| 122 |
DROP TABLE IF EXISTS test.t1_my_table; |
| 123 |
DROP DATABASE IF EXISTS db_datadict; |
| 124 |
CREATE DATABASE db_datadict; |
| 125 |
CREATE TABLE test.t1_table (f1 BIGINT, f2 CHAR(10)) |
| 126 |
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci |
| 127 |
ENGINE = <engine_type>; |
| 128 |
DROP USER 'testuser1'@'localhost'; |
| 129 |
CREATE USER 'testuser1'@'localhost'; |
| 130 |
SELECT * FROM information_schema.views |
| 131 |
WHERE table_name LIKE 't1_%' |
| 132 |
ORDER BY table_schema, table_name; |
| 133 |
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM |
| 134 |
CREATE VIEW test.t1_view AS SELECT DISTINCT f1 FROM test.t1_table; |
| 135 |
CREATE ALGORITHM=MERGE VIEW test.t1_view1 AS SELECT f1 FROM test.t1_table; |
| 136 |
CREATE ALGORITHM=TEMPTABLE VIEW test.t1_view2 AS SELECT f1 FROM test.t1_table; |
| 137 |
SELECT * FROM information_schema.views |
| 138 |
WHERE table_name LIKE 't1_%' |
| 139 |
ORDER BY table_schema, table_name; |
| 140 |
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM |
| 141 |
def test t1_view select distinct `test`.`t1_table`.`f1` AS `f1` from `test`.`t1_table` NONE NO root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED |
| 142 |
def test t1_view1 select `test`.`t1_table`.`f1` AS `f1` from `test`.`t1_table` NONE YES root@localhost DEFINER latin1 latin1_swedish_ci MERGE |
| 143 |
def test t1_view2 select `test`.`t1_table`.`f1` AS `f1` from `test`.`t1_table` NONE NO root@localhost DEFINER latin1 latin1_swedish_ci TEMPTABLE |
| 144 |
DROP VIEW test.t1_view1; |
| 145 |
DROP VIEW test.t1_view2; |
| 146 |
SELECT table_name,definer FROM information_schema.views |
| 147 |
WHERE table_name = 't1_view'; |
| 148 |
table_name definer |
| 149 |
t1_view root@localhost |
| 150 |
ALTER DEFINER = 'testuser1'@'localhost' VIEW test.t1_view AS |
| 151 |
SELECT DISTINCT f1 FROM test.t1_table; |
| 152 |
SELECT table_name,definer,security_type FROM information_schema.views |
| 153 |
WHERE table_name LIKE 't1_%'; |
| 154 |
table_name definer security_type |
| 155 |
t1_view testuser1@localhost DEFINER |
| 156 |
ALTER DEFINER = 'root'@'localhost' SQL SECURITY INVOKER VIEW test.t1_view AS |
| 157 |
SELECT f1 FROM test.t1_table WITH LOCAL CHECK OPTION; |
| 158 |
SELECT table_name,definer,security_type FROM information_schema.views |
| 159 |
WHERE table_name LIKE 't1_%'; |
| 160 |
table_name definer security_type |
| 161 |
t1_view root@localhost INVOKER |
| 162 |
SELECT table_schema,table_name FROM information_schema.views |
| 163 |
WHERE table_name LIKE 't1_%' |
| 164 |
ORDER BY table_schema,table_name; |
| 165 |
table_schema table_name |
| 166 |
test t1_view |
| 167 |
RENAME TABLE test.t1_view TO db_datadict.t1_view; |
| 168 |
ERROR HY000: Changing schema from 'test' to 'db_datadict' is not allowed |
| 169 |
DROP VIEW test.t1_view; |
| 170 |
CREATE VIEW db_datadict.t1_view AS SELECT * FROM test.t1_table; |
| 171 |
SELECT table_schema,table_name FROM information_schema.views |
| 172 |
WHERE table_name LIKE 't1_%' |
| 173 |
ORDER BY table_schema,table_name; |
| 174 |
table_schema table_name |
| 175 |
db_datadict t1_view |
| 176 |
SELECT table_name FROM information_schema.views |
| 177 |
WHERE table_name LIKE 't1_%' |
| 178 |
ORDER BY table_name; |
| 179 |
table_name |
| 180 |
t1_view |
| 181 |
RENAME TABLE db_datadict.t1_view TO db_datadict.t1_viewx; |
| 182 |
SELECT table_name FROM information_schema.views |
| 183 |
WHERE table_name LIKE 't1_%' |
| 184 |
ORDER BY table_name; |
| 185 |
table_name |
| 186 |
t1_viewx |
| 187 |
SELECT table_name FROM information_schema.views |
| 188 |
WHERE table_name LIKE 't1_%' |
| 189 |
ORDER BY table_name; |
| 190 |
table_name |
| 191 |
t1_viewx |
| 192 |
DROP VIEW db_datadict.t1_viewx; |
| 193 |
SELECT table_name FROM information_schema.views |
| 194 |
WHERE table_name LIKE 't1_%' |
| 195 |
ORDER BY table_name; |
| 196 |
table_name |
| 197 |
CREATE VIEW db_datadict.t1_view AS SELECT * FROM test.t1_table; |
| 198 |
SELECT table_name FROM information_schema.views |
| 199 |
WHERE table_name LIKE 't1_%' |
| 200 |
ORDER BY table_name; |
| 201 |
table_name |
| 202 |
t1_view |
| 203 |
DROP TABLE test.t1_table; |
| 204 |
SELECT table_name FROM information_schema.views |
| 205 |
WHERE table_name LIKE 't1_%' |
| 206 |
ORDER BY table_name; |
| 207 |
table_name |
| 208 |
t1_view |
| 209 |
CREATE TABLE test.t1_table (f1 BIGINT, f2 CHAR(10)) |
| 210 |
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci COMMENT = 'Initial Comment' |
| 211 |
ENGINE = <engine_type>; |
| 212 |
SELECT table_name FROM information_schema.views |
| 213 |
WHERE table_name LIKE 't1_%' |
| 214 |
ORDER BY table_name; |
| 215 |
table_name |
| 216 |
t1_view |
| 217 |
DROP DATABASE db_datadict; |
| 218 |
SELECT table_name FROM information_schema.views |
| 219 |
WHERE table_name LIKE 't1_%' |
| 220 |
ORDER BY table_name; |
| 221 |
table_name |
| 222 |
DROP USER 'testuser1'@'localhost'; |
| 223 |
DROP TABLE test.t1_table; |
| 224 |
######################################################################## |
| 225 |
# Testcases 3.2.1.3-3.2.1.5 + 3.2.1.8-3.2.1.12: INSERT/UPDATE/DELETE and |
| 226 |
# DDL on INFORMATION_SCHEMA table are not supported |
| 227 |
######################################################################## |
| 228 |
DROP DATABASE IF EXISTS db_datadict; |
| 229 |
CREATE DATABASE db_datadict; |
| 230 |
CREATE VIEW db_datadict.v1 AS SELECT 1; |
| 231 |
INSERT INTO information_schema.views |
| 232 |
SELECT * FROM information_schema.views; |
| 233 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 234 |
INSERT INTO information_schema.views(table_schema, table_name) |
| 235 |
VALUES ('db2', 'v2'); |
| 236 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 237 |
UPDATE information_schema.views SET table_schema = 'test' |
| 238 |
WHERE table_name = 't1'; |
| 239 |
Got one of the listed errors |
| 240 |
DELETE FROM information_schema.views WHERE table_name = 't1'; |
| 241 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 242 |
TRUNCATE information_schema.views; |
| 243 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 244 |
CREATE INDEX my_idx_on_views ON information_schema.views(table_schema); |
| 245 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 246 |
ALTER TABLE information_schema.views DROP PRIMARY KEY; |
| 247 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 248 |
ALTER TABLE information_schema.views ADD f1 INT; |
| 249 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 250 |
DROP TABLE information_schema.views; |
| 251 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 252 |
ALTER TABLE information_schema.views RENAME db_datadict.views; |
| 253 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 254 |
ALTER TABLE information_schema.views RENAME information_schema.xviews; |
| 255 |
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' |
| 256 |
DROP DATABASE db_datadict; |