mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-11-29 18:37:36 +08:00
Add option for charset checking
This commit is contained in:
parent
2a5dd205c1
commit
e96b75ae8b
@ -926,6 +926,20 @@ void admin_set_maintain(network_mysqld_con* con, int mode)
|
||||
network_mysqld_con_send_ok_full(con->client, affected, 0,2,0);
|
||||
}
|
||||
|
||||
void admin_set_charset_check(network_mysqld_con* con, int mode)
|
||||
{
|
||||
if (con->is_admin_client) {
|
||||
return;
|
||||
}
|
||||
|
||||
int affected = 0;
|
||||
if (con->srv->charset_check != mode) {
|
||||
con->srv->charset_check = mode;
|
||||
affected = 1;
|
||||
}
|
||||
network_mysqld_con_send_ok_full(con->client, affected, 0,2,0);
|
||||
}
|
||||
|
||||
void admin_show_maintain(network_mysqld_con* con)
|
||||
{
|
||||
if (con->is_admin_client) {
|
||||
@ -1668,6 +1682,7 @@ static struct sql_help_entry_t {
|
||||
{"delete allow_ip/deny_ip '<user>@<address>'", "delete address from white list of module", ALL_HELP},
|
||||
{"set reduce_conns (true|false)", "reduce idle connections if set to true", ALL_HELP},
|
||||
{"set maintain (true|false)", "close all client connections if set to true", ALL_HELP},
|
||||
{"set charset_check (true|false)", "check the client charset is equal to the default charset", ALL_HELP},
|
||||
{"refresh conns", "refresh all server connections", ALL_HELP},
|
||||
{"show maintain status", "show maintain status", ALL_HELP},
|
||||
{"show status [like '%pattern%']", "show select/update/insert/delete statistics", ALL_HELP},
|
||||
|
@ -23,6 +23,7 @@ void admin_acl_add_rule(network_mysqld_con *con, gboolean is_white, char *addr);
|
||||
void admin_acl_delete_rule(network_mysqld_con *con, gboolean is_white, char* ip);
|
||||
void admin_set_reduce_conns(network_mysqld_con* con, int mode);
|
||||
void admin_set_maintain(network_mysqld_con* con, int mode);
|
||||
void admin_set_charset_check(network_mysqld_con* con, int mode);
|
||||
void admin_show_maintain(network_mysqld_con* con);
|
||||
void admin_show_status(network_mysqld_con* con, const char* like);
|
||||
void admin_show_variables(network_mysqld_con* con, const char* like);
|
||||
|
@ -211,6 +211,9 @@ cmd ::= SET REDUCE_CONNS boolean(X) SEMI. {
|
||||
cmd ::= SET MAINTAIN boolean(X) SEMI. {
|
||||
admin_set_maintain(con, X);
|
||||
}
|
||||
cmd ::= SET CHARSET_CHECK boolean(X) SEMI. {
|
||||
admin_set_charset_check(con, X);
|
||||
}
|
||||
cmd ::= REFRESH_CONNS SEMI. {
|
||||
admin_set_server_conn_refresh(con);
|
||||
}
|
||||
|
@ -77,6 +77,7 @@
|
||||
"master" return TK_MASTER;
|
||||
"slave" return TK_SLAVE;
|
||||
"maintain" return TK_MAINTAIN;
|
||||
"charset_check" return TK_CHARSET_CHECK;
|
||||
"status" return TK_STATUS;
|
||||
"variables" return TK_VARIABLES;
|
||||
"conn_num" return TK_CONN_NUM;
|
||||
|
@ -816,6 +816,13 @@ adjust_charset(network_mysqld_con *con, mysqld_query_attr_t *query_attr)
|
||||
g_string_assign_len(con->server->charset, charset->str, charset->len);
|
||||
}
|
||||
|
||||
if (con->srv->charset_check) {
|
||||
if (strcmp(con->client->charset->str, con->srv->default_charset) != 0) {
|
||||
g_message("%s: client charset:%s, default charset:%s, client address:%s", G_STRLOC,
|
||||
con->client->charset->str, con->srv->default_charset, con->client->src->name->str);
|
||||
}
|
||||
}
|
||||
|
||||
if (!query_attr->charset_client_set) {
|
||||
if (!g_string_equal(con->client->charset_client, con->server->charset_client)) {
|
||||
if (con->client->charset_client->len > 0) {
|
||||
|
@ -1601,6 +1601,13 @@ check_and_set_attr_bitmap(network_mysqld_con *con)
|
||||
g_warning("%s: not support different sql modes", G_STRLOC);
|
||||
}
|
||||
|
||||
if (con->srv->charset_check) {
|
||||
if (strcmp(con->client->charset->str, con->srv->default_charset) != 0) {
|
||||
g_message("%s: client charset:%s, default charset:%s, client address:%s", G_STRLOC,
|
||||
con->client->charset->str, con->srv->default_charset, con->client->src->name->str);
|
||||
}
|
||||
}
|
||||
|
||||
if (!g_string_equal(con->client->charset, ss->server->charset)) {
|
||||
ss->attr_diff |= ATTR_DIF_CHARSET;
|
||||
con->unmatched_attribute |= ATTR_DIF_CHARSET;
|
||||
|
@ -139,6 +139,7 @@ struct chassis {
|
||||
unsigned int master_preferred;
|
||||
unsigned int is_manual_down;
|
||||
unsigned int is_reduce_conns;
|
||||
unsigned int charset_check;
|
||||
unsigned int xa_log_detailed;
|
||||
unsigned int check_slave_delay;
|
||||
int socketpair_mutex;
|
||||
|
Loading…
Reference in New Issue
Block a user