diff options
author | unknown <iggy@recycle.(none)> | 2007-03-29 12:13:42 -0400 |
---|---|---|
committer | unknown <iggy@recycle.(none)> | 2007-03-29 12:13:42 -0400 |
commit | 7c27a05a966ec9911b6afae853f1fc8bdab4b1db (patch) | |
tree | eaa4e6324778d6e13ff178f36f4fffa495709890 | |
parent | 169771462158ec5da9112322d803f027ed39e19b (diff) | |
parent | 09eff0aa5bdbfaebe47c155084d5d84e6f5adec4 (diff) | |
download | mariadb-git-7c27a05a966ec9911b6afae853f1fc8bdab4b1db.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new-maint
into recycle.(none):/src/bug23491/my51-bug23491
mysql-test/t/mysqldump.test:
Auto merged
sql/item_create.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/sp.cc:
Auto merged
sql/sp_head.h:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/mysqldump.result:
SCCS merged
-rw-r--r-- | mysql-test/r/information_schema.result | 2 | ||||
-rw-r--r-- | mysql-test/r/mysqldump.result | 23 | ||||
-rw-r--r-- | mysql-test/r/sp-code.result | 2 | ||||
-rw-r--r-- | mysql-test/r/udf.result | 2 | ||||
-rw-r--r-- | mysql-test/t/mysqldump.test | 32 | ||||
-rw-r--r-- | sql/item_create.cc | 8 | ||||
-rw-r--r-- | sql/item_create.h | 3 | ||||
-rw-r--r-- | sql/item_func.cc | 9 | ||||
-rw-r--r-- | sql/sp.cc | 2 | ||||
-rw-r--r-- | sql/sp_head.h | 6 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 6 |
11 files changed, 78 insertions, 17 deletions
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index e5d6078e863..286768bc7d3 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -706,7 +706,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; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index c274b1073e7..330c86f6518 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3205,6 +3205,29 @@ 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; +# # Bug#26346: stack + buffer overrun in mysqldump # CREATE TABLE t1(a int); diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result index 67b030f87a4..9d86a6bc08d 100644 --- a/mysql-test/r/sp-code.result +++ b/mysql-test/r/sp-code.result @@ -187,7 +187,7 @@ Pos Instruction 32 set v_dig@4 (v_dig@4 + 1) 33 stmt 4 "update sudoku_work set dig = v_dig wh..." 34 set v_tcounter@6 (v_tcounter@6 + 1) -35 jump_if_not 37(37) (not(`test`.`sudoku_digit_ok`(v_row@7,v_col@8,v_dig@4))) +35 jump_if_not 37(37) (not(`sudoku_digit_ok`(v_row@7,v_col@8,v_dig@4))) 36 jump 15 37 set v_i@3 (v_i@3 + 1) 38 jump 15 diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 593ac63ca80..c7a9b0982a9 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -159,7 +159,7 @@ EXPLAIN EXTENDED SELECT myfunc_int(fn(MIN(b))) as c FROM t1 GROUP BY a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 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 filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 708bd9274b1..89e20e527d5 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1466,6 +1466,38 @@ CREATE TABLE t1 (a int) ENGINE=merge UNION=(t2, t3); DROP TABLE t1, t2, t3; --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 # diff --git a/sql/item_create.cc b/sql/item_create.cc index 0c3870883c2..8ff78ef1b48 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -167,7 +167,7 @@ class Create_sp_func : public Create_qfunc { public: virtual Item* create(THD *thd, LEX_STRING db, LEX_STRING name, - List<Item> *item_list); + bool use_explicit_name, List<Item> *item_list); static Create_sp_func s_singleton; @@ -2316,7 +2316,7 @@ Create_qfunc::create(THD *thd, LEX_STRING name, List<Item> *item_list) if (thd->copy_db_to(&db.str, &db.length)) return NULL; - return create(thd, db, name, item_list); + return create(thd, db, name, false, item_list); } @@ -2433,7 +2433,7 @@ Create_sp_func Create_sp_func::s_singleton; Item* Create_sp_func::create(THD *thd, LEX_STRING db, LEX_STRING name, - List<Item> *item_list) + bool use_explicit_name, List<Item> *item_list) { int arg_count= 0; Item *func= NULL; @@ -2458,7 +2458,7 @@ Create_sp_func::create(THD *thd, LEX_STRING db, LEX_STRING name, if (item_list != NULL) arg_count= item_list->elements; - qname= new (thd->mem_root) sp_name(db, name); + qname= new (thd->mem_root) sp_name(db, name, use_explicit_name); qname->init_qname(thd); sp_add_used_routine(lex, thd, qname, TYPE_ENUM_FUNCTION); diff --git a/sql/item_create.h b/sql/item_create.h index 985c4428d8f..0a668b3e67f 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -87,11 +87,12 @@ public: @param thd The current thread @param db The database name @param name The function name + @param use_explicit_name Should the function be represented as 'db.name'? @param item_list The list of arguments to the function, can be NULL @return An item representing the parsed function call */ virtual Item* create(THD *thd, LEX_STRING db, LEX_STRING name, - List<Item> *item_list) = 0; + bool use_explicit_name, List<Item> *item_list) = 0; protected: /** Constructor. */ diff --git a/sql/item_func.cc b/sql/item_func.cc index b7a708686a8..83d08d18561 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5030,7 +5030,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_explicit_name ? m_name->m_db.length : 0 + m_name->m_name.length)*2 + //characters*quoting 2 + // ` and ` 1 + // . @@ -5040,8 +5040,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_explicit_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(); } diff --git a/sql/sp.cc b/sql/sp.cc index c1a9aac0c24..3c6ae495068 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1041,7 +1041,7 @@ sp_exist_routines(THD *thd, TABLE_LIST *routines, bool any, bool no_error) 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 || diff --git a/sql/sp_head.h b/sql/sp_head.h index 19dc2dac476..10a8583571c 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -59,9 +59,10 @@ public: calling set_routine_type(). */ LEX_STRING m_sroutines_key; + bool m_explicit_name; /**< Prepend the db 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_explicit_name) + : m_db(db), m_name(name), m_explicit_name(use_explicit_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_explicit_name= false; } // Init. the qualified name from the db and name. diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b7f8f75b4a5..8d27659f225 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1931,7 +1931,7 @@ sp_name: my_error(ER_SP_WRONG_NAME, MYF(0), $3.str); MYSQL_YYABORT; } - $$= new sp_name($1, $3); + $$= new sp_name($1, $3, true); $$->init_qname(YYTHD); } | ident @@ -1945,7 +1945,7 @@ sp_name: } if (thd->copy_db_to(&db.str, &db.length)) MYSQL_YYABORT; - $$= new sp_name(db, $1); + $$= new sp_name(db, $1, false); if ($$) $$->init_qname(YYTHD); } @@ -6923,7 +6923,7 @@ function_call_generic: builder= find_qualified_function_builder(thd); DBUG_ASSERT(builder); - item= builder->create(thd, $1, $3, $5); + item= builder->create(thd, $1, $3, true, $5); if (! ($$= item)) { |