summaryrefslogtreecommitdiff
path: root/sql/sql_db.cc
diff options
context:
space:
mode:
authorunknown <SergeyV@selena.>2005-11-11 21:01:48 +0300
committerunknown <SergeyV@selena.>2005-11-11 21:01:48 +0300
commit1c677f8c559f244b72ff4f6f1c7528889af05f45 (patch)
tree07cb5eea931e8ec0d12a702586118a502ff860e3 /sql/sql_db.cc
parentcb38411696dfa0f98bdd1d90a99f34c3d930afd5 (diff)
downloadmariadb-git-1c677f8c559f244b72ff4f6f1c7528889af05f45.tar.gz
Fixes bug #14569. When no db is selected as current and we do create procedure db.sp()...
we changing current db temporarily and restore it when sp is created. however thd->db in this case becomes empty string rather than NULL and so all checks of thd->db == NULL will be false. So if after this we'll issue create procedure sp2()... without specifying db it will succeed and create sp with db=NULL, which causes mysqldto crash on show procedure status statement. This patch fixes the problem. mysql-test/r/sp-error.result: Result for bug #14569. mysql-test/t/sp-error.test: Test for bug #14569. sql/sql_db.cc: Fixes bug #14569. When no db is selected as current and we do create procedure db.sp()... we changing current db temporarily and restore it when sp is created. however thd->db in this case becomes empty string rather than NULL and so all checks of thd->db == NULL will be false. This patch fixes this issue. sql/sql_parse.cc: Fixes bug #14569. Reverted from initial patch to check thd->db for null values only.
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r--sql/sql_db.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index a5dabc8140c..bde6522a38b 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -1163,8 +1163,17 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
}
end:
x_free(thd->db);
- thd->db=dbname; // THD::~THD will free this
- thd->db_length=db_length;
+ if (dbname && dbname[0] == 0)
+ {
+ x_free(dbname);
+ thd->db= NULL;
+ thd->db_length= 0;
+ }
+ else
+ {
+ thd->db= dbname; // THD::~THD will free this
+ thd->db_length= db_length;
+ }
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!no_access_check)
sctx->db_access= db_access;