diff options
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r-- | sql/sql_db.cc | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc index b9da6ffd3f4..7a1fd091e7c 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -307,11 +307,19 @@ exit2: /* - Drop all tables in a database. + Drop all tables in a database and the database itself - db-name is already validated when we come here - If thd == 0, do not write any messages; This is useful in replication - when we want to remove a stale database before replacing it with the new one + SYNOPSIS + mysql_rm_db() + thd Thread handle + db Database name in the case given by user + It's already validated when we come here + if_exists Don't give error if database doesn't exists + silent Don't generate errors + + RETURN + 0 ok (Database dropped) + -1 Error generated */ @@ -319,7 +327,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) { long deleted=0; int error = 0; - char path[FN_REFLEN+16]; + char path[FN_REFLEN+16], tmp_db[NAME_LEN+1]; MY_DIR *dirp; DBUG_ENTER("mysql_rm_db"); @@ -351,6 +359,14 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) } goto exit; } + if (lower_case_table_names) + { + /* Convert database to lower case */ + strmov(tmp_db, db); + casedn_str(tmp_db); + db= tmp_db; + } + pthread_mutex_lock(&LOCK_open); remove_db_from_cache(db); pthread_mutex_unlock(&LOCK_open); @@ -426,7 +442,7 @@ exit2: /* Removes files with known extensions plus all found subdirectories that - are 2 digits (raid directories). + are 2 hex digits (raid directories). thd MUST be set when calling this function! */ @@ -451,8 +467,10 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, DBUG_PRINT("info",("Examining: %s", file->name)); /* Check if file is a raid directory */ - if (my_isdigit(&my_charset_latin1,file->name[0]) && - my_isdigit(&my_charset_latin1,file->name[1]) && + if ((my_isdigit(&my_charset_latin1, file->name[0]) || + (file->name[0] >= 'a' && file->name[0] <= 'f')) && + (my_isdigit(&my_charset_latin1, file->name[1]) || + (file->name[1] >= 'a' && file->name[1] <= 'f')) && !file->name[2] && !level) { char newpath[FN_REFLEN]; |