mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Now database default character is changed during ALTER DATABASE
if the current db is being altered
This commit is contained in:
@ -36,7 +36,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
|
|||||||
Currently databse default charset is only stored there.
|
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;
|
register File file;
|
||||||
char buf[256]; // Should be enough
|
char buf[256]; // Should be enough
|
||||||
@ -72,7 +72,7 @@ exit:
|
|||||||
/*
|
/*
|
||||||
Load database options file:
|
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;
|
register File file;
|
||||||
char buf[256]="";
|
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;
|
register File file;
|
||||||
uint create_options = create_info ? create_info->options : 0;
|
uint create_options = create_info ? create_info->options : 0;
|
||||||
|
|
||||||
printf("alter database\n");
|
|
||||||
|
|
||||||
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
|
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
|
||||||
|
|
||||||
// do not alter database if another thread is holding read lock
|
// 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)))
|
if ((error=write_db_opt(thd,db,create_info,path)))
|
||||||
goto exit;
|
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 (!silent)
|
||||||
{
|
{
|
||||||
if (!thd->query)
|
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 *dbname=my_strdup((char*) name,MYF(MY_WME));
|
||||||
char path[FN_REFLEN];
|
char path[FN_REFLEN];
|
||||||
uint db_access;
|
uint db_access;
|
||||||
|
HA_CREATE_INFO create;
|
||||||
|
|
||||||
DBUG_ENTER("mysql_change_db");
|
DBUG_ENTER("mysql_change_db");
|
||||||
|
|
||||||
if (!dbname || !(db_length=strip_sp(dbname)))
|
if (!dbname || !(db_length=strip_sp(dbname)))
|
||||||
@ -553,8 +562,9 @@ bool mysql_change_db(THD *thd,const char *name)
|
|||||||
strcat(path,"/");
|
strcat(path,"/");
|
||||||
unpack_dirname(path,path);
|
unpack_dirname(path,path);
|
||||||
strcat(path,MY_DB_OPT_FILE);
|
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);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user