Commit 1d3d64d6 authored by unknown's avatar unknown

Fix for the bug #1209: SELECT DATABASE().

parent ca2ab353
......@@ -361,3 +361,16 @@ a b c d e f g h dd
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00
drop table t1, t2;
drop database if exists test_$1;
create database test_$1;
use test_$1;
select database();
database()
test_$1
drop database test_$1;
select database();
database()
NULL
select database();
database()
NULL
......@@ -260,3 +260,19 @@ select * from t2;
drop table t1, t2;
#
# Bug #1209
#
--disable_warnings
drop database if exists test_$1;
--enable_warnings
create database test_$1;
use test_$1;
select database();
drop database test_$1;
select database();
# Connect without a database
connect (user4,localhost,mysqltest_1,,*NO-ONE*);
select database();
......@@ -1454,8 +1454,8 @@ String *Item_func_database::val_str(String *str)
THD *thd= current_thd;
if (!thd->db)
{
str->length(0);
str->set_charset(system_charset_info);
null_value= 1;
return 0;
}
else
str->copy((const char*) thd->db,(uint) strlen(thd->db),system_charset_info);
......
......@@ -391,6 +391,8 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
exit:
start_waiting_global_read_lock(thd);
if (thd->db && !strcmp(thd->db, db))
thd->db= 0;
exit2:
VOID(pthread_mutex_unlock(&LOCK_mysql_create_db));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment