From 6a594ffd18f52b4bf825eed9714c94207235d22c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Mar 2007 21:55:01 +0400 Subject: Fix for BUG#25082: default database change on trigger execution breaks replication. When a stored routine is executed, we switch current database to the database, in which the routine has been created. When the stored routine finishes, we switch back to the original database. The problem was that if the original database does not exist (anymore) after routine execution, we raised an error. The fix is to report a warning, and switch to the NULL database. mysql-test/r/sp.result: Updated result file. mysql-test/t/sp.test: Added test case for BUG#25082. sql/mysql_priv.h: 1. Change mysql_change_db() prototype; 2. Polishing. sql/sp.cc: Polishing. sql/sp_head.cc: Polishing. sql/sql_db.cc: 1. Polishing. 2. Fix mysql_change_db(). sql/sql_parse.cc: Polishing. sql/sql_show.cc: Polishing. --- sql/sp.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sql/sp.cc') diff --git a/sql/sp.cc b/sql/sp.cc index 2bb13b02e14..506b0bcd92b 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -441,14 +441,14 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, { sp_head *sp= newlex.sphead; - if (dbchanged && (ret= mysql_change_db(thd, old_db.str, 1))) + if (dbchanged && (ret= mysql_change_db(thd, &old_db, TRUE))) goto end; delete sp; ret= SP_PARSE_ERROR; } else { - if (dbchanged && (ret= mysql_change_db(thd, old_db.str, 1))) + if (dbchanged && (ret= mysql_change_db(thd, &old_db, TRUE))) goto end; *sphp= newlex.sphead; (*sphp)->set_definer(&definer_user_name, &definer_host_name); @@ -1896,7 +1896,7 @@ sp_use_new_db(THD *thd, LEX_STRING new_db, LEX_STRING *old_db, DBUG_RETURN(0); } - ret= mysql_change_db(thd, new_db.str, no_access_check); + ret= mysql_change_db(thd, &new_db, no_access_check); *dbchangedp= ret == 0; DBUG_RETURN(ret); -- cgit v1.2.1