#At file:///home/gluh/MySQL/mysql-5.0-bugteam/ based on revid:sergey.glukhov@stripped
2763 Sergey Glukhov 2009-02-25
Bug#40345 MySQLDump prefixes view name with database name when view references other db
print compact view name if the view belongs to the current database
@ mysql-test/r/information_schema_db.result
result fix
@ mysql-test/r/mysqldump.result
result fix
@ mysql-test/r/view_grant.result
result fix
@ sql/sql_show.cc
print compact view name if the view belongs to the current database
modified:
mysql-test/r/information_schema_db.result
mysql-test/r/mysqldump.result
mysql-test/r/view_grant.result
sql/sql_show.cc
=== modified file 'mysql-test/r/information_schema_db.result'
--- a/mysql-test/r/information_schema_db.result 2008-10-02 09:37:07 +0000
+++ b/mysql-test/r/information_schema_db.result 2009-02-25 11:44:50 +0000
@@ -188,7 +188,7 @@ Field Type Null Key Default Extra
f1 char(4) YES NULL
show create view v2;
View Create View
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
show create view testdb_1.v1;
ERROR 42000: SHOW VIEW command denied to user 'testdb_2'@'localhost' for table 'v1'
select table_name from information_schema.columns a
=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result 2009-02-19 16:33:28 +0000
+++ b/mysql-test/r/mysqldump.result 2009-02-25 11:44:50 +0000
@@ -3246,7 +3246,7 @@ USE `mysqldump_views`;
/*!50001 DROP TABLE `nasishnasifu`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `mysqldump_views`.`nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
+/*!50001 VIEW `nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
drop view nasishnasifu;
drop database mysqldump_views;
drop table mysqldump_tables.basetable;
=== modified file 'mysql-test/r/view_grant.result'
--- a/mysql-test/r/view_grant.result 2008-02-21 09:17:32 +0000
+++ b/mysql-test/r/view_grant.result 2009-02-25 11:44:50 +0000
@@ -26,7 +26,7 @@ create view v2 as select * from mysqltes
ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2'
show create view v1;
View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1`
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1`
grant create view,drop,select on test.* to mysqltest_1@localhost;
use test;
alter view v1 as select * from mysqltest.t1;
@@ -307,7 +307,7 @@ grant create view,select on test.* to my
create view v1 as select * from mysqltest.t1;
show create view v1;
View Create View
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1`
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1`
revoke select on mysqltest.t1 from mysqltest_1@localhost;
select * from v1;
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2009-02-25 10:20:20 +0000
+++ b/sql/sql_show.cc 2009-02-25 11:44:50 +0000
@@ -1232,21 +1232,25 @@ void append_definer(THD *thd, String *bu
static int
view_store_create_info(THD *thd, TABLE_LIST *table, String *buff)
{
+ my_bool compact_view_name= TRUE;
my_bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
MODE_ORACLE |
MODE_MSSQL |
MODE_DB2 |
MODE_MAXDB |
MODE_ANSI)) != 0;
- /*
- Compact output format for view can be used
- - if user has db of this view as current db
- - if this view only references table inside it's own db
- */
+
if (!thd->db || strcmp(thd->db, table->view_db.str))
- table->compact_view_format= FALSE;
+ /*
+ print compact view name if the view belongs to the current database
+ */
+ compact_view_name= table->compact_view_format= FALSE;
else
{
+ /*
+ Compact output format for view body can be used
+ if this view only references table inside it's own db
+ */
TABLE_LIST *tbl;
table->compact_view_format= TRUE;
for (tbl= thd->lex->query_tables;
@@ -1267,7 +1271,7 @@ view_store_create_info(THD *thd, TABLE_L
view_store_options(thd, table, buff);
}
buff->append(STRING_WITH_LEN("VIEW "));
- if (!table->compact_view_format)
+ if (!compact_view_name)
{
append_identifier(thd, buff, table->view_db.str, table->view_db.length);
buff->append('.');
Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20090225114450-g5gahec8k2lubztv.bundle
| Thread |
|---|
| • bzr commit into mysql-5.0-bugteam branch (Sergey.Glukhov:2763)Bug#40345 | Sergey Glukhov | 25 Feb |