Commit 8d9d12d1 authored by unknown's avatar unknown

New syntax to change client collation:

SET COLLATION latin1
SET COLLATION 'latin1'
SET COLLATION DEFAULT

parent 64a7e9fd
...@@ -511,16 +511,55 @@ SHOW FIELDS FROM t1; ...@@ -511,16 +511,55 @@ SHOW FIELDS FROM t1;
Field Type Collation Null Key Default Extra Field Type Collation Null Key Default Extra
latin1_f char(32) latin1_bin YES NULL latin1_f char(32) latin1_bin YES NULL
SET NAMES 'latin1'; SET NAMES 'latin1';
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation latin1
SET NAMES latin1; SET NAMES latin1;
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation latin1
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation latin1
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A' charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1 2 1 latin1 latin1 2 1
SET NAMES latin1 COLLATE latin1_bin; SET NAMES latin1 COLLATE latin1_bin;
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation latin1_bin
SET NAMES 'latin1' COLLATE 'latin1_bin'; SET NAMES 'latin1' COLLATE 'latin1_bin';
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation latin1_bin
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A' charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_bin 2 0 latin1 latin1_bin 2 0
SET NAMES koi8r;
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation koi8r
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
koi8r koi8r 2 1
SET COLLATION 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'
koi8r koi8r_bin 2 0
SET COLLATION DEFAULT;
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation koi8r
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
koi8r koi8r 2 1
SET NAMES DEFAULT; SET NAMES DEFAULT;
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
client_collation latin1
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A' charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1 2 1 latin1 latin1 2 1
......
...@@ -128,12 +128,27 @@ SHOW CREATE TABLE t1; ...@@ -128,12 +128,27 @@ SHOW CREATE TABLE t1;
SHOW FIELDS FROM t1; SHOW FIELDS FROM t1;
SET NAMES 'latin1'; SET NAMES 'latin1';
SHOW VARIABLES LIKE 'client_collation';
SET NAMES latin1; SET NAMES latin1;
SHOW VARIABLES LIKE 'client_collation';
SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET NAMES latin1 COLLATE latin1_bin; SET NAMES latin1 COLLATE latin1_bin;
SHOW VARIABLES LIKE 'client_collation';
SET NAMES 'latin1' COLLATE 'latin1_bin'; SET NAMES 'latin1' COLLATE 'latin1_bin';
SHOW VARIABLES LIKE 'client_collation';
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;
SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET COLLATION DEFAULT;
SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET NAMES DEFAULT; SET NAMES DEFAULT;
SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
--error 1251 --error 1251
SET NAMES latin1 COLLATE koi8r; SET NAMES latin1 COLLATE koi8r;
......
...@@ -4224,7 +4224,6 @@ option_value: ...@@ -4224,7 +4224,6 @@ option_value:
{ {
THD* thd= YYTHD; THD* thd= YYTHD;
LEX *lex= &thd->lex; LEX *lex= &thd->lex;
system_variables vars= thd->variables;
CHARSET_INFO *cs= $2 ? $2 : thd->db_charset; CHARSET_INFO *cs= $2 ? $2 : thd->db_charset;
CHARSET_INFO *cl= $3 ? $3 : cs; CHARSET_INFO *cl= $3 ? $3 : cs;
...@@ -4241,6 +4240,35 @@ option_value: ...@@ -4241,6 +4240,35 @@ option_value:
find_sys_var("client_collation"), find_sys_var("client_collation"),
csname)); csname));
} }
| COLLATION_SYM collation_name_or_default
{
THD* thd= YYTHD;
LEX *lex= &thd->lex;
system_variables *vars= &thd->variables;
CHARSET_INFO *cs= vars->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 ((cl != cs) && strcmp(cs->csname,cl->csname))
{
net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
cl->name,cs->csname);
YYABORT;
}
Item_string *csname= 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"),
csname));
}
| PASSWORD equal text_or_password | PASSWORD equal text_or_password
{ {
THD *thd=YYTHD; THD *thd=YYTHD;
......
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