From 5b1bd43d4fb560c14117e0e3c9db4cb4ea844c30 Mon Sep 17 00:00:00 2001 From: jingxiaobing Date: Wed, 29 Aug 2018 21:31:09 +0800 Subject: [PATCH] fix bug: CREATE SHARDED TABLE; logging when creating VDB and table --- plugins/admin/admin-commands.c | 3 +++ src/network-mysqld.c | 2 +- src/network-mysqld.h | 2 +- src/sharding-config.c | 3 +++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/admin/admin-commands.c b/plugins/admin/admin-commands.c index a754584..8053ede 100644 --- a/plugins/admin/admin-commands.c +++ b/plugins/admin/admin-commands.c @@ -1546,6 +1546,7 @@ void admin_create_vdb(network_mysqld_con* con, int id, GPtrArray* partitions, gboolean ok = sharding_vdb_is_valid(vdb, g->backends->groups->len) && shard_conf_add_vdb(vdb); if (ok) { + g_message("Admin: %s", con->orig_sql->str); shard_conf_write_json(con->srv->config_manager); network_mysqld_con_send_ok(con->client); } else { @@ -1564,6 +1565,7 @@ void admin_create_sharded_table(network_mysqld_con* con, const char* schema, t->pkey = g_string_new(key); gboolean ok = shard_conf_add_sharded_table(t); if (ok) { + g_message("Admin: %s", con->orig_sql->str); shard_conf_write_json(con->srv->config_manager); network_mysqld_con_send_ok(con->client); } else { @@ -1729,6 +1731,7 @@ void admin_create_single_table(network_mysqld_con* con, const char* schema, { gboolean ok = shard_conf_add_single_table(schema, table, group); if (ok) { + g_message("Admin: %s", con->orig_sql->str); shard_conf_write_json(con->srv->config_manager); network_mysqld_con_send_ok_full(con->client, 1, 0, SERVER_STATUS_AUTOCOMMIT, 0); } else { diff --git a/src/network-mysqld.c b/src/network-mysqld.c index 6296301..738ddbd 100644 --- a/src/network-mysqld.c +++ b/src/network-mysqld.c @@ -422,7 +422,7 @@ network_mysqld_con_retry_timeout(network_mysqld_con *con) return timeout; } -int network_mysqld_con_clear_xa_env_when_not_expected(network_mysqld_con *con) +void network_mysqld_con_clear_xa_env_when_not_expected(network_mysqld_con *con) { con->dist_tran = 0; con->dist_tran_failed = 0; diff --git a/src/network-mysqld.h b/src/network-mysqld.h index 09e4ea8..1635fab 100644 --- a/src/network-mysqld.h +++ b/src/network-mysqld.h @@ -764,7 +764,7 @@ NETWORK_API void network_mysqld_con_handle(int event_fd, short events, void *use NETWORK_API int network_mysqld_queue_append(network_socket *sock, network_queue *queue, const char *data, size_t len); NETWORK_API int network_mysqld_queue_append_raw(network_socket *sock, network_queue *queue, GString *data); NETWORK_API int network_mysqld_queue_reset(network_socket *sock); -NETWORK_API int network_mysqld_con_clear_xa_env_when_not_expected(network_mysqld_con *con); +NETWORK_API void network_mysqld_con_clear_xa_env_when_not_expected(network_mysqld_con *con); NETWORK_API void network_connection_pool_create_conn(network_mysqld_con *con); NETWORK_API void network_connection_pool_create_conns(chassis *srv); diff --git a/src/sharding-config.c b/src/sharding-config.c index 941e405..53d8326 100644 --- a/src/sharding-config.c +++ b/src/sharding-config.c @@ -967,6 +967,8 @@ gboolean shard_conf_add_sharded_table(sharding_table_t* t) { sharding_vdb_t* vdb = shard_vdbs_get_by_id(shard_conf_vdbs, t->vdb_id); if (vdb) { + t->vdb_ref = vdb; + t->shard_key_type = vdb->key_type; return sharding_tables_add(t); } else { return FALSE; @@ -1052,6 +1054,7 @@ gboolean shard_conf_write_json(chassis_config_t* conf_manager) char* json_str = cJSON_Print(root); chassis_config_write_object(conf_manager, "sharding", json_str); + g_message("Update sharding.json"); cJSON_Delete(root); g_free(json_str); return TRUE;