mirror of
https://github.com/MariaDB/server.git
synced 2025-01-28 01:34:17 +01:00
Now database default character is changed during ALTER DATABASE
if the current db is being altered
This commit is contained in:
parent
fce8822611
commit
e6a32a67ba
1 changed files with 16 additions and 6 deletions
|
@ -36,7 +36,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
|
|||
Currently databse default charset is only stored there.
|
||||
*/
|
||||
|
||||
static int write_db_opt(THD *thd, char *db, HA_CREATE_INFO *create, char *fn)
|
||||
static int write_db_opt(THD *thd,const char *db,HA_CREATE_INFO *create,char *fn)
|
||||
{
|
||||
register File file;
|
||||
char buf[256]; // Should be enough
|
||||
|
@ -72,7 +72,7 @@ exit:
|
|||
/*
|
||||
Load database options file:
|
||||
*/
|
||||
static int load_db_opt(THD *thd,char *fn)
|
||||
static int load_db_opt(THD *thd,const char *db,HA_CREATE_INFO *create,char *fn)
|
||||
{
|
||||
register File file;
|
||||
char buf[256]="";
|
||||
|
@ -217,8 +217,6 @@ int mysql_alter_db(THD *thd, char *db, HA_CREATE_INFO *create_info, bool silent)
|
|||
register File file;
|
||||
uint create_options = create_info ? create_info->options : 0;
|
||||
|
||||
printf("alter database\n");
|
||||
|
||||
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
|
||||
|
||||
// do not alter database if another thread is holding read lock
|
||||
|
@ -236,6 +234,15 @@ int mysql_alter_db(THD *thd, char *db, HA_CREATE_INFO *create_info, bool silent)
|
|||
if ((error=write_db_opt(thd,db,create_info,path)))
|
||||
goto exit;
|
||||
|
||||
/*
|
||||
Change options if current
|
||||
database is being altered
|
||||
*/
|
||||
if (thd->db && !strcmp(thd->db,db))
|
||||
{
|
||||
thd->db_charset= create_info ? create_info->table_charset : NULL;
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
if (!thd->query)
|
||||
|
@ -499,6 +506,8 @@ bool mysql_change_db(THD *thd,const char *name)
|
|||
char *dbname=my_strdup((char*) name,MYF(MY_WME));
|
||||
char path[FN_REFLEN];
|
||||
uint db_access;
|
||||
HA_CREATE_INFO create;
|
||||
|
||||
DBUG_ENTER("mysql_change_db");
|
||||
|
||||
if (!dbname || !(db_length=strip_sp(dbname)))
|
||||
|
@ -553,8 +562,9 @@ bool mysql_change_db(THD *thd,const char *name)
|
|||
strcat(path,"/");
|
||||
unpack_dirname(path,path);
|
||||
strcat(path,MY_DB_OPT_FILE);
|
||||
load_db_opt(thd,path);
|
||||
|
||||
bzero(&create,sizeof(create));
|
||||
load_db_opt(thd,name,&create,path);
|
||||
thd->db_charset=create.table_charset;
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue