diff --git a/plugins/shard/shard-plugin.c b/plugins/shard/shard-plugin.c index 26ea0d9..e824628 100644 --- a/plugins/shard/shard-plugin.c +++ b/plugins/shard/shard-plugin.c @@ -199,6 +199,13 @@ check_backends_attr_changed(network_mysqld_con *con) return server_attr_changed; } +static void +network_mysqld_con_purify_sharding_plan(struct sharding_plan_t *sharding_plan) +{ + sharding_plan->modified_sql = NULL; + sharding_plan->is_modified = 0; +} + NETWORK_MYSQLD_PLUGIN_PROTO(proxy_read_query) { GQueue *chunks = con->client->recv_queue->chunks; @@ -214,6 +221,9 @@ NETWORK_MYSQLD_PLUGIN_PROTO(proxy_read_query) p.offset = 0; network_mysqld_con_reset_command_response_state(con); + if (con->sharding_plan) { + network_mysqld_con_purify_sharding_plan(con->sharding_plan); + } g_debug("%s: call network_mysqld_con_command_states_init", G_STRLOC); if (network_mysqld_con_command_states_init(con, &p)) { g_warning("%s: tracking mysql proto states failed", G_STRLOC); @@ -774,6 +784,15 @@ remove_ro_servers(network_mysqld_con *con) } } +static void +network_mysqld_con_set_sharding_plan(network_mysqld_con *con, sharding_plan_t *plan) +{ + if (con->sharding_plan) { + sharding_plan_free(con->sharding_plan); + } + con->sharding_plan = plan; +} + static int process_init_db_when_get_server_list(network_mysqld_con *con, sharding_plan_t *plan, int *rv, int *disp_flag) { diff --git a/src/network-mysqld.c b/src/network-mysqld.c index 34cad02..5035b67 100644 --- a/src/network-mysqld.c +++ b/src/network-mysqld.c @@ -5026,11 +5026,4 @@ check_and_create_conns_func(int fd, short what, void *arg) chassis_event_add_with_timeout(chas, &chas->auto_create_conns_event, &check_interval); } -void -network_mysqld_con_set_sharding_plan(network_mysqld_con *con, sharding_plan_t *plan) -{ - if (con->sharding_plan) { - sharding_plan_free(con->sharding_plan); - } - con->sharding_plan = plan; -} + diff --git a/src/network-mysqld.h b/src/network-mysqld.h index f194b6f..f495437 100644 --- a/src/network-mysqld.h +++ b/src/network-mysqld.h @@ -728,11 +728,6 @@ void network_mysqld_send_xa_start(network_socket *, const char *xid); NETWORK_API void network_mysqld_con_reset_command_response_state(network_mysqld_con *con); NETWORK_API void network_mysqld_con_reset_query_state(network_mysqld_con *con); -/** - * set groups, delete if already exists - */ -void network_mysqld_con_set_sharding_plan(network_mysqld_con *con, struct sharding_plan_t *); - /** * should be socket */