Commit 638f8d12 authored by unknown's avatar unknown

DATABASE character set is never blank anymore

parent 139267a5
...@@ -60,9 +60,9 @@ static bool write_db_opt(const char *path, HA_CREATE_INFO *create) ...@@ -60,9 +60,9 @@ static bool write_db_opt(const char *path, HA_CREATE_INFO *create)
if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0)
{ {
ulong length; ulong length;
length= my_sprintf(buf,(buf, "default-character-set=%s\n", CHARSET_INFO *cs= (create && create->table_charset) ?
(create && create->table_charset) ? create->table_charset : default_charset_info;
create->table_charset->name : "DEFAULT")); length= my_sprintf(buf,(buf, "default-character-set=%s\n", cs->name));
/* Error is written by my_write */ /* Error is written by my_write */
if (!my_write(file,(byte*) buf, length, MYF(MY_NABP+MY_WME))) if (!my_write(file,(byte*) buf, length, MYF(MY_NABP+MY_WME)))
...@@ -98,6 +98,7 @@ static bool load_db_opt(const char *path, HA_CREATE_INFO *create) ...@@ -98,6 +98,7 @@ static bool load_db_opt(const char *path, HA_CREATE_INFO *create)
uint nbytes; uint nbytes;
bzero((char*) create,sizeof(*create)); bzero((char*) create,sizeof(*create));
create->table_charset= default_charset_info;
if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0) if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0)
{ {
IO_CACHE cache; IO_CACHE cache;
...@@ -278,7 +279,8 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) ...@@ -278,7 +279,8 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
*/ */
if (thd->db && !strcmp(thd->db,db)) if (thd->db && !strcmp(thd->db,db))
{ {
thd->db_charset= create_info ? create_info->table_charset : NULL; thd->db_charset= (create_info && create_info->table_charset) ?
create_info->table_charset : default_charset_info;
} }
mysql_update_log.write(thd,thd->query, thd->query_length); mysql_update_log.write(thd,thd->query, thd->query_length);
...@@ -599,7 +601,7 @@ bool mysql_change_db(THD *thd, const char *name) ...@@ -599,7 +601,7 @@ bool mysql_change_db(THD *thd, const char *name)
strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE); strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
load_db_opt(path, &create); load_db_opt(path, &create);
thd->db_charset=create.table_charset; thd->db_charset= create.table_charset ? create.table_charset : default_charset_info;
thd->variables.thd_charset=thd->db_charset ? thd->db_charset : default_charset_info; thd->variables.thd_charset=thd->db_charset ? thd->db_charset : default_charset_info;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -461,9 +461,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -461,9 +461,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
{ {
if (!sql_field->charset) if (!sql_field->charset)
sql_field->charset = create_info->table_charset ? sql_field->charset = create_info->table_charset ?
create_info->table_charset : create_info->table_charset : thd->db_charset;
thd->db_charset? thd->db_charset :
default_charset_info;
switch (sql_field->sql_type) { switch (sql_field->sql_type) {
case FIELD_TYPE_BLOB: case FIELD_TYPE_BLOB:
......
...@@ -839,7 +839,7 @@ create: ...@@ -839,7 +839,7 @@ create:
bzero((char*) &lex->create_info,sizeof(lex->create_info)); bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.options=$2 | $4; lex->create_info.options=$2 | $4;
lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type; lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type;
lex->create_info.table_charset=thd->db_charset?thd->db_charset:default_charset_info; lex->create_info.table_charset= thd->db_charset;
lex->name=0; lex->name=0;
} }
create2 create2
...@@ -1445,7 +1445,7 @@ alter: ...@@ -1445,7 +1445,7 @@ alter:
lex->select_lex.db=lex->name=0; lex->select_lex.db=lex->name=0;
bzero((char*) &lex->create_info,sizeof(lex->create_info)); bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= DB_TYPE_DEFAULT; lex->create_info.db_type= DB_TYPE_DEFAULT;
lex->create_info.table_charset=thd->db_charset?thd->db_charset:default_charset_info; lex->create_info.table_charset= thd->db_charset;
lex->create_info.row_type= ROW_TYPE_NOT_USED; lex->create_info.row_type= ROW_TYPE_NOT_USED;
lex->alter_keys_onoff=LEAVE_AS_IS; lex->alter_keys_onoff=LEAVE_AS_IS;
lex->simple_alter=1; lex->simple_alter=1;
......
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