|
| 1 | +create database mysqltest1; |
| 2 | +create database mysqltest2; |
| 3 | +create database mysqltest3; |
| 4 | +create user invoker@localhost; |
| 5 | +create user definer@localhost; |
| 6 | +grant select,show view on mysqltest1.* to invoker@localhost; |
| 7 | +grant select,show view on mysqltest1.* to definer@localhost; |
| 8 | +grant select,show view on mysqltest2.* to invoker@localhost; |
| 9 | +grant select,show view on mysqltest2.* to definer@localhost; |
| 10 | +grant select,show view on mysqltest3.* to invoker@localhost; |
| 11 | +grant select on performance_schema.* to definer@localhost; |
| 12 | +create table mysqltest1.t1 (a int); |
| 13 | +create definer=definer@localhost view mysqltest2.v2 as select * from mysqltest1.t1; |
| 14 | +create definer=definer@localhost view mysqltest3.v3 as select * from mysqltest2.v2; |
| 15 | +create definer=definer@localhost view mysqltest3.v3is as select schema_name from information_schema.schemata order by schema_name; |
| 16 | +create definer=definer@localhost view mysqltest3.v3ps as select user from performance_schema.users where current_connections>0 order by user; |
| 17 | +create definer=definer@localhost view mysqltest3.v3nt as select 1; |
| 18 | +create definer=definer@localhost sql security invoker view mysqltest3.v3i as select * from mysqltest1.t1; |
| 19 | + |
| 20 | +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET latin1 */; |
| 21 | + |
| 22 | +USE `mysqltest1`; |
| 23 | +/*!40101 SET @saved_cs_client = @@character_set_client */; |
| 24 | +/*!40101 SET character_set_client = utf8 */; |
| 25 | +CREATE TABLE `t1` ( |
| 26 | + `a` int(11) DEFAULT NULL |
| 27 | +) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
| 28 | +/*!40101 SET character_set_client = @saved_cs_client */; |
| 29 | + |
| 30 | +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET latin1 */; |
| 31 | + |
| 32 | +USE `mysqltest2`; |
| 33 | +SET @saved_cs_client = @@character_set_client; |
| 34 | +SET character_set_client = utf8; |
| 35 | +/*!50001 CREATE TABLE `v2` ( |
| 36 | + `a` tinyint NOT NULL |
| 37 | +) ENGINE=MyISAM */; |
| 38 | +SET character_set_client = @saved_cs_client; |
| 39 | + |
| 40 | +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest3` /*!40100 DEFAULT CHARACTER SET latin1 */; |
| 41 | + |
| 42 | +USE `mysqltest3`; |
| 43 | +SET @saved_cs_client = @@character_set_client; |
| 44 | +SET character_set_client = utf8; |
| 45 | +/*!50001 CREATE TABLE `v3` ( |
| 46 | + `a` tinyint NOT NULL |
| 47 | +) ENGINE=MyISAM */; |
| 48 | +SET character_set_client = @saved_cs_client; |
| 49 | +SET @saved_cs_client = @@character_set_client; |
| 50 | +SET character_set_client = utf8; |
| 51 | +/*!50001 CREATE TABLE `v3i` ( |
| 52 | + `a` tinyint NOT NULL |
| 53 | +) ENGINE=MyISAM */; |
| 54 | +SET character_set_client = @saved_cs_client; |
| 55 | +SET @saved_cs_client = @@character_set_client; |
| 56 | +SET character_set_client = utf8; |
| 57 | +/*!50001 CREATE TABLE `v3is` ( |
| 58 | + `schema_name` tinyint NOT NULL |
| 59 | +) ENGINE=MyISAM */; |
| 60 | +SET character_set_client = @saved_cs_client; |
| 61 | +SET @saved_cs_client = @@character_set_client; |
| 62 | +SET character_set_client = utf8; |
| 63 | +/*!50001 CREATE TABLE `v3nt` ( |
| 64 | + `1` tinyint NOT NULL |
| 65 | +) ENGINE=MyISAM */; |
| 66 | +SET character_set_client = @saved_cs_client; |
| 67 | +SET @saved_cs_client = @@character_set_client; |
| 68 | +SET character_set_client = utf8; |
| 69 | +/*!50001 CREATE TABLE `v3ps` ( |
| 70 | + `user` tinyint NOT NULL |
| 71 | +) ENGINE=MyISAM */; |
| 72 | +SET character_set_client = @saved_cs_client; |
| 73 | + |
| 74 | +USE `mysqltest1`; |
| 75 | + |
| 76 | +USE `mysqltest2`; |
| 77 | +/*!50001 DROP TABLE IF EXISTS `v2`*/; |
| 78 | +/*!50001 SET @saved_cs_client = @@character_set_client */; |
| 79 | +/*!50001 SET @saved_cs_results = @@character_set_results */; |
| 80 | +/*!50001 SET @saved_col_connection = @@collation_connection */; |
| 81 | +/*!50001 SET character_set_client = latin1 */; |
| 82 | +/*!50001 SET character_set_results = latin1 */; |
| 83 | +/*!50001 SET collation_connection = latin1_swedish_ci */; |
| 84 | +/*!50001 CREATE ALGORITHM=UNDEFINED */ |
| 85 | +/*!50013 DEFINER=`definer`@`localhost` SQL SECURITY DEFINER */ |
| 86 | +/*!50001 VIEW `v2` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` */; |
| 87 | +/*!50001 SET character_set_client = @saved_cs_client */; |
| 88 | +/*!50001 SET character_set_results = @saved_cs_results */; |
| 89 | +/*!50001 SET collation_connection = @saved_col_connection */; |
| 90 | + |
| 91 | +USE `mysqltest3`; |
| 92 | +/*!50001 DROP TABLE IF EXISTS `v3`*/; |
| 93 | +/*!50001 SET @saved_cs_client = @@character_set_client */; |
| 94 | +/*!50001 SET @saved_cs_results = @@character_set_results */; |
| 95 | +/*!50001 SET @saved_col_connection = @@collation_connection */; |
| 96 | +/*!50001 SET character_set_client = latin1 */; |
| 97 | +/*!50001 SET character_set_results = latin1 */; |
| 98 | +/*!50001 SET collation_connection = latin1_swedish_ci */; |
| 99 | +/*!50001 CREATE ALGORITHM=UNDEFINED */ |
| 100 | +/*!50013 DEFINER=`definer`@`localhost` SQL SECURITY DEFINER */ |
| 101 | +/*!50001 VIEW `v3` AS select `v2`.`a` AS `a` from `mysqltest2`.`v2` */; |
| 102 | +/*!50001 SET character_set_client = @saved_cs_client */; |
| 103 | +/*!50001 SET character_set_results = @saved_cs_results */; |
| 104 | +/*!50001 SET collation_connection = @saved_col_connection */; |
| 105 | +/*!50001 DROP TABLE IF EXISTS `v3i`*/; |
| 106 | +/*!50001 SET @saved_cs_client = @@character_set_client */; |
| 107 | +/*!50001 SET @saved_cs_results = @@character_set_results */; |
| 108 | +/*!50001 SET @saved_col_connection = @@collation_connection */; |
| 109 | +/*!50001 SET character_set_client = latin1 */; |
| 110 | +/*!50001 SET character_set_results = latin1 */; |
| 111 | +/*!50001 SET collation_connection = latin1_swedish_ci */; |
| 112 | +/*!50001 CREATE ALGORITHM=UNDEFINED */ |
| 113 | +/*!50013 DEFINER=`definer`@`localhost` SQL SECURITY INVOKER */ |
| 114 | +/*!50001 VIEW `v3i` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` */; |
| 115 | +/*!50001 SET character_set_client = @saved_cs_client */; |
| 116 | +/*!50001 SET character_set_results = @saved_cs_results */; |
| 117 | +/*!50001 SET collation_connection = @saved_col_connection */; |
| 118 | +/*!50001 DROP TABLE IF EXISTS `v3is`*/; |
| 119 | +/*!50001 SET @saved_cs_client = @@character_set_client */; |
| 120 | +/*!50001 SET @saved_cs_results = @@character_set_results */; |
| 121 | +/*!50001 SET @saved_col_connection = @@collation_connection */; |
| 122 | +/*!50001 SET character_set_client = latin1 */; |
| 123 | +/*!50001 SET character_set_results = latin1 */; |
| 124 | +/*!50001 SET collation_connection = latin1_swedish_ci */; |
| 125 | +/*!50001 CREATE ALGORITHM=UNDEFINED */ |
| 126 | +/*!50013 DEFINER=`definer`@`localhost` SQL SECURITY DEFINER */ |
| 127 | +/*!50001 VIEW `v3is` AS select `information_schema`.`schemata`.`SCHEMA_NAME` AS `schema_name` from `information_schema`.`schemata` order by `information_schema`.`schemata`.`SCHEMA_NAME` */; |
| 128 | +/*!50001 SET character_set_client = @saved_cs_client */; |
| 129 | +/*!50001 SET character_set_results = @saved_cs_results */; |
| 130 | +/*!50001 SET collation_connection = @saved_col_connection */; |
| 131 | +/*!50001 DROP TABLE IF EXISTS `v3nt`*/; |
| 132 | +/*!50001 SET @saved_cs_client = @@character_set_client */; |
| 133 | +/*!50001 SET @saved_cs_results = @@character_set_results */; |
| 134 | +/*!50001 SET @saved_col_connection = @@collation_connection */; |
| 135 | +/*!50001 SET character_set_client = latin1 */; |
| 136 | +/*!50001 SET character_set_results = latin1 */; |
| 137 | +/*!50001 SET collation_connection = latin1_swedish_ci */; |
| 138 | +/*!50001 CREATE ALGORITHM=UNDEFINED */ |
| 139 | +/*!50013 DEFINER=`definer`@`localhost` SQL SECURITY DEFINER */ |
| 140 | +/*!50001 VIEW `v3nt` AS select 1 AS `1` */; |
| 141 | +/*!50001 SET character_set_client = @saved_cs_client */; |
| 142 | +/*!50001 SET character_set_results = @saved_cs_results */; |
| 143 | +/*!50001 SET collation_connection = @saved_col_connection */; |
| 144 | +/*!50001 DROP TABLE IF EXISTS `v3ps`*/; |
| 145 | +/*!50001 SET @saved_cs_client = @@character_set_client */; |
| 146 | +/*!50001 SET @saved_cs_results = @@character_set_results */; |
| 147 | +/*!50001 SET @saved_col_connection = @@collation_connection */; |
| 148 | +/*!50001 SET character_set_client = latin1 */; |
| 149 | +/*!50001 SET character_set_results = latin1 */; |
| 150 | +/*!50001 SET collation_connection = latin1_swedish_ci */; |
| 151 | +/*!50001 CREATE ALGORITHM=UNDEFINED */ |
| 152 | +/*!50013 DEFINER=`definer`@`localhost` SQL SECURITY DEFINER */ |
| 153 | +/*!50001 VIEW `v3ps` AS select `performance_schema`.`users`.`USER` AS `user` from `performance_schema`.`users` where `performance_schema`.`users`.`CURRENT_CONNECTIONS` > 0 order by `performance_schema`.`users`.`USER` */; |
| 154 | +/*!50001 SET character_set_client = @saved_cs_client */; |
| 155 | +/*!50001 SET character_set_results = @saved_cs_results */; |
| 156 | +/*!50001 SET collation_connection = @saved_col_connection */; |
| 157 | +connect inv,localhost,invoker; |
| 158 | +lock table mysqltest3.v3 write; |
| 159 | +ERROR 42000: Access denied for user 'invoker'@'localhost' to database 'mysqltest3' |
| 160 | +disconnect inv; |
| 161 | +connection default; |
| 162 | +grant lock tables on mysqltest3.* to invoker@localhost; |
| 163 | +connect inv,localhost,invoker; |
| 164 | +show create view mysqltest3.v3; |
| 165 | +View Create View character_set_client collation_connection |
| 166 | +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`definer`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest3`.`v3` AS select `v2`.`a` AS `a` from `mysqltest2`.`v2` latin1 latin1_swedish_ci |
| 167 | +show create view mysqltest3.v3is; |
| 168 | +View Create View character_set_client collation_connection |
| 169 | +v3is CREATE ALGORITHM=UNDEFINED DEFINER=`definer`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest3`.`v3is` AS select `information_schema`.`schemata`.`SCHEMA_NAME` AS `schema_name` from `information_schema`.`schemata` order by `information_schema`.`schemata`.`SCHEMA_NAME` latin1 latin1_swedish_ci |
| 170 | +show create view mysqltest3.v3ps; |
| 171 | +View Create View character_set_client collation_connection |
| 172 | +v3ps CREATE ALGORITHM=UNDEFINED DEFINER=`definer`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest3`.`v3ps` AS select `performance_schema`.`users`.`USER` AS `user` from `performance_schema`.`users` where `performance_schema`.`users`.`CURRENT_CONNECTIONS` > 0 order by `performance_schema`.`users`.`USER` latin1 latin1_swedish_ci |
| 173 | +show create view mysqltest3.v3nt; |
| 174 | +View Create View character_set_client collation_connection |
| 175 | +v3nt CREATE ALGORITHM=UNDEFINED DEFINER=`definer`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest3`.`v3nt` AS select 1 AS `1` latin1 latin1_swedish_ci |
| 176 | +show create view mysqltest3.v3i; |
| 177 | +View Create View character_set_client collation_connection |
| 178 | +v3i CREATE ALGORITHM=UNDEFINED DEFINER=`definer`@`localhost` SQL SECURITY INVOKER VIEW `mysqltest3`.`v3i` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` latin1 latin1_swedish_ci |
| 179 | +lock table mysqltest3.v3 write; |
| 180 | +ERROR HY000: View 'mysqltest3.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them |
| 181 | +lock table mysqltest3.v3i write; |
| 182 | +ERROR HY000: View 'mysqltest3.v3i' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them |
| 183 | +lock table mysqltest3.v3is write; |
| 184 | +select * from mysqltest3.v3is; |
| 185 | +schema_name |
| 186 | +information_schema |
| 187 | +mysqltest1 |
| 188 | +mysqltest2 |
| 189 | +performance_schema |
| 190 | +test |
| 191 | +lock table mysqltest3.v3ps write; |
| 192 | +select * from mysqltest3.v3ps; |
| 193 | +user |
| 194 | +NULL |
| 195 | +invoker |
| 196 | +root |
| 197 | +lock table mysqltest3.v3nt write; |
| 198 | +select * from mysqltest3.v3nt; |
| 199 | +1 |
| 200 | +1 |
| 201 | +disconnect inv; |
| 202 | +connection default; |
| 203 | +grant lock tables on mysqltest2.* to invoker@localhost; |
| 204 | +connect inv,localhost,invoker; |
| 205 | +lock table mysqltest3.v3 write; |
| 206 | +ERROR HY000: View 'mysqltest3.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them |
| 207 | +lock table mysqltest3.v3i write; |
| 208 | +ERROR HY000: View 'mysqltest3.v3i' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them |
| 209 | +disconnect inv; |
| 210 | +connection default; |
| 211 | +grant lock tables on mysqltest1.* to definer@localhost; |
| 212 | +connect inv,localhost,invoker; |
| 213 | +lock table mysqltest3.v3 write; |
| 214 | +select * from mysqltest3.v3; |
| 215 | +a |
| 216 | +lock table mysqltest3.v3i write; |
| 217 | +ERROR HY000: View 'mysqltest3.v3i' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them |
| 218 | +disconnect inv; |
| 219 | +connection default; |
| 220 | +grant lock tables on mysqltest1.* to invoker@localhost; |
| 221 | +connect inv,localhost,invoker; |
| 222 | +lock table mysqltest3.v3i write; |
| 223 | +select * from mysqltest3.v3i; |
| 224 | +a |
| 225 | +disconnect inv; |
| 226 | +connection default; |
| 227 | +drop user invoker@localhost; |
| 228 | +drop user definer@localhost; |
| 229 | +drop database mysqltest1; |
| 230 | +drop database mysqltest2; |
| 231 | +drop database mysqltest3; |
0 commit comments