Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
bbf710b3
Commit
bbf710b3
authored
Apr 05, 2003
by
mysql@home.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some optimization in SET NAMES
parent
e93e98c2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
85 deletions
+49
-85
mysql-test/r/ctype_collate.result
mysql-test/r/ctype_collate.result
+2
-2
mysql-test/r/variables.result
mysql-test/r/variables.result
+0
-12
mysql-test/t/ctype_collate.test
mysql-test/t/ctype_collate.test
+2
-2
mysql-test/t/variables.test
mysql-test/t/variables.test
+0
-8
sql/set_var.cc
sql/set_var.cc
+13
-12
sql/set_var.h
sql/set_var.h
+6
-2
sql/sql_yacc.yy
sql/sql_yacc.yy
+26
-47
No files found.
mysql-test/r/ctype_collate.result
View file @
bbf710b3
...
@@ -546,14 +546,14 @@ client_collation koi8r_general_ci
...
@@ -546,14 +546,14 @@ client_collation koi8r_general_ci
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_swedish_ci 3 1
latin1 latin1_swedish_ci 3 1
SET
COLLATION
koi8r_bin;
SET
NAMES koi8r COLLATE
koi8r_bin;
SHOW VARIABLES LIKE 'client_collation';
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
Variable_name Value
client_collation koi8r_bin
client_collation koi8r_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_swedish_ci 3 1
latin1 latin1_swedish_ci 3 1
SET
COLLATION
DEFAULT;
SET
NAMES koi8r COLLATE
DEFAULT;
SHOW VARIABLES LIKE 'client_collation';
SHOW VARIABLES LIKE 'client_collation';
Variable_name Value
Variable_name Value
client_collation koi8r_general_ci
client_collation koi8r_general_ci
...
...
mysql-test/r/variables.result
View file @
bbf710b3
...
@@ -155,18 +155,10 @@ set net_buffer_length=2000000000;
...
@@ -155,18 +155,10 @@ set net_buffer_length=2000000000;
show variables like 'net_buffer_length';
show variables like 'net_buffer_length';
Variable_name Value
Variable_name Value
net_buffer_length 1048576
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;
set character set cp1251_koi8;
show variables like "client_collation";
show variables like "client_collation";
Variable_name Value
Variable_name Value
client_collation cp1251_bulgarian_ci
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;
select @@timestamp>0;
@@timestamp>0
@@timestamp>0
1
1
...
@@ -195,10 +187,6 @@ set GLOBAL table_type=DEFAULT;
...
@@ -195,10 +187,6 @@ set GLOBAL table_type=DEFAULT;
Variable 'table_type' doesn't have a default value
Variable 'table_type' doesn't have a default value
set client_collation=UNKNOWN_CHARACTER_SET;
set client_collation=UNKNOWN_CHARACTER_SET;
Unknown character set: '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;
set global autocommit=1;
Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL
Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL
select @@global.timestamp;
select @@global.timestamp;
...
...
mysql-test/t/ctype_collate.test
View file @
bbf710b3
...
@@ -143,10 +143,10 @@ SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
...
@@ -143,10 +143,10 @@ SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET
NAMES
koi8r
;
SET
NAMES
koi8r
;
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
COLLATION
koi8r_bin
;
SET
NAMES
koi8r
COLLATE
koi8r_bin
;
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
COLLATION
DEFAULT
;
SET
NAMES
koi8r
COLLATE
DEFAULT
;
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
DEFAULT
;
SET
NAMES
DEFAULT
;
...
...
mysql-test/t/variables.test
View file @
bbf710b3
...
@@ -91,12 +91,8 @@ show variables like 'net_buffer_length';
...
@@ -91,12 +91,8 @@ show variables like 'net_buffer_length';
set
net_buffer_length
=
2000000000
;
set
net_buffer_length
=
2000000000
;
show
variables
like
'net_buffer_length'
;
show
variables
like
'net_buffer_length'
;
set
GLOBAL
character
set
cp1251_koi8
;
show
global
variables
like
"client_collation"
;
set
character
set
cp1251_koi8
;
set
character
set
cp1251_koi8
;
show
variables
like
"client_collation"
;
show
variables
like
"client_collation"
;
set
global
character
set
default
,
session
character
set
default
;
show
variables
like
"client_collation"
;
select
@@
timestamp
>
0
;
select
@@
timestamp
>
0
;
set
@@
rand_seed1
=
10000000
,
@@
rand_seed2
=
1000000
;
set
@@
rand_seed1
=
10000000
,
@@
rand_seed2
=
1000000
;
...
@@ -124,10 +120,6 @@ set SESSION query_cache_size=10000;
...
@@ -124,10 +120,6 @@ set SESSION query_cache_size=10000;
set
GLOBAL
table_type
=
DEFAULT
;
set
GLOBAL
table_type
=
DEFAULT
;
--
error
1115
--
error
1115
set
client_collation
=
UNKNOWN_CHARACTER_SET
;
set
client_collation
=
UNKNOWN_CHARACTER_SET
;
--
error
1115
set
character
set
unknown
;
--
error
1232
set
character
set
0
;
--
error
1228
--
error
1228
set
global
autocommit
=
1
;
set
global
autocommit
=
1
;
--
error
1228
--
error
1228
...
...
sql/set_var.cc
View file @
bbf710b3
...
@@ -1175,7 +1175,7 @@ static my_old_conv old_conv[]=
...
@@ -1175,7 +1175,7 @@ static my_old_conv old_conv[]=
{
NULL
,
NULL
}
{
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
;
my_old_conv
*
c
;
...
@@ -1662,22 +1662,23 @@ int set_var_password::update(THD *thd)
...
@@ -1662,22 +1662,23 @@ int set_var_password::update(THD *thd)
int
set_var_client_collation
::
check
(
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
;
return
0
;
}
}
int
set_var_client_collation
::
update
(
THD
*
thd
)
int
set_var_client_collation
::
update
(
THD
*
thd
)
{
{
#if 0
thd
->
variables
.
thd_charset
=
client_collation
;
if (var->type == OPT_GLOBAL)
thd
->
variables
.
convert_result_charset
=
convert_result_charset
;
global_system_variables.thd_charset= var->save_result.charset;
thd
->
protocol_simple
.
init
(
thd
);
else
thd
->
protocol_prep
.
init
(
thd
);
#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
);
}
return
0
;
return
0
;
}
}
...
...
sql/set_var.h
View file @
bbf710b3
...
@@ -530,11 +530,14 @@ class set_var_password: public set_var_base
...
@@ -530,11 +530,14 @@ class set_var_password: public set_var_base
class
set_var_client_collation
:
public
set_var_base
class
set_var_client_collation
:
public
set_var_base
{
{
CHARSET_INFO
*
client_charset
;
CHARSET_INFO
*
client_collation
;
CHARSET_INFO
*
client_collation
;
my_bool
convert_result_charset
;
my_bool
convert_result_charset
;
public:
public:
set_var_client_collation
(
CHARSET_INFO
*
coll_arg
,
my_bool
conv_arg
)
set_var_client_collation
(
CHARSET_INFO
*
cset_arg
,
:
client_collation
(
coll_arg
),
convert_result_charset
(
conv_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
check
(
THD
*
thd
);
int
update
(
THD
*
thd
);
int
update
(
THD
*
thd
);
...
@@ -552,3 +555,4 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list);
...
@@ -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
);
void
fix_delay_key_write
(
THD
*
thd
,
enum_var_type
type
);
extern
sys_var_str
sys_charset
;
extern
sys_var_str
sys_charset
;
CHARSET_INFO
*
get_old_charset_by_name
(
const
char
*
old_name
);
sql/sql_yacc.yy
View file @
bbf710b3
...
@@ -646,6 +646,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
...
@@ -646,6 +646,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
opt_collate
opt_collate
charset_name
charset_name
charset_name_or_default
charset_name_or_default
old_or_new_charset_name
old_or_new_charset_name_or_default
collation_name
collation_name
collation_name_or_default
collation_name_or_default
...
@@ -1354,6 +1356,24 @@ charset_name_or_default:
...
@@ -1354,6 +1356,24 @@ charset_name_or_default:
charset_name { $$=$1; }
charset_name { $$=$1; }
| DEFAULT { $$=NULL; } ;
| 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:
collation_name:
ident_or_text
ident_or_text
{
{
...
@@ -1366,7 +1386,7 @@ collation_name:
...
@@ -1366,7 +1386,7 @@ collation_name:
opt_collate:
opt_collate:
/* empty */ { $$=NULL; }
/* empty */ { $$=NULL; }
| COLLATE_SYM collation_name { $$=$2; }
| COLLATE_SYM collation_name
_or_default
{ $$=$2; }
;
;
collation_name_or_default:
collation_name_or_default:
...
@@ -4383,56 +4403,15 @@ option_value:
...
@@ -4383,56 +4403,15 @@ option_value:
find_sys_var("tx_isolation"),
find_sys_var("tx_isolation"),
new Item_int((int32) $4)));
new Item_int((int32) $4)));
}
}
| charset
set_expr
_or_default
| charset
old_or_new_charset_name
_or_default
{
{
THD *thd= YYTHD;
LEX *lex= Lex;
LEX *lex= &thd->lex;
lex->var_list.push_back(new set_var_client_collation($2,NULL,1));
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));
}
}
| NAMES_SYM charset_name_or_default opt_collate
| NAMES_SYM charset_name_or_default opt_collate
{
{
THD* thd= YYTHD;
LEX *lex= Lex;
LEX *lex= &thd->lex;
lex->var_list.push_back(new set_var_client_collation($2,$3,1));
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));
}
}
| PASSWORD equal text_or_password
| PASSWORD equal text_or_password
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment