Commit 96991914 authored by unknown's avatar unknown

Database default charset now works:

CREATE DATABASE dbname DEFAULT CHARACTERSET=latin1


sql/sql_class.cc:
  Database default charset
sql/sql_class.h:
  Database default charset
sql/sql_db.cc:
  Database default charset
sql/sql_table.cc:
  Database default charset
BitKeeper/etc/ignore:
  Added tests/client_test to the ignore list
parent 000828e0
......@@ -478,3 +478,4 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
tests/client_test
......@@ -103,6 +103,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
file_id = 0;
cond_count=0;
convert_set=0;
db_charset=default_charset_info;
mysys_var=0;
#ifndef DBUG_OFF
dbug_sentry=THD_SENTRY_MAGIC;
......
......@@ -473,6 +473,7 @@ public:
ulong slave_proxy_id;
NET* slave_net; // network connection from slave -> m.
my_off_t log_pos;
CHARSET_INFO *db_charset;
THD();
~THD();
......
......@@ -25,6 +25,8 @@
#include <direct.h>
#endif
#define MY_DB_OPT_FILE ".db.opt"
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
const char *db, const char *path,
uint level);
......@@ -82,12 +84,12 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, bool silent
strcat(path,"/");
unpack_dirname(path,path);
strcat(path,"db.opt");
strcat(path,MY_DB_OPT_FILE);
if ((file=my_create(path,CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0)
{
sprintf(path,"CREATE DATABASE %s DEFAULT CHARACTER SET=%s\n",db,
(create_info && create_info->table_charset)
? create_info->table_charset->name : "DEFAULT");
sprintf(path,"default-character-set=%s\n",
(create_info && create_info->table_charset) ?
create_info->table_charset->name : "DEFAULT");
if (my_write(file,(byte*) path,strlen(path),MYF(MY_NABP+MY_WME)))
{
......@@ -423,15 +425,44 @@ bool mysql_change_db(THD *thd,const char *name)
strcat(path,"/");
unpack_dirname(path,path);
strcat(path,"db.opt");
strcat(path,MY_DB_OPT_FILE);
if ((file=my_open(path,O_RDWR|O_BINARY,MYF(MY_WME))) >= 0)
{
int nbytes=my_read(file,(byte*) path,sizeof(path),MYF(0));
if ( nbytes >= 0 )
{
char *ln=path;
char *pe=path+nbytes;
path[nbytes]='\0';
// BAR TODO: parse create options
// and extract database default charset
for ( ln=path; ln<pe; )
{
char *le,*val;
for ( le=ln, val=0 ; le<pe ; le++ )
{
switch(le[0])
{
case '=':
le[0]='\0';
val=le+1;
le++;
break;
case '\r':
case '\n':
le[0]='\0';
le++;
for( ; (le[0]=='\r' || le[0]=='\n') ; le++);
if (!strcmp(ln,"default-character-set") && val && val[0])
{
thd->db_charset=get_charset_by_name(val, MYF(0));
}
goto cnt;
break;
}
}
cnt:
ln=le;
}
}
my_close(file,MYF(0));
}
......
......@@ -377,7 +377,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
auto_increment++;
if(!sql_field->charset)
sql_field->charset = create_info->table_charset ?
create_info->table_charset : default_charset_info;
create_info->table_charset :
thd->db_charset? thd->db_charset :
default_charset_info;
pos+=sql_field->pack_length;
}
if (auto_increment > 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