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:
@ -916,3 +916,16 @@ ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
|
|||||||
DROP PROCEDURE bug13037_p1;
|
DROP PROCEDURE bug13037_p1;
|
||||||
DROP PROCEDURE bug13037_p2;
|
DROP PROCEDURE bug13037_p2;
|
||||||
DROP PROCEDURE bug13037_p3;
|
DROP PROCEDURE bug13037_p3;
|
||||||
|
create database mysqltest1;
|
||||||
|
create database mysqltest2;
|
||||||
|
use mysqltest1;
|
||||||
|
drop database mysqltest1;
|
||||||
|
create procedure mysqltest2.p1() select version();
|
||||||
|
create procedure p2() select version();
|
||||||
|
ERROR 3D000: No database selected
|
||||||
|
use mysqltest2;
|
||||||
|
show procedure status;
|
||||||
|
Db Name Type Definer Modified Created Security_type Comment
|
||||||
|
mysqltest2 p1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
|
||||||
|
drop database mysqltest2;
|
||||||
|
use test;
|
||||||
|
@ -1337,6 +1337,22 @@ DROP PROCEDURE bug13037_p1;
|
|||||||
DROP PROCEDURE bug13037_p2;
|
DROP PROCEDURE bug13037_p2;
|
||||||
DROP PROCEDURE bug13037_p3;
|
DROP PROCEDURE bug13037_p3;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug#14569 "editing a stored procedure kills mysqld-nt"
|
||||||
|
#
|
||||||
|
create database mysqltest1;
|
||||||
|
create database mysqltest2;
|
||||||
|
use mysqltest1;
|
||||||
|
drop database mysqltest1;
|
||||||
|
create procedure mysqltest2.p1() select version();
|
||||||
|
--error ER_NO_DB_ERROR
|
||||||
|
create procedure p2() select version();
|
||||||
|
use mysqltest2;
|
||||||
|
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
|
||||||
|
show procedure status;
|
||||||
|
drop database mysqltest2;
|
||||||
|
use test;
|
||||||
|
|
||||||
|
|
||||||
# BUG#NNNN: New bug synopsis
|
# BUG#NNNN: New bug synopsis
|
||||||
#
|
#
|
||||||
|
@ -1163,8 +1163,17 @@ bool mysql_change_db(THD *thd, const char *name, bool no_access_check)
|
|||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
x_free(thd->db);
|
x_free(thd->db);
|
||||||
thd->db=dbname; // THD::~THD will free this
|
if (dbname && dbname[0] == 0)
|
||||||
thd->db_length=db_length;
|
{
|
||||||
|
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
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
if (!no_access_check)
|
if (!no_access_check)
|
||||||
sctx->db_access= db_access;
|
sctx->db_access= db_access;
|
||||||
|
@ -4099,7 +4099,7 @@ end_with_restore_list:
|
|||||||
|
|
||||||
if (!lex->sphead->m_db.str || !lex->sphead->m_db.str[0])
|
if (!lex->sphead->m_db.str || !lex->sphead->m_db.str[0])
|
||||||
{
|
{
|
||||||
if (!thd->db || thd->db[0] == 0)
|
if (!thd->db)
|
||||||
{
|
{
|
||||||
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
|
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
|
||||||
delete lex->sphead;
|
delete lex->sphead;
|
||||||
|
Reference in New Issue
Block a user