summaryrefslogtreecommitdiff
path: root/sql/sp.cc
diff options
context:
space:
mode:
authorunknown <anozdrin/alik@ibm.opbmk>2007-08-30 20:06:19 +0400
committerunknown <anozdrin/alik@ibm.opbmk>2007-08-30 20:06:19 +0400
commit3edb630197ae42353905325e9d1c8e78d329c23a (patch)
tree4f3652996129fb156cf227aa8e3bc8dbc55ea5e5 /sql/sp.cc
parentffd0c6c1498f374592acabaf0f50857a87ed52e7 (diff)
downloadmariadb-git-3edb630197ae42353905325e9d1c8e78d329c23a.tar.gz
Cleanup-patch for BUG#25843: changing default database between
PREPARE and EXECUTE of statement breaks binlog. sql/sp.cc: - Polishing sp_use_new_db(): - renamed no_access_check to force_switch to be more adequate; - fixed comment; sql/sql_class.h: Polishing: fixed comment. sql/sql_db.cc: 1. Use mysql_change_db_impl() to reset current database instead of THD::set_db() in mysql_rm_db(). THD::set_db() does not take care of THD::db_access and database attributes (@@collation_database). 2. Polishing: add, fix comments.
Diffstat (limited to 'sql/sp.cc')
-rw-r--r--sql/sp.cc57
1 files changed, 32 insertions, 25 deletions
diff --git a/sql/sp.cc b/sql/sp.cc
index 7b69842669f..8655e520041 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -574,7 +574,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
we'll update it later in switch_query_ctx().
*/
- if ((ret= sp_use_new_db(thd, name->m_db, &old_db, 1, &dbchanged)))
+ if ((ret= sp_use_new_db(thd, name->m_db, &old_db, TRUE, &dbchanged)))
goto end;
thd->spcont= NULL;
@@ -2027,34 +2027,41 @@ create_string(THD *thd, String *buf,
-/*
+/**
Change the current database if needed.
- SYNOPSIS
- sp_use_new_db()
- thd thread handle
- new_db new database name (a string and its length)
- old_db [IN] str points to a buffer where to store the old
- database, length contains the size of the buffer
- [OUT] if old db was not NULL, its name is copied
- to the buffer pointed at by str and length is updated
- accordingly. Otherwise str[0] is set to '\0' and length
- is set to 0. The out parameter should be used only if
- the database name has been changed (see dbchangedp).
- dbchangedp [OUT] is set to TRUE if the current database is changed,
- FALSE otherwise. A database is not changed if the old
- name is the same as the new one, both names are empty,
- or an error has occurred.
-
- RETURN VALUE
- 0 success
- 1 access denied or out of memory (the error message is
- set in THD)
+ @param[in] thd thread handle
+ @param[in] new_db new database name
+ @param[in, out] old_db IN: str points to a buffer where to store
+ the old database, length contains the
+ size of the buffer
+ OUT: if old db was not NULL, its name is
+ copied to the buffer pointed at by str
+ and length is updated accordingly.
+ Otherwise str[0] is set to '\0' and
+ length is set to 0. The out parameter
+ should be used only if the database name
+ has been changed (see dbchangedp).
+ @param[in] force_switch Flag to mysql_change_db(). For more information,
+ see mysql_change_db() comment.
+ @param[out] dbchangedp is set to TRUE if the current database is
+ changed, FALSE otherwise. The current
+ database is not changed if the old name
+ is equal to the new one, both names are
+ empty, or an error has occurred.
+
+ @return Operation status.
+ @retval 0 on success
+ @retval 1 access denied or out of memory
+ (the error message is set in THD)
*/
int
-sp_use_new_db(THD *thd, LEX_STRING new_db, LEX_STRING *old_db,
- bool no_access_check, bool *dbchangedp)
+sp_use_new_db(THD *thd,
+ LEX_STRING new_db,
+ LEX_STRING *old_db,
+ bool force_switch,
+ bool *dbchangedp)
{
int ret;
DBUG_ENTER("sp_use_new_db");
@@ -2085,7 +2092,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, no_access_check);
+ ret= mysql_change_db(thd, &new_db, force_switch);
*dbchangedp= ret == 0;
DBUG_RETURN(ret);