diff options
author | unknown <kostja@bodhi.(none)> | 2007-07-05 02:20:32 +0400 |
---|---|---|
committer | unknown <kostja@bodhi.(none)> | 2007-07-05 02:20:32 +0400 |
commit | b1ec3b534d530807995955c1c249496b0912a906 (patch) | |
tree | e075072a888e58c0455a6e257bc19c035e9cb24a /sql/sql_db.cc | |
parent | c182dfa2406d827682811105a243e58fac16acee (diff) | |
download | mariadb-git-b1ec3b534d530807995955c1c249496b0912a906.tar.gz |
A fix and a teset case for Bug#28551 The warning
'No database selected' is reported when calling stored procedures
Remove the offending warning introduced by the fix for Bug
25082
This minimal patch relies on the intrinsic knowledge of the fact that
mysql_change_db is never called with 'force_switch' set to TRUE
when such a warning may be needed:
* every stored routine belongs to a database (unlike, e.g., a
user defined function, which does not), so if we're activating the
database of a stored routine, it can never be NULL.
Therefore, this branch is never called for activation.
* if we're restoring the 'old' current database after routine
execution is complete, we should not issue a warning, since it's OK to
call a routine without having previously selected the current database.
TODO: 'force_switch' is an ambiguous flag, since we do not actually
have to 'force' the switch in case of stored routines at all.
When we activate the routine's database, we should perform
all the checks as in case of 'use db', and so we already do (in this
case 'force_switch' is unused).
When we load a routine into cache, we should not use mysql_change_db
at all, since there it's enough to call thd->reset_db(). We
do it this way for triggers, but code for routines is different (wrongly).
TODO: bugs are lurking in replication, since it bypasses mysql_change_db
and calls thd->[re_]set_db to set the current database.
The latter does not change thd->db_charset, thd->sctx->db_access
and thd->variables.collation_database (and this may have nasty side
effects).
These todo items are to be addressed in a separate patch, if at all.
mysql-test/r/sp.result:
Update results (Bug#28551)
mysql-test/t/sp.test:
Add a test case (Bug#28551)
sql/sp.cc:
Remove an obsolete comment.
Replace a check with an assert.
sql/sql_db.cc:
Remove the offending warning introduced by the fix for Bug
25082
This minimal patch relies on the intrinsic knowledge of the fact that
mysql_change_db is never called with 'force_switch' set to TRUE
when such a warning may be needed.
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r-- | sql/sql_db.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 963457cc896..91b0c02d23b 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1240,10 +1240,10 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch) { if (force_switch) { - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, - ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR)); - - /* Change db to NULL. */ + /* + This can only happen when we restore the old db in THD after + execution of a routine is complete. Change db to NULL. + */ mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server); |