summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbell@sanja.is.com.ua <>2003-04-05 21:51:03 +0300
committerbell@sanja.is.com.ua <>2003-04-05 21:51:03 +0300
commit4cecc44ce70d840333413c7f054fde37a9fe794b (patch)
tree28ffad83d798a5e488517b63c0f3e9d18ae4a18f
parentfa46807825911019c079fec95ae56af98e3eb00c (diff)
parentbbf710b35eb79608eb49a64b4fa168cb5722ab50 (diff)
downloadmariadb-git-4cecc44ce70d840333413c7f054fde37a9fe794b.tar.gz
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-in-4.1
-rw-r--r--mysql-test/r/ctype_collate.result4
-rw-r--r--mysql-test/r/variables.result12
-rw-r--r--mysql-test/t/ctype_collate.test4
-rw-r--r--mysql-test/t/variables.test8
-rw-r--r--sql/set_var.cc25
-rw-r--r--sql/set_var.h8
-rw-r--r--sql/sql_yacc.yy73
7 files changed, 49 insertions, 85 deletions
diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result
index c0af8840e64..0be2bf5f54b 100644
--- a/mysql-test/r/ctype_collate.result
+++ b/mysql-test/r/ctype_collate.result
@@ -546,14 +546,14 @@ client_collation koi8r_general_ci
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1
-SET COLLATION koi8r_bin;
+SET NAMES koi8r COLLATE koi8r_bin;
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation koi8r_bin
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1
-SET COLLATION DEFAULT;
+SET NAMES koi8r COLLATE DEFAULT;
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation koi8r_general_ci
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 0693eedf55a..b709d135ee1 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -155,18 +155,10 @@ set net_buffer_length=2000000000;
show variables like 'net_buffer_length';
Variable_name Value
net_buffer_length 1048576
-set GLOBAL character set cp1251_koi8;
-show global variables like "client_collation";
-Variable_name Value
-client_collation cp1251_bulgarian_ci
set character set cp1251_koi8;
show variables like "client_collation";
Variable_name Value
client_collation cp1251_bulgarian_ci
-set global character set default, session character set default;
-show variables like "client_collation";
-Variable_name Value
-client_collation latin1_swedish_ci
select @@timestamp>0;
@@timestamp>0
1
@@ -195,10 +187,6 @@ set GLOBAL table_type=DEFAULT;
Variable 'table_type' doesn't have a default value
set client_collation=UNKNOWN_CHARACTER_SET;
Unknown character set: 'UNKNOWN_CHARACTER_SET'
-set character set unknown;
-Unknown character set: 'unknown'
-set character set 0;
-Wrong argument type to variable 'client_collation'
set global autocommit=1;
Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL
select @@global.timestamp;
diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test
index e2631a06156..2740ca24eb3 100644
--- a/mysql-test/t/ctype_collate.test
+++ b/mysql-test/t/ctype_collate.test
@@ -143,10 +143,10 @@ SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET NAMES koi8r;
SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
-SET COLLATION koi8r_bin;
+SET NAMES koi8r COLLATE koi8r_bin;
SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
-SET COLLATION DEFAULT;
+SET NAMES koi8r COLLATE DEFAULT;
SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET NAMES DEFAULT;
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 7671b663738..bb94ab17b77 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -91,12 +91,8 @@ show variables like 'net_buffer_length';
set net_buffer_length=2000000000;
show variables like 'net_buffer_length';
-set GLOBAL character set cp1251_koi8;
-show global variables like "client_collation";
set character set cp1251_koi8;
show variables like "client_collation";
-set global character set default, session character set default;
-show variables like "client_collation";
select @@timestamp>0;
set @@rand_seed1=10000000,@@rand_seed2=1000000;
@@ -124,10 +120,6 @@ set SESSION query_cache_size=10000;
set GLOBAL table_type=DEFAULT;
--error 1115
set client_collation=UNKNOWN_CHARACTER_SET;
---error 1115
-set character set unknown;
---error 1232
-set character set 0;
--error 1228
set global autocommit=1;
--error 1228
diff --git a/sql/set_var.cc b/sql/set_var.cc
index a47fdbfb63f..127988b8c4e 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1175,7 +1175,7 @@ static my_old_conv old_conv[]=
{ NULL , NULL }
};
-static CHARSET_INFO *get_old_charset_by_name(const char *name)
+CHARSET_INFO *get_old_charset_by_name(const char *name)
{
my_old_conv *c;
@@ -1662,22 +1662,23 @@ int set_var_password::update(THD *thd)
int set_var_client_collation::check(THD *thd)
{
+ client_charset= client_charset ? client_charset : thd->db_charset;
+ client_collation= client_collation ? client_collation : client_charset;
+ if (!my_charset_same(client_charset, client_collation))
+ {
+ my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
+ client_collation->name, client_charset->csname);
+ return -1;
+ }
return 0;
}
int set_var_client_collation::update(THD *thd)
{
-#if 0
- if (var->type == OPT_GLOBAL)
- global_system_variables.thd_charset= var->save_result.charset;
- else
-#endif
- {
- thd->variables.thd_charset= client_collation;
- thd->variables.convert_result_charset= convert_result_charset;
- thd->protocol_simple.init(thd);
- thd->protocol_prep.init(thd);
- }
+ thd->variables.thd_charset= client_collation;
+ thd->variables.convert_result_charset= convert_result_charset;
+ thd->protocol_simple.init(thd);
+ thd->protocol_prep.init(thd);
return 0;
}
diff --git a/sql/set_var.h b/sql/set_var.h
index 54f773d40ff..7b2f9d5cb80 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -530,11 +530,14 @@ public:
class set_var_client_collation: public set_var_base
{
+ CHARSET_INFO *client_charset;
CHARSET_INFO *client_collation;
my_bool convert_result_charset;
public:
- set_var_client_collation(CHARSET_INFO *coll_arg ,my_bool conv_arg)
- :client_collation(coll_arg), convert_result_charset(conv_arg)
+ set_var_client_collation(CHARSET_INFO *cset_arg,
+ CHARSET_INFO *coll_arg ,my_bool conv_arg)
+ :client_charset(cset_arg), client_collation(coll_arg),
+ convert_result_charset(conv_arg)
{}
int check(THD *thd);
int update(THD *thd);
@@ -552,3 +555,4 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list);
void fix_delay_key_write(THD *thd, enum_var_type type);
extern sys_var_str sys_charset;
+CHARSET_INFO *get_old_charset_by_name(const char *old_name);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 05ebaf89e09..07325d9a1b0 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -646,6 +646,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
opt_collate
charset_name
charset_name_or_default
+ old_or_new_charset_name
+ old_or_new_charset_name_or_default
collation_name
collation_name_or_default
@@ -1354,6 +1356,24 @@ charset_name_or_default:
charset_name { $$=$1; }
| DEFAULT { $$=NULL; } ;
+
+old_or_new_charset_name:
+ ident_or_text
+ {
+ if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))) &&
+ !($$=get_old_charset_by_name($1.str)))
+ {
+ net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,$1.str);
+ YYABORT;
+ }
+ }
+ | BINARY { $$= &my_charset_bin; }
+ ;
+
+old_or_new_charset_name_or_default:
+ old_or_new_charset_name { $$=$1; }
+ | DEFAULT { $$=NULL; } ;
+
collation_name:
ident_or_text
{
@@ -1366,7 +1386,7 @@ collation_name:
opt_collate:
/* empty */ { $$=NULL; }
- | COLLATE_SYM collation_name { $$=$2; }
+ | COLLATE_SYM collation_name_or_default { $$=$2; }
;
collation_name_or_default:
@@ -4383,56 +4403,15 @@ option_value:
find_sys_var("tx_isolation"),
new Item_int((int32) $4)));
}
- | charset set_expr_or_default
+ | charset old_or_new_charset_name_or_default
{
- THD *thd= YYTHD;
- LEX *lex= &thd->lex;
- if (!$2)
- {
- CHARSET_INFO *cl= thd->db_charset;
- $2= new Item_string(cl->name, strlen(cl->name), &my_charset_latin1);
- }
- lex->var_list.push_back(new set_var(lex->option_type,
- find_sys_var("client_collation"),
- $2));
+ LEX *lex= Lex;
+ lex->var_list.push_back(new set_var_client_collation($2,NULL,1));
}
| NAMES_SYM charset_name_or_default opt_collate
{
- THD* thd= YYTHD;
- LEX *lex= &thd->lex;
- CHARSET_INFO *cs= $2 ? $2 : thd->db_charset;
- CHARSET_INFO *cl= $3 ? $3 : cs;
-
- if (!my_charset_same(cs,cl))
- {
- net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
- cl->name,cs->csname);
- YYABORT;
- }
- lex->var_list.push_back(new set_var_client_collation(cl,1));
- }
- | COLLATION_SYM collation_name_or_default
- {
- THD* thd= YYTHD;
- LEX *lex= &thd->lex;
- CHARSET_INFO *cs= thd->variables.thd_charset;
- CHARSET_INFO *cl= $2;
-
- if (!cl)
- {
- if (!(cl=get_charset_by_csname(cs->csname,MY_CS_PRIMARY,MYF(0))))
- {
- net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,"DEFAULT");
- YYABORT;
- }
- }
- else if (!my_charset_same(cs,cl))
- {
- net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
- cl->name,cs->csname);
- YYABORT;
- }
- lex->var_list.push_back(new set_var_client_collation(cl,1));
+ LEX *lex= Lex;
+ lex->var_list.push_back(new set_var_client_collation($2,$3,1));
}
| PASSWORD equal text_or_password
{