List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:February 6 2009 11:39am
Subject:bzr commit into mysql-5.0-bugteam branch (Sergey.Glukhov:2742)
Bug#40345
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.0-bug-33717/ based on revid:sergey.glukhov@stripped

 2742 Sergey Glukhov	2009-02-06
      Bug#40345 MySQLDump prefixes view name with database name when view references other db
      The fix:
      print compact view name if 
      view only references table inside it's own db
      or information_schema table.
modified:
  mysql-test/r/information_schema.result
  mysql-test/t/information_schema.test
  sql/sql_show.cc

per-file messages:
  mysql-test/r/information_schema.result
    test result
  mysql-test/t/information_schema.test
    test case
  sql/sql_show.cc
    print compact view name if 
    view only references table inside it's own db
    or information_schema table.
=== modified file 'mysql-test/r/information_schema.result'
--- a/mysql-test/r/information_schema.result	2008-03-25 15:44:27 +0000
+++ b/mysql-test/r/information_schema.result	2009-02-06 11:38:50 +0000
@@ -1432,4 +1432,9 @@ TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	TA
 DROP TABLE test.t1;
 SET max_heap_table_size = DEFAULT;
 USE test;
+create view v1 as select TABLE_NAME from information_schema.TABLES;
+show create view v1;
+View	Create View
+v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `TABLES`.`TABLE_NAME` AS `TABLE_NAME` from `information_schema`.`TABLES`
+drop view v1;
 End of 5.0 tests.

=== modified file 'mysql-test/t/information_schema.test'
--- a/mysql-test/t/information_schema.test	2008-03-25 15:44:27 +0000
+++ b/mysql-test/t/information_schema.test	2009-02-06 11:38:50 +0000
@@ -1139,5 +1139,12 @@ DROP TABLE test.t1;
 SET max_heap_table_size = DEFAULT;
 USE test;
 
+#
+# Bug#40345 MySQLDump prefixes view name with database name when view references other db
+#
+create view v1 as select TABLE_NAME from information_schema.TABLES;
+show create view v1;
+drop view v1;
+
 --echo End of 5.0 tests.
 

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2009-01-05 10:37:56 +0000
+++ b/sql/sql_show.cc	2009-02-06 11:38:50 +0000
@@ -1222,6 +1222,7 @@ 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 |
@@ -1232,9 +1233,10 @@ view_store_create_info(THD *thd, TABLE_L
      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
+       or information_schema table
   */
   if (!thd->db || strcmp(thd->db, table->view_db.str))
-    table->compact_view_format= FALSE;
+    compact_view_name= table->compact_view_format= FALSE;
   else
   {
     TABLE_LIST *tbl;
@@ -1246,6 +1248,8 @@ view_store_create_info(THD *thd, TABLE_L
       if (strcmp(table->view_db.str, tbl->view ? tbl->view_db.str :tbl->db)!= 0)
       {
         table->compact_view_format= FALSE;
+        if (!tbl->schema_table)
+          compact_view_name= FALSE;
         break;
       }
     }
@@ -1257,7 +1261,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('.');

Thread
bzr commit into mysql-5.0-bugteam branch (Sergey.Glukhov:2742)Bug#40345Sergey Glukhov6 Feb