Skip to content

Commit

Permalink
support default charset when client connects to Atlas
Browse files Browse the repository at this point in the history
  • Loading branch information
Qihoo360 committed Dec 4, 2013
1 parent d5407fa commit d1c91ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.0.3
*支持客户端在连接时指定默认字符集

2.0.2
*检测线程只检测状态为down的DB
*处于事务状态的客户端退出时,Atlas销毁该客户端使用的连接
Expand Down
11 changes: 10 additions & 1 deletion plugins/proxy/proxy-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ typedef enum {

SQL_LOG_TYPE sql_log_type = OFF;

char* charset[64] = {NULL, "big5", NULL, NULL, NULL, NULL, NULL, NULL, "latin1", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "gb2312", NULL, NULL, NULL, "gbk", NULL, NULL, NULL, NULL, "utf8", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "binary"};

guint get_table_index(GPtrArray* tokens, gint* d, gint* t) {
*d = *t = -1;

Expand Down Expand Up @@ -898,7 +900,7 @@ NETWORK_MYSQLD_PLUGIN_PROTO(proxy_read_auth) {

con->client->response = auth;

g_string_assign_len(con->client->default_db, S(auth->database));
// g_string_assign_len(con->client->default_db, S(auth->database));

con->state = CON_STATE_SEND_AUTH_RESULT;

Expand All @@ -907,6 +909,13 @@ NETWORK_MYSQLD_PLUGIN_PROTO(proxy_read_auth) {
GString *expected_response = g_string_sized_new(20);
network_mysqld_proto_password_scramble(expected_response, S(con->challenge), S(hashed_password));
if (g_string_equal(expected_response, auth->response)) {
g_string_assign_len(recv_sock->default_db, S(auth->database));

char *client_charset = charset[auth->charset];
g_string_assign(recv_sock->charset_client, client_charset);
g_string_assign(recv_sock->charset_results, client_charset);
g_string_assign(recv_sock->charset_connection, client_charset);

network_mysqld_con_send_ok(recv_sock);
} else {
GString *error = g_string_sized_new(64);
Expand Down

0 comments on commit d1c91ed

Please sign in to comment.