Below is the list of changes that have just been committed into a local
5.0 repository of iggy. When iggy does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-02-20 15:43:19-05:00, iggy@alf. +8 -0
Bug#23491 MySQLDump prefix function call in a view by database name
- mysqldump executes a SHOW CREATE VIEW statement to generate the text
that it outputs. When the function name is retrieved it's database
name is unconditionally prepended. This change causes the function's
database name to be prepended only when it was used to define the
function.
mysql-test/r/information_schema.result@stripped, 2007-02-20 15:43:11-05:00, iggy@alf. +1 -1
Bug#23491 MySQLDump prefix function call in a view by database name
- Updated Results.
mysql-test/r/mysqldump.result@stripped, 2007-02-20 15:43:12-05:00, iggy@alf. +23 -0
Bug#23491 MySQLDump prefix function call in a view by database name
- Updated Results.
mysql-test/r/udf.result@stripped, 2007-02-20 15:43:12-05:00, iggy@alf. +1 -1
Bug#23491 MySQLDump prefix function call in a view by database name
- Updated Results.
mysql-test/t/mysqldump.test@stripped, 2007-02-20 15:43:13-05:00, iggy@alf. +32 -0
Bug#23491 MySQLDump prefix function call in a view by database name
- Added new testcase.
sql/item_func.cc@stripped, 2007-02-20 15:43:13-05:00, iggy@alf. +6 -3
Bug#23491 MySQLDump prefix function call in a view by database name
- Updated Results.
sql/sp.cc@stripped, 2007-02-20 15:43:13-05:00, iggy@alf. +1 -1
Bug#23491 MySQLDump prefix function call in a view by database name
- Use new sp_name constructor.
sql/sp_head.h@stripped, 2007-02-20 15:43:14-05:00, iggy@alf. +4 -2
Bug#23491 MySQLDump prefix function call in a view by database name
- Add m_implicit_name member to sp_name object.
- Redefined sp_name constructor to include new member.
sql/sql_yacc.yy@stripped, 2007-02-20 15:43:14-05:00, iggy@alf. +4 -4
Bug#23491 MySQLDump prefix function call in a view by database name
- Use new sp_name constructors.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: iggy
# Host: alf.
# Root: D:/src/mysql-5.0-maint_23491
--- 1.324/sql/item_func.cc 2007-02-20 15:43:35 -05:00
+++ 1.325/sql/item_func.cc 2007-02-20 15:43:35 -05:00
@@ -5016,7 +5016,7 @@ Item_func_sp::func_name() const
{
THD *thd= current_thd;
/* Calculate length to avoid reallocation of string for sure */
- uint len= ((m_name->m_db.length +
+ uint len= ((m_name->m_implicit_name ? m_name->m_db.length : 0 +
m_name->m_name.length)*2 + //characters*quoting
2 + // ` and `
1 + // .
@@ -5026,8 +5026,11 @@ Item_func_sp::func_name() const
system_charset_info);
qname.length(0);
- append_identifier(thd, &qname, m_name->m_db.str, m_name->m_db.length);
- qname.append('.');
+ if (m_name->m_implicit_name)
+ {
+ append_identifier(thd, &qname, m_name->m_db.str, m_name->m_db.length);
+ qname.append('.');
+ }
append_identifier(thd, &qname, m_name->m_name.str, m_name->m_name.length);
return qname.ptr();
}
--- 1.503/sql/sql_yacc.yy 2007-02-20 15:43:35 -05:00
+++ 1.504/sql/sql_yacc.yy 2007-02-20 15:43:35 -05:00
@@ -1437,7 +1437,7 @@ sp_name:
my_error(ER_SP_WRONG_NAME, MYF(0), $3.str);
YYABORT;
}
- $$= new sp_name($1, $3);
+ $$= new sp_name($1, $3, true);
$$->init_qname(YYTHD);
}
| ident
@@ -1451,7 +1451,7 @@ sp_name:
}
if (thd->copy_db_to(&db.str, &db.length))
YYABORT;
- $$= new sp_name(db, $1);
+ $$= new sp_name(db, $1, false);
if ($$)
$$->init_qname(YYTHD);
}
@@ -4892,7 +4892,7 @@ simple_expr:
| ident '.' ident '(' opt_expr_list ')'
{
LEX *lex= Lex;
- sp_name *name= new sp_name($1, $3);
+ sp_name *name= new sp_name($1, $3, true);
name->init_qname(YYTHD);
sp_add_used_routine(lex, YYTHD, name, TYPE_ENUM_FUNCTION);
@@ -5008,7 +5008,7 @@ simple_expr:
LEX_STRING db;
if (thd->copy_db_to(&db.str, &db.length))
YYABORT;
- sp_name *name= new sp_name(db, $1);
+ sp_name *name= new sp_name(db, $1, false);
if (name)
name->init_qname(thd);
--- 1.117/mysql-test/r/information_schema.result 2007-02-20 15:43:36 -05:00
+++ 1.118/mysql-test/r/information_schema.result 2007-02-20 15:43:36 -05:00
@@ -687,7 +687,7 @@ Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or
definer/invoker of view lack rights to use them
show create table v3;
View Create View
-v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3`
AS select `test`.`sub1`(1) AS `c`
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3`
AS select `sub1`(1) AS `c`
Warnings:
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or
definer/invoker of view lack rights to use them
drop view v2;
--- 1.11/mysql-test/r/udf.result 2007-02-20 15:43:36 -05:00
+++ 1.12/mysql-test/r/udf.result 2007-02-20 15:43:36 -05:00
@@ -159,7 +159,7 @@ EXPLAIN EXTENDED SELECT myfunc_int(fn(MI
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
Warnings:
-Note 1003 select myfunc_int(`test`.`fn`(min(`test`.`t1`.`b`)) AS `fn(MIN(b))`) AS `c`
from `test`.`t1` group by `test`.`t1`.`a`
+Note 1003 select myfunc_int(`fn`(min(`test`.`t1`.`b`)) AS `fn(MIN(b))`) AS `c` from
`test`.`t1` group by `test`.`t1`.`a`
EXPLAIN EXTENDED SELECT myfunc_int(test.fn(MIN(b))) as c FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
--- 1.125/sql/sp.cc 2007-02-20 15:43:36 -05:00
+++ 1.126/sql/sp.cc 2007-02-20 15:43:36 -05:00
@@ -1070,7 +1070,7 @@ sp_exist_routines(THD *thd, TABLE_LIST *
lex_name.length= strlen(routine->table_name);
lex_db.str= thd->strmake(routine->db, lex_db.length);
lex_name.str= thd->strmake(routine->table_name, lex_name.length);
- name= new sp_name(lex_db, lex_name);
+ name= new sp_name(lex_db, lex_name, true);
name->init_qname(thd);
sp_object_found= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, name,
&thd->sp_proc_cache, FALSE) != NULL ||
--- 1.90/sql/sp_head.h 2007-02-20 15:43:36 -05:00
+++ 1.91/sql/sp_head.h 2007-02-20 15:43:36 -05:00
@@ -59,9 +59,10 @@ public:
calling set_routine_type().
*/
LEX_STRING m_sroutines_key;
+ bool m_implicit_name;
- sp_name(LEX_STRING db, LEX_STRING name)
- : m_db(db), m_name(name)
+ sp_name(LEX_STRING db, LEX_STRING name, bool use_implicit_name)
+ : m_db(db), m_name(name), m_implicit_name(use_implicit_name)
{
m_qname.str= m_sroutines_key.str= 0;
m_qname.length= m_sroutines_key.length= 0;
@@ -79,6 +80,7 @@ public:
m_name.length= m_qname.length= key_len - 1;
m_db.str= 0;
m_db.length= 0;
+ m_implicit_name= false;
}
// Init. the qualified name from the db and name.
--- 1.119/mysql-test/r/mysqldump.result 2007-02-20 15:43:36 -05:00
+++ 1.120/mysql-test/r/mysqldump.result 2007-02-20 15:43:36 -05:00
@@ -3218,5 +3218,28 @@ INSERT INTO t1 VALUES(1,0xff00fef0);
</mysqldump>
DROP TABLE t1;
#
+# Bug #23491: MySQLDump prefix function call in a view by database name
+#
+create database bug23491_original;
+create database bug23491_restore;
+use bug23491_original;
+create table t1 (c1 int);
+create view v1 as select * from t1;
+create procedure p1() select 1;
+create function f1() returns int return 1;
+create view v2 as select f1();
+create function f2() returns int return f1();
+create view v3 as select bug23491_original.f1();
+use bug23491_restore;
+show create view bug23491_restore.v2;
+View Create View
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2`
AS select `f1`() AS `f1()`
+show create view bug23491_restore.v3;
+View Create View
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3`
AS select `bug23491_original`.`f1`() AS `bug23491_original.f1()`
+drop database bug23491_original;
+drop database bug23491_restore;
+use test;
+#
# End of 5.0 tests
#
--- 1.108/mysql-test/t/mysqldump.test 2007-02-20 15:43:36 -05:00
+++ 1.109/mysql-test/t/mysqldump.test 2007-02-20 15:43:36 -05:00
@@ -1428,5 +1428,37 @@ INSERT INTO t1 VALUES(1,0xff00fef0);
DROP TABLE t1;
--echo #
+--echo # Bug #23491: MySQLDump prefix function call in a view by database name
+--echo #
+
+# Setup
+create database bug23491_original;
+create database bug23491_restore;
+use bug23491_original;
+create table t1 (c1 int);
+create view v1 as select * from t1;
+create procedure p1() select 1;
+create function f1() returns int return 1;
+create view v2 as select f1();
+create function f2() returns int return f1();
+create view v3 as select bug23491_original.f1();
+
+# Backup.
+--exec $MYSQL_DUMP --skip-comments -uroot --opt --routines bug23491_original >
$MYSQLTEST_VARDIR/tmp/bug23491_backup.sql;
+
+# Restore.
+--exec $MYSQL bug23491_restore < $MYSQLTEST_VARDIR/tmp/bug23491_backup.sql;
+
+# Verify
+use bug23491_restore;
+show create view bug23491_restore.v2;
+show create view bug23491_restore.v3;
+
+# Cleanup
+drop database bug23491_original;
+drop database bug23491_restore;
+use test;
+
+--echo #
--echo # End of 5.0 tests
--echo #
| Thread |
|---|
| • bk commit into 5.0 tree (iggy:1.2402) BUG#23491 | Ignacio Galarza | 20 Feb |