summaryrefslogtreecommitdiff
path: root/sql/set_var.cc
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-03-20 02:06:08 +0200
committerunknown <monty@narttu.mysql.fi>2003-03-20 02:06:08 +0200
commit97cd4fb127f4096f2196a71778a15c8183aa7784 (patch)
tree025fe4204ddb1d72e14a98b1df497f7329939ebd /sql/set_var.cc
parent161942e3cefd8923633e0a7b3b7a9860a95f6fbc (diff)
parentc2297fb5ecaf2e98b21ae8287535d0b7fbced34b (diff)
downloadmariadb-git-97cd4fb127f4096f2196a71778a15c8183aa7784.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into narttu.mysql.fi:/my/mysql-4.1 configure.in: Auto merged libmysqld/lib_sql.cc: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/lex.h: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysqld.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/slave.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_repl.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r--sql/set_var.cc74
1 files changed, 27 insertions, 47 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 4189543e70e..cb49ad603d9 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -105,7 +105,6 @@ sys_var_str sys_charset("character_set",
sys_update_charset,
sys_set_default_charset);
sys_var_client_collation sys_client_collation("client_collation");
-sys_var_thd_conv_charset sys_convert_charset("convert_character_set");
sys_var_bool_ptr sys_concurrent_insert("concurrent_insert",
&myisam_concurrent_insert);
sys_var_long_ptr sys_connect_timeout("connect_timeout",
@@ -338,7 +337,6 @@ sys_var *sys_variables[]=
&sys_client_collation,
&sys_concurrent_insert,
&sys_connect_timeout,
- &sys_convert_charset,
&sys_default_week_format,
&sys_delay_key_write,
&sys_delayed_insert_limit,
@@ -447,7 +445,6 @@ struct show_var_st init_vars[]= {
{sys_client_collation.name, (char*) &sys_client_collation, SHOW_SYS},
{sys_concurrent_insert.name,(char*) &sys_concurrent_insert, SHOW_SYS},
{sys_connect_timeout.name, (char*) &sys_connect_timeout, SHOW_SYS},
- {sys_convert_charset.name, (char*) &sys_convert_charset, SHOW_SYS},
{"datadir", mysql_real_data_home, SHOW_CHAR},
{"default_week_format", (char*) &sys_default_week_format, SHOW_SYS},
{sys_delay_key_write.name, (char*) &sys_delay_key_write, SHOW_SYS},
@@ -1134,56 +1131,38 @@ byte *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type)
}
-bool sys_var_thd_conv_charset::check(THD *thd, set_var *var)
-{
- CONVERT *tmp;
- char buff[80];
- String str(buff,sizeof(buff), system_charset_info), *res;
-
- if (!var->value) // Default value
- {
- var->save_result.convert= (var->type != OPT_GLOBAL ?
- global_system_variables.convert_set
- : (CONVERT*) 0);
- return 0;
- }
- if (!(res=var->value->val_str(&str)))
- res= &empty_string;
-
- if (!(tmp=get_convert_set(res->c_ptr())))
- {
- my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
- return 1;
- }
- var->save_result.convert=tmp; // Save for update
- return 0;
-}
+typedef struct old_names_map_st {
+ const char *old_name;
+ const char *new_name;
+} my_old_conv;
+static my_old_conv old_conv[]=
+{
+ { "cp1251_koi8" , "cp1251" },
+ { "cp1250_latin2" , "cp1250" },
+ { "kam_latin2" , "keybcs2" },
+ { "mac_latin2" , "MacRoman" },
+ { "macce_latin2" , "MacCE" },
+ { "pc2_latin2" , "pclatin2" },
+ { "vga_latin2" , "pclatin1" },
+ { "koi8_cp1251" , "koi8r" },
+ { "win1251ukr_koi8_ukr" , "win1251ukr" },
+ { "koi8_ukr_win1251ukr" , "koi8u" },
+ { NULL , NULL }
+};
-bool sys_var_thd_conv_charset::update(THD *thd, set_var *var)
+static CHARSET_INFO *get_old_charset_by_name(const char *name)
{
- if (var->type == OPT_GLOBAL)
- global_system_variables.convert_set= var->save_result.convert;
- else
+ my_old_conv *c;
+
+ for (c= old_conv; c->old_name; c++)
{
- thd->lex.convert_set= thd->variables.convert_set=
- var->save_result.convert;
- thd->protocol_simple.init(thd);
- thd->protocol_prep.init(thd);
+ if (!my_strcasecmp(&my_charset_latin1,name,c->old_name))
+ return get_charset_by_name(c->new_name,MYF(0));
}
- return 0;
+ return NULL;
}
-
-byte *sys_var_thd_conv_charset::value_ptr(THD *thd, enum_var_type type)
-{
- CONVERT *conv= ((type == OPT_GLOBAL) ?
- global_system_variables.convert_set :
- thd->variables.convert_set);
- return conv ? (byte*) conv->name : (byte*) "";
-}
-
-
bool sys_var_client_collation::check(THD *thd, set_var *var)
{
CHARSET_INFO *tmp;
@@ -1201,7 +1180,8 @@ bool sys_var_client_collation::check(THD *thd, set_var *var)
if (!(res=var->value->val_str(&str)))
res= &empty_string;
- if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0))))
+ if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0))) &&
+ !(tmp=get_old_charset_by_name(res->c_ptr())))
{
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
return 1;