mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user