Loading mysql-test/r/rpl_sp.result +20 −0 Original line number Diff line number Diff line Loading @@ -468,4 +468,24 @@ drop table t1; set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0; End of 5.0 tests drop database if exists mysqltest; drop database if exists mysqltest2; create database mysqltest; create database mysqltest2; use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); show binlog events in 'master-bin.000001' from 8657; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 8657 Query 1 8760 drop database if exists mysqltest2 master-bin.000001 8760 Query 1 8853 create database mysqltest master-bin.000001 8853 Query 1 8948 create database mysqltest2 master-bin.000001 8948 Query 1 9045 use `mysqltest2`; create table t ( t integer ) master-bin.000001 9045 Query 1 9184 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end master-bin.000001 9184 Query 1 9279 use `mysqltest2`; insert into t values ( 1 ) create procedure `\\`.test() begin end; ERROR 42000: Unknown database '\\' drop database mysqltest; drop database mysqltest2; End of 5.1 tests mysql-test/t/rpl_sp.test +22 −0 Original line number Diff line number Diff line Loading @@ -528,4 +528,26 @@ connection master; set global log_bin_trust_function_creators=0; --echo End of 5.0 tests # # Bug22043: MySQL don't add "USE <DATABASE>" before "DROP PROCEDURE IF EXISTS" # connection master; --disable_warnings drop database if exists mysqltest; drop database if exists mysqltest2; --enable_warnings create database mysqltest; create database mysqltest2; use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); show binlog events in 'master-bin.000001' from 8657; --error ER_BAD_DB_ERROR create procedure `\\`.test() begin end; # Clean up drop database mysqltest; drop database mysqltest2; --echo End of 5.1 tests sql/sp.cc +0 −9 Original line number Diff line number Diff line Loading @@ -497,17 +497,10 @@ db_create_routine(THD *thd, int type, sp_head *sp) char definer[USER_HOST_BUFF_SIZE]; char old_db_buf[NAME_LEN+1]; LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; bool dbchanged; DBUG_ENTER("db_create_routine"); DBUG_PRINT("enter", ("type: %d name: %.*s",type,sp->m_name.length, sp->m_name.str)); if ((ret= sp_use_new_db(thd, sp->m_db, &old_db, 0, &dbchanged))) { ret= SP_NO_DB_ERROR; goto done; } if (!(table= open_proc_table_for_update(thd))) ret= SP_OPEN_TABLE_FAILED; else Loading Loading @@ -631,8 +624,6 @@ db_create_routine(THD *thd, int type, sp_head *sp) done: close_thread_tables(thd); if (dbchanged) (void) mysql_change_db(thd, old_db.str, 1); DBUG_RETURN(ret); } Loading sql/sql_parse.cc +24 −0 Original line number Diff line number Diff line Loading @@ -4384,6 +4384,30 @@ mysql_execute_command(THD *thd) DBUG_ASSERT(lex->sphead != 0); DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */ /* Verify that the database name is allowed, optionally lowercase it. */ if (check_db_name(lex->sphead->m_db.str)) { my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str); delete lex->sphead; lex->sphead= 0; goto error; } /* Check that a database with this name exists. */ if (check_db_dir_existence(lex->sphead->m_db.str)) { my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str); delete lex->sphead; lex->sphead= 0; goto error; } if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0, is_schema_db(lex->sphead->m_db.str))) { Loading Loading
mysql-test/r/rpl_sp.result +20 −0 Original line number Diff line number Diff line Loading @@ -468,4 +468,24 @@ drop table t1; set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0; End of 5.0 tests drop database if exists mysqltest; drop database if exists mysqltest2; create database mysqltest; create database mysqltest2; use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); show binlog events in 'master-bin.000001' from 8657; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 8657 Query 1 8760 drop database if exists mysqltest2 master-bin.000001 8760 Query 1 8853 create database mysqltest master-bin.000001 8853 Query 1 8948 create database mysqltest2 master-bin.000001 8948 Query 1 9045 use `mysqltest2`; create table t ( t integer ) master-bin.000001 9045 Query 1 9184 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end master-bin.000001 9184 Query 1 9279 use `mysqltest2`; insert into t values ( 1 ) create procedure `\\`.test() begin end; ERROR 42000: Unknown database '\\' drop database mysqltest; drop database mysqltest2; End of 5.1 tests
mysql-test/t/rpl_sp.test +22 −0 Original line number Diff line number Diff line Loading @@ -528,4 +528,26 @@ connection master; set global log_bin_trust_function_creators=0; --echo End of 5.0 tests # # Bug22043: MySQL don't add "USE <DATABASE>" before "DROP PROCEDURE IF EXISTS" # connection master; --disable_warnings drop database if exists mysqltest; drop database if exists mysqltest2; --enable_warnings create database mysqltest; create database mysqltest2; use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); show binlog events in 'master-bin.000001' from 8657; --error ER_BAD_DB_ERROR create procedure `\\`.test() begin end; # Clean up drop database mysqltest; drop database mysqltest2; --echo End of 5.1 tests
sql/sp.cc +0 −9 Original line number Diff line number Diff line Loading @@ -497,17 +497,10 @@ db_create_routine(THD *thd, int type, sp_head *sp) char definer[USER_HOST_BUFF_SIZE]; char old_db_buf[NAME_LEN+1]; LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; bool dbchanged; DBUG_ENTER("db_create_routine"); DBUG_PRINT("enter", ("type: %d name: %.*s",type,sp->m_name.length, sp->m_name.str)); if ((ret= sp_use_new_db(thd, sp->m_db, &old_db, 0, &dbchanged))) { ret= SP_NO_DB_ERROR; goto done; } if (!(table= open_proc_table_for_update(thd))) ret= SP_OPEN_TABLE_FAILED; else Loading Loading @@ -631,8 +624,6 @@ db_create_routine(THD *thd, int type, sp_head *sp) done: close_thread_tables(thd); if (dbchanged) (void) mysql_change_db(thd, old_db.str, 1); DBUG_RETURN(ret); } Loading
sql/sql_parse.cc +24 −0 Original line number Diff line number Diff line Loading @@ -4384,6 +4384,30 @@ mysql_execute_command(THD *thd) DBUG_ASSERT(lex->sphead != 0); DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */ /* Verify that the database name is allowed, optionally lowercase it. */ if (check_db_name(lex->sphead->m_db.str)) { my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str); delete lex->sphead; lex->sphead= 0; goto error; } /* Check that a database with this name exists. */ if (check_db_dir_existence(lex->sphead->m_db.str)) { my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str); delete lex->sphead; lex->sphead= 0; goto error; } if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0, is_schema_db(lex->sphead->m_db.str))) { Loading