summaryrefslogtreecommitdiff
path: root/sql/sql_connect.cc
diff options
context:
space:
mode:
authorKristofer Pettersson <kristofer.pettersson@oracle.com>2011-03-11 15:24:42 +0100
committerKristofer Pettersson <kristofer.pettersson@oracle.com>2011-03-11 15:24:42 +0100
commit546bd8d261fb8e9c82cdc599074c1e4665c64c0a (patch)
treef6d5624d865e73fdac8e6751dcd1f9a8d71a950c /sql/sql_connect.cc
parent17e77a7e49c0359fa66d4bd0b7c43246728f2a09 (diff)
parent16ae38bd8025144e0e9b083239ad0ea13fb822aa (diff)
downloadmariadb-git-546bd8d261fb8e9c82cdc599074c1e4665c64c0a.tar.gz
automerge
Diffstat (limited to 'sql/sql_connect.cc')
-rw-r--r--sql/sql_connect.cc34
1 files changed, 29 insertions, 5 deletions
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 4c4f30600de..406998537e4 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -582,8 +582,23 @@ void reset_mqh(LEX_USER *lu, bool get_them= 0)
}
-void thd_init_client_charset(THD *thd, uint cs_number)
+/**
+ Set thread character set variables from the given ID
+
+ @param thd thread handle
+ @param cs_number character set and collation ID
+
+ @retval 0 OK; character_set_client, collation_connection and
+ character_set_results are set to the new value,
+ or to the default global values.
+
+ @retval 1 error, e.g. the given ID is not supported by parser.
+ Corresponding SQL error is sent.
+*/
+
+bool thd_init_client_charset(THD *thd, uint cs_number)
{
+ CHARSET_INFO *cs;
/*
Use server character set and collation if
- opt_character_set_client_handshake is not set
@@ -592,10 +607,10 @@ void thd_init_client_charset(THD *thd, uint cs_number)
- client character set doesn't exists in server
*/
if (!opt_character_set_client_handshake ||
- !(thd->variables.character_set_client= get_charset(cs_number, MYF(0))) ||
+ !(cs= get_charset(cs_number, MYF(0))) ||
!my_strcasecmp(&my_charset_latin1,
global_system_variables.character_set_client->name,
- thd->variables.character_set_client->name))
+ cs->name))
{
thd->variables.character_set_client=
global_system_variables.character_set_client;
@@ -606,10 +621,18 @@ void thd_init_client_charset(THD *thd, uint cs_number)
}
else
{
+ if (!is_supported_parser_charset(cs))
+ {
+ /* Disallow non-supported parser character sets: UCS2, UTF16, UTF32 */
+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "character_set_client",
+ cs->csname);
+ return true;
+ }
thd->variables.character_set_results=
thd->variables.collation_connection=
- thd->variables.character_set_client;
+ thd->variables.character_set_client= cs;
}
+ return false;
}
@@ -869,7 +892,8 @@ static int check_connection(THD *thd)
thd->client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16;
thd->max_client_packet_length= uint4korr(net->read_pos+4);
DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
- thd_init_client_charset(thd, (uint) net->read_pos[8]);
+ if (thd_init_client_charset(thd, (uint) net->read_pos[8]))
+ return 1;
thd->update_charset();
end= (char*) net->read_pos+32;
}