diff options
-rw-r--r-- | sql/sql_db.cc | 12 | ||||
-rw-r--r-- | sql/sql_table.cc | 4 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 4 |
3 files changed, 10 insertions, 10 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc index c2efd392495..517438d9203 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -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) { ulong length; - length= my_sprintf(buf,(buf, "default-character-set=%s\n", - (create && create->table_charset) ? - create->table_charset->name : "DEFAULT")); + CHARSET_INFO *cs= (create && create->table_charset) ? + create->table_charset : default_charset_info; + length= my_sprintf(buf,(buf, "default-character-set=%s\n", cs->name)); /* Error is written by my_write */ 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) uint nbytes; bzero((char*) create,sizeof(*create)); + create->table_charset= default_charset_info; if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0) { IO_CACHE cache; @@ -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)) { - 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); @@ -599,7 +601,7 @@ bool mysql_change_db(THD *thd, const char *name) strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE); 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; DBUG_RETURN(0); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c6fa4d25120..80ddad3a4d2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -461,9 +461,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, { if (!sql_field->charset) sql_field->charset = create_info->table_charset ? - create_info->table_charset : - thd->db_charset? thd->db_charset : - default_charset_info; + create_info->table_charset : thd->db_charset; switch (sql_field->sql_type) { case FIELD_TYPE_BLOB: diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7c7e5e024dd..739e3dd2685 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -839,7 +839,7 @@ create: bzero((char*) &lex->create_info,sizeof(lex->create_info)); lex->create_info.options=$2 | $4; 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; } create2 @@ -1445,7 +1445,7 @@ alter: lex->select_lex.db=lex->name=0; bzero((char*) &lex->create_info,sizeof(lex->create_info)); 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->alter_keys_onoff=LEAVE_AS_IS; lex->simple_alter=1; |