Skip to content

Commit d1c91ed

Browse files
author
Qihoo360
committed
support default charset when client connects to Atlas
1 parent d5407fa commit d1c91ed

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.0.3
2+
*支持客户端在连接时指定默认字符集
3+
14
2.0.2
25
*检测线程只检测状态为down的DB
36
*处于事务状态的客户端退出时,Atlas销毁该客户端使用的连接

plugins/proxy/proxy-plugin.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ typedef enum {
193193

194194
SQL_LOG_TYPE sql_log_type = OFF;
195195

196+
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"};
197+
196198
guint get_table_index(GPtrArray* tokens, gint* d, gint* t) {
197199
*d = *t = -1;
198200

@@ -898,7 +900,7 @@ NETWORK_MYSQLD_PLUGIN_PROTO(proxy_read_auth) {
898900

899901
con->client->response = auth;
900902

901-
g_string_assign_len(con->client->default_db, S(auth->database));
903+
// g_string_assign_len(con->client->default_db, S(auth->database));
902904

903905
con->state = CON_STATE_SEND_AUTH_RESULT;
904906

@@ -907,6 +909,13 @@ NETWORK_MYSQLD_PLUGIN_PROTO(proxy_read_auth) {
907909
GString *expected_response = g_string_sized_new(20);
908910
network_mysqld_proto_password_scramble(expected_response, S(con->challenge), S(hashed_password));
909911
if (g_string_equal(expected_response, auth->response)) {
912+
g_string_assign_len(recv_sock->default_db, S(auth->database));
913+
914+
char *client_charset = charset[auth->charset];
915+
g_string_assign(recv_sock->charset_client, client_charset);
916+
g_string_assign(recv_sock->charset_results, client_charset);
917+
g_string_assign(recv_sock->charset_connection, client_charset);
918+
910919
network_mysqld_con_send_ok(recv_sock);
911920
} else {
912921
GString *error = g_string_sized_new(64);

0 commit comments

Comments
 (0)