From 6c302207807fcd255f152d663014868dbde5dcea Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 30 Apr 2024 14:51:37 +1000 Subject: [PATCH 1/3] MDEV-26858 Spider: Remove dead code related to HandlerSocket Remove the dead-code, in Spider, which is related to the Spider's HandlerSocket support. The code has been disabled for a long time and it is unlikely that the code will be enabled. - rm all files under storage/spider/hs_client/ except hs_compat.h - rm storage/spider/spd_db_handlersocket.* - unifdef -UHS_HAS_SQLCOM -UHAVE_HANDLERSOCKET \ -m storage/spider/spd_* storage/spider/ha_spider.* storage/spider/hs_client/* - remove relevant files from storage/spider/CMakeLists.txt --- storage/spider/CMakeLists.txt | 5 +- storage/spider/ha_spider.cc | 1207 ---- storage/spider/ha_spider.h | 81 - storage/spider/hs_client/allocator.hpp | 43 - storage/spider/hs_client/auto_addrinfo.hpp | 49 - storage/spider/hs_client/auto_file.hpp | 67 - .../spider/hs_client/auto_ptrcontainer.hpp | 70 - storage/spider/hs_client/config.cpp | 286 - storage/spider/hs_client/config.hpp | 76 - storage/spider/hs_client/escape.cpp | 129 - storage/spider/hs_client/escape.hpp | 64 - storage/spider/hs_client/fatal.cpp | 44 - storage/spider/hs_client/fatal.hpp | 26 - storage/spider/hs_client/hstcpcli.cpp | 662 -- storage/spider/hs_client/hstcpcli.hpp | 93 - storage/spider/hs_client/mutex.hpp | 48 - storage/spider/hs_client/socket.cpp | 306 - storage/spider/hs_client/socket.hpp | 57 - storage/spider/hs_client/string_buffer.hpp | 146 - storage/spider/hs_client/string_ref.hpp | 106 - storage/spider/hs_client/string_util.cpp | 202 - storage/spider/hs_client/string_util.hpp | 51 - storage/spider/hs_client/thread.hpp | 84 - storage/spider/hs_client/util.hpp | 25 - storage/spider/spd_conn.cc | 772 -- storage/spider/spd_db_conn.cc | 1143 +-- storage/spider/spd_db_conn.h | 5 - storage/spider/spd_db_handlersocket.cc | 6311 ----------------- storage/spider/spd_db_handlersocket.h | 1091 --- storage/spider/spd_db_include.h | 175 - storage/spider/spd_db_mysql.cc | 261 - storage/spider/spd_db_mysql.h | 76 - storage/spider/spd_db_oracle.cc | 272 - storage/spider/spd_db_oracle.h | 76 - storage/spider/spd_direct_sql.cc | 251 +- storage/spider/spd_include.h | 125 - storage/spider/spd_param.cc | 185 - storage/spider/spd_param.h | 33 - storage/spider/spd_table.cc | 754 -- storage/spider/spd_table.h | 8 - storage/spider/spd_trx.cc | 281 +- 41 files changed, 20 insertions(+), 15726 deletions(-) delete mode 100644 storage/spider/hs_client/allocator.hpp delete mode 100644 storage/spider/hs_client/auto_addrinfo.hpp delete mode 100644 storage/spider/hs_client/auto_file.hpp delete mode 100644 storage/spider/hs_client/auto_ptrcontainer.hpp delete mode 100644 storage/spider/hs_client/config.cpp delete mode 100644 storage/spider/hs_client/config.hpp delete mode 100644 storage/spider/hs_client/escape.cpp delete mode 100644 storage/spider/hs_client/escape.hpp delete mode 100644 storage/spider/hs_client/fatal.cpp delete mode 100644 storage/spider/hs_client/fatal.hpp delete mode 100644 storage/spider/hs_client/hstcpcli.cpp delete mode 100644 storage/spider/hs_client/hstcpcli.hpp delete mode 100644 storage/spider/hs_client/mutex.hpp delete mode 100644 storage/spider/hs_client/socket.cpp delete mode 100644 storage/spider/hs_client/socket.hpp delete mode 100644 storage/spider/hs_client/string_buffer.hpp delete mode 100644 storage/spider/hs_client/string_ref.hpp delete mode 100644 storage/spider/hs_client/string_util.cpp delete mode 100644 storage/spider/hs_client/string_util.hpp delete mode 100644 storage/spider/hs_client/thread.hpp delete mode 100644 storage/spider/hs_client/util.hpp delete mode 100644 storage/spider/spd_db_handlersocket.cc delete mode 100644 storage/spider/spd_db_handlersocket.h diff --git a/storage/spider/CMakeLists.txt b/storage/spider/CMakeLists.txt index 397478bfc40..11304d05b18 100644 --- a/storage/spider/CMakeLists.txt +++ b/storage/spider/CMakeLists.txt @@ -17,10 +17,7 @@ SET(SPIDER_SOURCES spd_param.cc spd_sys_table.cc spd_trx.cc spd_db_conn.cc spd_conn.cc spd_table.cc spd_direct_sql.cc spd_udf.cc spd_ping_table.cc spd_copy_tables.cc spd_i_s.cc spd_malloc.cc ha_spider.cc spd_udf.def - spd_db_mysql.cc spd_db_handlersocket.cc spd_db_oracle.cc - spd_group_by_handler.cc spd_db_include.cc - hs_client/config.cpp hs_client/escape.cpp hs_client/fatal.cpp - hs_client/hstcpcli.cpp hs_client/socket.cpp hs_client/string_util.cpp + spd_db_mysql.cc spd_db_oracle.cc spd_group_by_handler.cc spd_db_include.cc ) IF(DEFINED ENV{ORACLE_HOME}) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index bdf2470f6cb..485b98eec84 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -71,10 +71,6 @@ ha_spider::ha_spider( conn_keys = NULL; spider_thread_id = 0; trx_conn_adjustment = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - trx_hs_r_conn_adjustment = 0; - trx_hs_w_conn_adjustment = 0; -#endif search_link_query_id = 0; #ifdef WITH_PARTITION_STORAGE_ENGINE partition_handler = NULL; @@ -104,14 +100,6 @@ ha_spider::ha_spider( use_pre_action = FALSE; #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_pushed_ret_fields_num = MAX_FIELDS; - hs_pushed_ret_fields = NULL; - hs_pushed_ret_fields_size = 0; - hs_increment = FALSE; - hs_decrement = FALSE; - hs_pushed_strref_num = 0; -#endif #endif #ifdef HA_CAN_BULK_ACCESS is_bulk_access_clone = FALSE; @@ -134,16 +122,10 @@ ha_spider::ha_spider( result_list.insert_sqls = NULL; result_list.update_sqls = NULL; result_list.tmp_sqls = NULL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_result_buf = NULL; -#endif result_list.tmp_tables_created = FALSE; result_list.bgs_working = FALSE; result_list.direct_order_limit = FALSE; result_list.direct_limit_offset = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_has_result = FALSE; -#endif result_list.set_split_read = FALSE; result_list.insert_dup_update_pushdown = FALSE; result_list.tmp_pos_row_first = NULL; @@ -174,10 +156,6 @@ ha_spider::ha_spider( conn_keys = NULL; spider_thread_id = 0; trx_conn_adjustment = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - trx_hs_r_conn_adjustment = 0; - trx_hs_w_conn_adjustment = 0; -#endif search_link_query_id = 0; #ifdef WITH_PARTITION_STORAGE_ENGINE partition_handler = NULL; @@ -207,14 +185,6 @@ ha_spider::ha_spider( use_pre_action = FALSE; #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_pushed_ret_fields_num = MAX_FIELDS; - hs_pushed_ret_fields = NULL; - hs_pushed_ret_fields_size = 0; - hs_increment = FALSE; - hs_decrement = FALSE; - hs_pushed_strref_num = 0; -#endif #endif #ifdef HA_CAN_BULK_ACCESS is_bulk_access_clone = FALSE; @@ -237,16 +207,10 @@ ha_spider::ha_spider( result_list.insert_sqls = NULL; result_list.update_sqls = NULL; result_list.tmp_sqls = NULL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_result_buf = NULL; -#endif result_list.tmp_tables_created = FALSE; result_list.bgs_working = FALSE; result_list.direct_order_limit = FALSE; result_list.direct_limit_offset = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_has_result = FALSE; -#endif result_list.set_split_read = FALSE; result_list.insert_dup_update_pushdown = FALSE; result_list.tmp_pos_row_first = NULL; @@ -746,25 +710,8 @@ int ha_spider::close() delete [] result_list.tmp_sqls; result_list.tmp_sqls = NULL; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (result_list.hs_result_buf) - { - delete result_list.hs_result_buf; - result_list.hs_result_buf = NULL; - } -#endif spider_free_share(share); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if (hs_pushed_ret_fields) - { - spider_free(spider_current_trx, hs_pushed_ret_fields, MYF(0)); - hs_pushed_ret_fields = NULL; - hs_pushed_ret_fields_size = 0; - } -#endif -#endif is_clone = FALSE; pt_clone_source_handler = NULL; share = NULL; @@ -783,84 +730,6 @@ int ha_spider::check_access_kind_for_connection( conn_kinds = 0; switch (wide_handler->sql_command) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - case SQLCOM_HS_READ: - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - if (!write_request) - { - DBUG_PRINT("info",("spider spider_use_hs_read=%d", - spider_param_use_hs_read(thd, share->use_hs_reads[roop_count]))); - DBUG_PRINT("info",("spider use_hs_reads[%d]=%ld", roop_count, - share->use_hs_reads[roop_count])); - if (spider_param_use_hs_read(thd, share->use_hs_reads[roop_count])) - { - DBUG_PRINT("info",("spider set %d to HS_READ", roop_count)); - conn_kinds |= SPIDER_CONN_KIND_HS_READ; - conn_kind[roop_count] = SPIDER_CONN_KIND_HS_READ; - } else { - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - } else if (share->hs_write_to_reads[roop_count]) - { - DBUG_PRINT("info",("spider spider_use_hs_write=%d", - spider_param_use_hs_write(thd, share->use_hs_writes[roop_count]))); - DBUG_PRINT("info",("spider use_hs_write[%d]=%ld", roop_count, - share->use_hs_writes[roop_count])); - if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) - { - DBUG_PRINT("info",("spider set %d to HS_WRITE", roop_count)); - conn_kinds |= SPIDER_CONN_KIND_HS_READ; - conn_kind[roop_count] = SPIDER_CONN_KIND_HS_READ; - } else { - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - } else { - DBUG_PRINT("info",("spider spider_use_hs_write=%d", - spider_param_use_hs_write(thd, share->use_hs_writes[roop_count]))); - DBUG_PRINT("info",("spider use_hs_write[%d]=%ld", roop_count, - share->use_hs_writes[roop_count])); - if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) - { - DBUG_PRINT("info",("spider set %d to HS_WRITE", roop_count)); - conn_kinds |= SPIDER_CONN_KIND_HS_WRITE; - conn_kind[roop_count] = SPIDER_CONN_KIND_HS_WRITE; - } else { - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - } - } - break; - case SQLCOM_HS_UPDATE: - case SQLCOM_HS_DELETE: - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - break; - case SQLCOM_HS_INSERT: - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - DBUG_PRINT("info",("spider spider_use_hs_write=%d", - spider_param_use_hs_write(thd, share->use_hs_writes[roop_count]))); - DBUG_PRINT("info",("spider use_hs_write[%d]=%ld", roop_count, - share->use_hs_writes[roop_count])); - if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) - { - DBUG_PRINT("info",("spider set %d to HS_WRITE", roop_count)); - conn_kinds |= SPIDER_CONN_KIND_HS_WRITE; - conn_kind[roop_count] = SPIDER_CONN_KIND_HS_WRITE; - } else { - conn_kinds |= SPIDER_CONN_KIND_MYSQL; - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - } - } - break; -#endif case SQLCOM_UPDATE: case SQLCOM_UPDATE_MULTI: case SQLCOM_DELETE: @@ -873,12 +742,6 @@ int ha_spider::check_access_kind_for_connection( } break; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_strs_pos(SPIDER_SQL_TYPE_UPDATE_HS))) - { - DBUG_RETURN(error_num); - } -#endif if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE))) { DBUG_RETURN(error_num); @@ -913,17 +776,9 @@ void ha_spider::check_access_kind( DBUG_PRINT("info",("spider sql_command=%u", wide_handler->sql_command)); DBUG_PRINT("info",("spider thd->query_id=%lld", thd->query_id)); #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#ifdef HS_HAS_SQLCOM - if (wide_handler->sql_command == SQLCOM_HS_UPDATE) - wide_handler->update_request = TRUE; - else -#endif wide_handler->update_request = FALSE; #else if ( -#ifdef HS_HAS_SQLCOM - wide_handler->sql_command == SQLCOM_HS_UPDATE || -#endif wide_handler->sql_command == SQLCOM_UPDATE || wide_handler->sql_command == SQLCOM_UPDATE_MULTI || /* for triggers */ @@ -1006,9 +861,6 @@ THR_LOCK_DATA **ha_spider::store_lock( { case SQLCOM_SELECT: case SQLCOM_HA_READ: -#ifdef HS_HAS_SQLCOM - case SQLCOM_HS_READ: -#endif if (lock_type == TL_READ_WITH_SHARED_LOCKS) wide_handler->lock_mode = 1; else if (lock_type <= TL_READ_NO_INSERT) @@ -1021,9 +873,6 @@ THR_LOCK_DATA **ha_spider::store_lock( break; case SQLCOM_UPDATE: case SQLCOM_UPDATE_MULTI: -#ifdef HS_HAS_SQLCOM - case SQLCOM_HS_UPDATE: -#endif case SQLCOM_CREATE_TABLE: case SQLCOM_INSERT: case SQLCOM_INSERT_SELECT: @@ -1032,10 +881,6 @@ THR_LOCK_DATA **ha_spider::store_lock( case SQLCOM_REPLACE: case SQLCOM_REPLACE_SELECT: case SQLCOM_DELETE_MULTI: -#ifdef HS_HAS_SQLCOM - case SQLCOM_HS_INSERT: - case SQLCOM_HS_DELETE: -#endif if (lock_type >= TL_READ && lock_type <= TL_READ_NO_INSERT) { wide_handler->lock_mode = -2; @@ -1478,13 +1323,6 @@ int ha_spider::reset() ft_count = 0; ft_init_without_index_init = FALSE; sql_kinds = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - hs_pushed_ret_fields_num = MAX_FIELDS; - hs_increment = FALSE; - hs_decrement = FALSE; -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; #endif @@ -1492,10 +1330,6 @@ int ha_spider::reset() result_list.have_sql_kind_backup = FALSE; result_list.direct_order_limit = FALSE; result_list.direct_limit_offset = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num2 = reset_hs_strs(SPIDER_SQL_TYPE_UPDATE_HS))) - error_num = error_num2; -#endif result_list.set_split_read = FALSE; result_list.insert_dup_update_pushdown = FALSE; use_spatial_index = FALSE; @@ -1687,12 +1521,6 @@ int ha_spider::index_init( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_sql(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif result_list.check_direct_order_limit = FALSE; prev_index_rnd_init = SPD_INDEX; DBUG_RETURN(0); @@ -1801,10 +1629,6 @@ int ha_spider::index_read_map_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -1892,18 +1716,6 @@ int ha_spider::index_read_map_internal( DBUG_RETURN(error_num); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & SPIDER_SQL_KIND_HS) - { - if ((error_num = append_limit_hs_part( - result_list.internal_offset, - result_list.limit_num, - SPIDER_SQL_TYPE_SELECT_HS))) - { - DBUG_RETURN(error_num); - } - } -#endif int roop_start, roop_end, lock_mode, link_ok; lock_mode = spider_conn_lock_mode(this); @@ -1964,10 +1776,6 @@ int ha_spider::index_read_map_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -1975,15 +1783,6 @@ int ha_spider::index_read_map_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -2217,19 +2016,7 @@ int ha_spider::index_read_map( conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - } -#endif if ((tmp_error_num = spider_db_bulk_store_result(this, conn, roop_count, (roop_count != link_ok)))) { @@ -2303,14 +2090,7 @@ int ha_spider::index_read_last_map_internal( spider_db_free_one_result_for_start_next(this); */ if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ( - result_list.hs_has_result || -#endif result_list.current -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) -#endif && (error_num = spider_db_free_result(this, FALSE)) ) @@ -2323,10 +2103,6 @@ int ha_spider::index_read_last_map_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -2462,10 +2238,6 @@ int ha_spider::index_read_last_map_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -2473,15 +2245,6 @@ int ha_spider::index_read_last_map_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -2782,9 +2545,6 @@ int ha_spider::index_first_internal( pt_clone_source_handler->pt_clone_last_searcher = this; } if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_has_result || -#endif sql_is_empty(SPIDER_SQL_TYPE_HANDLER) || sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL) ) { @@ -2934,10 +2694,6 @@ int ha_spider::index_first_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -2945,15 +2701,6 @@ int ha_spider::index_first_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -3172,9 +2919,6 @@ int ha_spider::index_last_internal( pt_clone_source_handler->pt_clone_last_searcher = this; } if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - result_list.hs_has_result || -#endif sql_is_empty(SPIDER_SQL_TYPE_HANDLER) || sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL) ) { @@ -3324,10 +3068,6 @@ int ha_spider::index_last_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -3335,15 +3075,6 @@ int ha_spider::index_last_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -3634,10 +3365,6 @@ int ha_spider::read_range_first_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -3774,10 +3501,6 @@ int ha_spider::read_range_first_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -3785,15 +3508,6 @@ int ha_spider::read_range_first_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -4020,26 +3734,11 @@ void ha_spider::reset_no_where_cond() { uint roop_count; DBUG_ENTER("ha_spider::reset_no_where_cond"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & (SPIDER_SQL_KIND_SQL | SPIDER_SQL_KIND_HANDLER)) - { -#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { dbton_handler[share->use_sql_dbton_ids[roop_count]]->no_where_cond = FALSE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (sql_kinds & SPIDER_SQL_KIND_HS) - { - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_handler[share->use_hs_dbton_ids[roop_count]]->no_where_cond = - FALSE; - } - } -#endif DBUG_VOID_RETURN; } @@ -4047,10 +3746,6 @@ bool ha_spider::check_no_where_cond() { uint roop_count; DBUG_ENTER("ha_spider::check_no_where_cond"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & (SPIDER_SQL_KIND_SQL | SPIDER_SQL_KIND_HANDLER)) - { -#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { if (dbton_handler[share->use_sql_dbton_ids[roop_count]]->no_where_cond) @@ -4058,19 +3753,6 @@ bool ha_spider::check_no_where_cond() DBUG_RETURN(TRUE); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (sql_kinds & SPIDER_SQL_KIND_HS) - { - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - if (dbton_handler[share->use_hs_dbton_ids[roop_count]]->no_where_cond) - { - DBUG_RETURN(TRUE); - } - } - } -#endif DBUG_RETURN(FALSE); } @@ -4272,10 +3954,6 @@ int ha_spider::read_multi_range_first_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif result_list.desc_flg = FALSE; #ifdef HA_MRR_USE_DEFAULT_IMPL result_list.sorted = mrr_is_output_sorted; @@ -4437,10 +4115,6 @@ int ha_spider::read_multi_range_first_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -4448,15 +4122,6 @@ int ha_spider::read_multi_range_first_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -4786,9 +4451,6 @@ int ha_spider::read_multi_range_first_internal( result_list.tmp_reuse_sql = FALSE; if (bka_mode && have_multi_range && -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - !(sql_kinds & SPIDER_SQL_KIND_HS) && -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL SPIDER_TEST(mrr_cur_range.range_flag & EQ_RANGE) #else @@ -5233,10 +4895,6 @@ int ha_spider::read_multi_range_first_internal( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -5244,15 +4902,6 @@ int ha_spider::read_multi_range_first_internal( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -5560,10 +5209,6 @@ int ha_spider::read_multi_range_first_internal( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL #else multi_range_ranges = multi_range_curr; @@ -5885,10 +5530,6 @@ int ha_spider::read_multi_range_next( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -5896,15 +5537,6 @@ int ha_spider::read_multi_range_next( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -6213,10 +5845,6 @@ int ha_spider::read_multi_range_next( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL #else multi_range_ranges = multi_range_curr; @@ -6253,9 +5881,6 @@ int ha_spider::read_multi_range_next( result_list.tmp_reuse_sql = FALSE; if (bka_mode && have_multi_range && -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - !(sql_kinds & SPIDER_SQL_KIND_HS) && -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL SPIDER_TEST(mrr_cur_range.range_flag & EQ_RANGE) #else @@ -6684,10 +6309,6 @@ int ha_spider::read_multi_range_next( } else { #endif ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = conns[roop_count]; if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) { @@ -6695,15 +6316,6 @@ int ha_spider::read_multi_range_next( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - conn = hs_r_conns[roop_count]; - else - conn = hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = @@ -7005,12 +6617,6 @@ int ha_spider::read_multi_range_next( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - (error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS)) - ) - DBUG_RETURN(error_num); -#endif #ifdef HA_MRR_USE_DEFAULT_IMPL #else multi_range_ranges = multi_range_curr; @@ -7125,13 +6731,6 @@ int ha_spider::rnd_init( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - (error_num = reset_hs_sql(SPIDER_SQL_TYPE_SELECT_HS)) || - (error_num = reset_hs_keys(SPIDER_SQL_TYPE_SELECT_HS)) - ) - DBUG_RETURN(error_num); -#endif result_list.check_direct_order_limit = FALSE; } } @@ -7203,10 +6802,6 @@ int ha_spider::rnd_next_internal( if (rnd_scan_and_first) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & SPIDER_SQL_KIND_HS) - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -9210,9 +8805,6 @@ ulonglong ha_spider::table_flags() const HA_CAN_TABLE_CONDITION_PUSHDOWN | #endif #ifdef HA_CAN_BULK_ACCESS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (support_bulk_access_hs() ? HA_CAN_BULK_ACCESS : 0) | -#endif #endif SPIDER_CAN_BG_SEARCH | SPIDER_CAN_BG_INSERT | @@ -9716,32 +9308,9 @@ void ha_spider::direct_update_init( THD *thd, bool hs_request ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint roop_count; -#endif DBUG_ENTER("ha_spider::direct_update_init"); DBUG_PRINT("info",("spider this=%p", this)); do_direct_update = TRUE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (hs_request) - { - maybe_do_hs_direct_update = TRUE; - memset(do_hs_direct_update, 0, share->link_bitmap_size); - for (roop_count = 0; roop_count < share->link_count; roop_count++) - { - if (spider_param_use_hs_write(thd, share->use_hs_writes[roop_count])) - { - DBUG_PRINT("info",("spider do_hs_direct_update[%d]=TRUE", - roop_count)); - spider_set_bit(do_hs_direct_update, roop_count); - } else { - maybe_do_hs_direct_update = FALSE; - } - } - } else { - maybe_do_hs_direct_update = FALSE; - } -#endif DBUG_VOID_RETURN; } #endif @@ -9929,9 +9498,6 @@ int ha_spider::direct_update_rows_init( ) #endif { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int error_num; -#endif st_select_lex *select_lex; longlong select_limit; longlong offset_limit; @@ -9973,11 +9539,7 @@ int ha_spider::direct_update_rows_init( } direct_update_init( thd, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - sql_command == SQLCOM_HS_UPDATE -#else FALSE -#endif ); if (!condition) cond_check = FALSE; @@ -10025,41 +9587,14 @@ int ha_spider::direct_update_rows_init( DBUG_PRINT("info",("spider offset_limit=%lld", offset_limit)); DBUG_PRINT("info",("spider mode=%u", mode)); DBUG_PRINT("info",("spider sql_command=%u", sql_command)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_PRINT("info",("spider maybe_do_hs_direct_update=%s", - maybe_do_hs_direct_update ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu", - hs_pushed_ret_fields_num)); -#endif DBUG_PRINT("info",("spider do_direct_update=%s", do_direct_update ? "TRUE" : "FALSE")); if ( ( !offset_limit -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - || (mode == 2 && maybe_do_hs_direct_update) -#endif ) && -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - sql_command == SQLCOM_HS_UPDATE && - hs_pushed_ret_fields_num < MAX_FIELDS && -#endif do_direct_update ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_PRINT("info",("spider pk_update=%s", pk_update ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider start_key=%p", &ranges->start_key)); - if (pk_update && spider_check_hs_pk_update(this, &ranges->start_key)) - { - DBUG_PRINT("info",("spider FALSE by pk_update")); - do_direct_update = FALSE; - DBUG_RETURN(HA_ERR_WRONG_COMMAND); - } - if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE))) - { - DBUG_RETURN(error_num); - } -#endif wide_handler->trx->direct_update_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); @@ -10544,9 +10079,6 @@ int ha_spider::direct_delete_rows_init( uint range_count, bool sorted ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int error_num; -#endif st_select_lex *select_lex; longlong select_limit; longlong offset_limit; @@ -10581,11 +10113,7 @@ int ha_spider::direct_delete_rows_init( } direct_update_init( thd, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - sql_command == SQLCOM_HS_DELETE -#else FALSE -#endif ); if (!condition) cond_check = FALSE; @@ -10630,21 +10158,9 @@ int ha_spider::direct_delete_rows_init( if ( ( !offset_limit -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - || (mode == 2 && maybe_do_hs_direct_update) -#endif ) && -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - sql_command == SQLCOM_HS_DELETE && -#endif do_direct_update ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE))) - { - DBUG_RETURN(error_num); - } -#endif wide_handler->trx->direct_delete_count++; DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); @@ -11964,9 +11480,6 @@ int ha_spider::info_push( #ifdef HA_CAN_BULK_ACCESS if ( #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - info_type != INFO_KIND_HS_RET_FIELDS && -#endif #endif info_type != INFO_KIND_BULK_ACCESS_BEGIN && info_type != INFO_KIND_BULK_ACCESS_CURRENT && @@ -11993,144 +11506,6 @@ int ha_spider::info_push( switch (info_type) { #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - case INFO_KIND_HS_RET_FIELDS: - { - DBUG_PRINT("info",("spider INFO_KIND_HS_RET_FIELDS")); - size_t roop_count; - Field *field; - SPIDER_HS_UINT32_INFO *tmp_info = (SPIDER_HS_UINT32_INFO *) info; - wide_handler->hs_pushed_ret_fields_num = tmp_info->info_size; - if (wide_handler->hs_pushed_ret_fields_size < - wide_handler->hs_pushed_ret_fields_num) - { - if (wide_handler->hs_pushed_ret_fields) - spider_free(spider_current_trx, wide_handler->hs_pushed_ret_fields, - MYF(0)); - if (!(wide_handler->hs_pushed_ret_fields = (uint32 *) - spider_bulk_malloc(spider_current_trx, SPD_MID_HA_SPIDER_INFO_PUSH_1, MYF(MY_WME), - &wide_handler->hs_pushed_ret_fields, - sizeof(uint32) * wide_handler->hs_pushed_ret_fields_num, - NullS)) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - wide_handler->hs_pushed_ret_fields_size = - wide_handler->hs_pushed_ret_fields_num; - } - memcpy(wide_handler->hs_pushed_ret_fields, tmp_info->info, - sizeof(uint32) * wide_handler->hs_pushed_ret_fields_num); - bitmap_clear_all(table->read_set); - bitmap_clear_all(table->write_set); - wide_handler->hs_pushed_lcl_fields_num = 0; - for (roop_count = 0; roop_count < wide_handler->hs_pushed_ret_fields_num; - roop_count++) - { - field = get_top_table_field( - wide_handler->hs_pushed_ret_fields[roop_count]); - if ((field = field_exchange(field))) - { - if (!bitmap_is_set(table->read_set, field->field_index)) - { - ++wide_handler->hs_pushed_lcl_fields_num; - bitmap_set_bit(table->read_set, field->field_index); - bitmap_set_bit(table->write_set, field->field_index); - } - } - } - } - break; - case INFO_KIND_HS_APPEND_STRING_REF: - { - DBUG_PRINT("info",("spider INFO_KIND_HS_APPEND_STRING_REF")); -#ifndef DBUG_OFF - SPIDER_HS_STRING_REF *tmp_ref = (SPIDER_HS_STRING_REF*) info; - char print_buf[MAX_FIELD_WIDTH]; - if (tmp_ref->size() < MAX_FIELD_WIDTH) - { - memcpy(print_buf, tmp_ref->begin(), tmp_ref->size()); - print_buf[tmp_ref->size()] = '\0'; - DBUG_PRINT("info",("spider info=%s", print_buf)); - } -#endif - Field *field; - if (wide_handler->hs_pushed_ret_fields) - { - field = get_top_table_field( - wide_handler->hs_pushed_ret_fields[ - wide_handler->hs_pushed_strref_num]); - } else { - field = get_top_table_field( - pt_clone_source_handler->wide_handler->hs_pushed_ret_fields[ - wide_handler->hs_pushed_strref_num]); - } - if (!field_exchange(field)) - { - wide_handler->hs_pushed_strref_num++; - break; - } - wide_handler->hs_pushed_strref_num++; - if (partition_handler && partition_handler->handlers) - { - size_t roop_count; - ha_spider **handlers = partition_handler->handlers; - for (roop_count = 0; roop_count < partition_handler->no_parts; - ++roop_count) - { - if ((error_num = handlers[roop_count]->push_back_hs_upds( - *((SPIDER_HS_STRING_REF*) info)))) - { - DBUG_RETURN(error_num); - } - } - } else { - if ((error_num = push_back_hs_upds(*((SPIDER_HS_STRING_REF*) info)))) - { - DBUG_RETURN(error_num); - } - } - break; - } - case INFO_KIND_HS_CLEAR_STRING_REF: - DBUG_PRINT("info",("spider INFO_KIND_HS_CLEAR_STRING_REF")); - wide_handler->hs_pushed_strref_num = 0; - if (partition_handler && partition_handler->handlers) - { - size_t roop_count; - ha_spider **handlers = partition_handler->handlers; - for (roop_count = 0; roop_count < partition_handler->no_parts; - ++roop_count) - { - if ((error_num = handlers[roop_count]->reset_hs_upds( - SPIDER_SQL_TYPE_UPDATE_HS))) - { - DBUG_RETURN(error_num); - } - } - } else { - if ((error_num = reset_hs_upds(SPIDER_SQL_TYPE_UPDATE_HS))) - { - DBUG_RETURN(error_num); - } - } - break; - case INFO_KIND_HS_INCREMENT_BEGIN: - DBUG_PRINT("info",("spider INFO_KIND_HS_INCREMENT_BEGIN")); - wide_handler->hs_increment = TRUE; - break; - case INFO_KIND_HS_INCREMENT_END: - DBUG_PRINT("info",("spider INFO_KIND_HS_INCREMENT_END")); - wide_handler->hs_increment = FALSE; - break; - case INFO_KIND_HS_DECREMENT_BEGIN: - DBUG_PRINT("info",("spider INFO_KIND_HS_DECREMENT_BEGIN")); - wide_handler->hs_decrement = TRUE; - break; - case INFO_KIND_HS_DECREMENT_END: - DBUG_PRINT("info",("spider INFO_KIND_HS_DECREMENT_END")); - wide_handler->hs_decrement = FALSE; - break; -#endif #ifdef INFO_KIND_UPDATE_FIELDS case INFO_KIND_UPDATE_FIELDS: DBUG_PRINT("info",("spider INFO_KIND_UPDATE_FIELDS")); @@ -12933,22 +12308,7 @@ bool ha_spider::handler_opened( DBUG_PRINT("info",("spider link_idx=%d", link_idx)); DBUG_PRINT("info",("spider tgt_conn_kind=%u", tgt_conn_kind)); if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ( - tgt_conn_kind == SPIDER_CONN_KIND_MYSQL && -#endif spider_bit_is_set(m_handler_opened, link_idx) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - ( - tgt_conn_kind == SPIDER_CONN_KIND_HS_READ && - spider_bit_is_set(r_handler_opened, link_idx) - ) || - ( - tgt_conn_kind == SPIDER_CONN_KIND_HS_WRITE && - spider_bit_is_set(w_handler_opened, link_idx) - ) -#endif ) { DBUG_PRINT("info",("spider TRUE")); DBUG_RETURN(TRUE); @@ -12962,16 +12322,7 @@ void ha_spider::set_handler_opened( ) { DBUG_ENTER("ha_spider::set_handler_opened"); DBUG_PRINT("info",("spider this=%p", this)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) -#endif spider_set_bit(m_handler_opened, link_idx); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else if (conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - spider_set_bit(r_handler_opened, link_idx); - else - spider_set_bit(w_handler_opened, link_idx); -#endif DBUG_VOID_RETURN; } @@ -12981,16 +12332,7 @@ void ha_spider::clear_handler_opened( ) { DBUG_ENTER("ha_spider::clear_handler_opened"); DBUG_PRINT("info",("spider this=%p", this)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (tgt_conn_kind == SPIDER_CONN_KIND_MYSQL) -#endif spider_clear_bit(m_handler_opened, link_idx); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else if (tgt_conn_kind == SPIDER_CONN_KIND_HS_READ) - spider_clear_bit(r_handler_opened, link_idx); - else - spider_clear_bit(w_handler_opened, link_idx); -#endif DBUG_VOID_RETURN; } @@ -13038,96 +12380,6 @@ int ha_spider::close_opened_handler( conns[link_idx] = NULL; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider_bit_is_set(r_handler_opened, link_idx)) - { - if ((error_num2 = spider_db_close_handler(this, - hs_r_conns[link_idx], link_idx, SPIDER_CONN_KIND_HS_READ)) - ) { - if ( - share->monitoring_kind[link_idx] && - need_mons[link_idx] - ) { - error_num2 = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - link_idx, - (uint32) share->monitoring_sid[link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[link_idx], - NULL, - 0, - share->monitoring_kind[link_idx], - share->monitoring_limit[link_idx], - share->monitoring_flag[link_idx], - TRUE - ); - } - error_num = error_num2; - } - spider_clear_bit(r_handler_opened, link_idx); - if (release_conn && !hs_w_conns[link_idx]->join_trx) - { - if ( - !hs_r_conns[link_idx]->opened_handlers && - wide_handler->trx->trx_hs_r_conn_adjustment == - trx_hs_r_conn_adjustment && - spider_param_hs_r_conn_recycle_mode(wide_handler->trx->thd) != 2 - ) { - wide_handler->trx->trx_hs_r_conn_adjustment++; - } - spider_free_conn_from_trx(wide_handler->trx, hs_r_conns[link_idx], - FALSE, FALSE, NULL); - hs_r_conns[link_idx] = NULL; - } - } - if (spider_bit_is_set(w_handler_opened, link_idx)) - { - if ((error_num2 = spider_db_close_handler(this, - hs_w_conns[link_idx], link_idx, SPIDER_CONN_KIND_HS_WRITE)) - ) { - if ( - share->monitoring_kind[link_idx] && - need_mons[link_idx] - ) { - error_num2 = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - link_idx, - (uint32) share->monitoring_sid[link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[link_idx], - NULL, - 0, - share->monitoring_kind[link_idx], - share->monitoring_limit[link_idx], - share->monitoring_flag[link_idx], - TRUE - ); - } - error_num = error_num2; - } - spider_clear_bit(w_handler_opened, link_idx); - if (release_conn && !hs_w_conns[link_idx]->join_trx) - { - if ( - !hs_w_conns[link_idx]->opened_handlers && - wide_handler->trx->trx_hs_w_conn_adjustment == - trx_hs_w_conn_adjustment && - spider_param_hs_w_conn_recycle_mode(wide_handler->trx->thd) != 2 - ) { - wide_handler->trx->trx_hs_w_conn_adjustment++; - } - spider_free_conn_from_trx(wide_handler->trx, hs_w_conns[link_idx], - FALSE, FALSE, NULL); - hs_w_conns[link_idx] = NULL; - } - } -#endif DBUG_RETURN(error_num); } @@ -13165,31 +12417,8 @@ int ha_spider::index_handler_init() spider_conn_use_handler(this, lock_mode, roop_count) && spider_conn_need_open_handler(this, active_index, roop_count) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint tmp_conn_kind1; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - do_direct_update && - spider_bit_is_set(do_hs_direct_update, roop_count) - ) { - tmp_conn_kind1 = SPIDER_CONN_KIND_HS_WRITE; - } else { -#endif - tmp_conn_kind1 = conn_kind[roop_count]; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - } -#endif -#endif if ((error_num = spider_db_open_handler(this, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (tmp_conn_kind1 == SPIDER_CONN_KIND_MYSQL ? -#endif conns[roop_count] -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - : tmp_conn_kind1 == SPIDER_CONN_KIND_HS_READ ? - hs_r_conns[roop_count] : hs_w_conns[roop_count] - ) -#endif , roop_count)) ) { if ( @@ -13215,18 +12444,7 @@ int ha_spider::index_handler_init() } DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uint tmp_conn_kind2 = conn_kind[roop_count]; - conn_kind[roop_count] = tmp_conn_kind1; -#endif -#endif set_handler_opened(roop_count); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - conn_kind[roop_count] = tmp_conn_kind2; -#endif -#endif } } if (sql_kinds & SPIDER_SQL_KIND_HANDLER) @@ -13288,15 +12506,7 @@ int ha_spider::rnd_handler_init() spider_conn_need_open_handler(this, MAX_KEY, roop_count) ) { if ((error_num = spider_db_open_handler(this, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL ? -#endif conns[roop_count] -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - : conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ ? - hs_r_conns[roop_count] : hs_w_conns[roop_count] - ) -#endif , roop_count)) ) { if ( @@ -13402,9 +12612,6 @@ void ha_spider::set_error_mode() case SQLCOM_SHOW_CREATE_TRIGGER: case SQLCOM_SHOW_PROFILE: case SQLCOM_SHOW_PROFILES: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - case SQLCOM_HS_READ: -#endif error_mode = spider_param_error_read_mode(thd, share->error_read_mode); DBUG_PRINT("info",("spider read error_mode=%d", error_mode)); break; @@ -13620,10 +12827,6 @@ int ha_spider::sync_from_clone_source( DBUG_PRINT("info",("spider synced from clone source all")); wide_handler->trx = spider->wide_handler->trx; sql_command = spider->sql_command; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - conn_kinds = spider->conn_kinds; - memcpy(conn_kind, spider->conn_kind, sizeof(uint) * share->link_count); -#endif wide_handler->external_lock_type = spider->wide_handler->external_lock_type; selupd_lock_mode = spider->selupd_lock_mode; @@ -13633,18 +12836,8 @@ int ha_spider::sync_from_clone_source( low_priority = spider->low_priority; memcpy(conns, spider->conns, sizeof(SPIDER_CONN *) * share->link_count); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - memcpy(hs_r_conns, spider->hs_r_conns, - sizeof(SPIDER_CONN *) * share->link_count); - memcpy(hs_w_conns, spider->hs_w_conns, - sizeof(SPIDER_CONN *) * share->link_count); -#endif spider_thread_id = spider->spider_thread_id; trx_conn_adjustment = spider->trx_conn_adjustment; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - trx_hs_r_conn_adjustment = spider->trx_hs_r_conn_adjustment; - trx_hs_w_conn_adjustment = spider->trx_hs_w_conn_adjustment; -#endif search_link_idx = spider->search_link_idx; external_lock_cnt = spider->external_lock_cnt; uint roop_count, dbton_id; @@ -13661,10 +12854,6 @@ int ha_spider::sync_from_clone_source( { DBUG_PRINT("info",("spider synced from clone source")); sql_command = spider->sql_command; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - conn_kinds = spider->conn_kinds; - memcpy(conn_kind, spider->conn_kind, sizeof(uint) * share->link_count); -#endif wide_handler->external_lock_type = spider->wide_handler->external_lock_type; selupd_lock_mode = spider->selupd_lock_mode; @@ -13683,18 +12872,6 @@ int ha_spider::sync_from_clone_source( } #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->hs_pushed_ret_fields_num < MAX_FIELDS) - { - SPIDER_HS_UINT32_INFO tmp_info; - tmp_info.info_size = spider->hs_pushed_ret_fields_num; - tmp_info.info = spider->hs_pushed_ret_fields; - if ((error_num = info_push(INFO_KIND_HS_RET_FIELDS, &tmp_info))) - { - DBUG_RETURN(error_num); - } - } -#endif #endif DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", dbton_handler)); @@ -13756,21 +12933,6 @@ void ha_spider::set_first_link_idx() dbton_hdl->strict_group_by = TRUE; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - dbton_id = share->hs_dbton_ids[all_link_idx]; - if (dbton_id < SPIDER_DBTON_SIZE) - { - dbton_hdl = dbton_handler[dbton_id]; - if (dbton_hdl->first_link_idx == -1) - { - dbton_hdl->first_link_idx = roop_count; - } - if (share->strict_group_bys[all_link_idx]) - { - dbton_hdl->strict_group_by = TRUE; - } - } -#endif } DBUG_VOID_RETURN; } @@ -13801,17 +12963,6 @@ void ha_spider::reset_first_link_idx() dbton_hdl->first_link_idx = search_link_idx; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - dbton_id = share->hs_dbton_ids[all_link_idx]; - if (dbton_id < SPIDER_DBTON_SIZE) - { - dbton_hdl = dbton_handler[dbton_id]; - if (dbton_hdl->first_link_idx == -1) - { - dbton_hdl->first_link_idx = search_link_idx; - } - } -#endif } DBUG_VOID_RETURN; } @@ -13841,109 +12992,6 @@ int ha_spider::reset_sql_sql( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::reset_hs_sql( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_sql"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_sql(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::reset_hs_keys( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_keys"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_keys(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::reset_hs_upds( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_upds"); - for (roop_count = 0; roop_count < share->use_dbton_count; roop_count++) - { - dbton_id = share->use_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_upds(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::reset_hs_strs( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_strs"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_strs(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::reset_hs_strs_pos( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::reset_hs_strs_pos"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->reset_strs_pos(sql_type))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} - -int ha_spider::push_back_hs_upds( - SPIDER_HS_STRING_REF &info -) { - int error_num; - uint roop_count, dbton_id; - DBUG_ENTER("ha_spider::push_back_hs_upds"); - for (roop_count = 0; roop_count < share->use_dbton_count; roop_count++) - { - dbton_id = share->use_dbton_ids[roop_count]; - if ((error_num = dbton_handler[dbton_id]->push_back_upds(info))) - { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif int ha_spider::append_tmp_table_and_sql_for_bka( const key_range *start_key @@ -14067,29 +13115,6 @@ int ha_spider::append_update_sql_part() DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int ha_spider::append_increment_update_set_sql_part() -{ - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_increment_update_set_sql_part"); - for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) - { - dbton_id = share->use_sql_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_increment_update_set_part()) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif -#endif int ha_spider::append_update_set_sql_part() { @@ -14132,27 +13157,6 @@ int ha_spider::append_direct_update_set_sql_part() DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::append_direct_update_set_hs_part() -{ - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_direct_update_set_hs_part"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_direct_update_set_part()) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif #endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS @@ -14583,31 +13587,6 @@ int ha_spider::append_key_where_sql_part( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::append_key_where_hs_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_key_where_hs_part"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_key_where_part(start_key, end_key, - sql_type)) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif int ha_spider::append_match_where_sql_part( ulong sql_type @@ -14883,30 +13862,6 @@ int ha_spider::append_limit_sql_part( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::append_limit_hs_part( - longlong offset, - longlong limit, - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_limit_hs_part"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_limit_part(offset, limit, sql_type)) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif int ha_spider::reappend_limit_sql_part( longlong offset, @@ -14973,28 +13928,6 @@ int ha_spider::append_insert_values_sql_part( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int ha_spider::append_insert_values_hs_part( - ulong sql_type -) { - int error_num; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::append_insert_values_hs_part"); - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - (error_num = dbton_hdl->append_insert_values_part(sql_type)) - ) { - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); -} -#endif int ha_spider::append_into_sql_part( ulong sql_type @@ -15039,10 +13972,6 @@ bool ha_spider::is_bulk_insert_exec_period( uint roop_count, dbton_id; spider_db_handler *dbton_hdl; DBUG_ENTER("ha_spider::is_bulk_insert_exec_period"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kinds & SPIDER_SQL_KIND_SQL) - { -#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { dbton_id = share->use_sql_dbton_ids[roop_count]; @@ -15054,23 +13983,6 @@ bool ha_spider::is_bulk_insert_exec_period( DBUG_RETURN(TRUE); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (sql_kinds & SPIDER_SQL_KIND_HS) - { - for (roop_count = 0; roop_count < share->use_hs_dbton_count; roop_count++) - { - dbton_id = share->use_hs_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - dbton_hdl->is_bulk_insert_exec_period(bulk_end) - ) { - DBUG_RETURN(TRUE); - } - } - } -#endif DBUG_RETURN(FALSE); } @@ -15776,21 +14688,6 @@ bool ha_spider::support_use_handler_sql( DBUG_RETURN(TRUE); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -bool ha_spider::support_bulk_access_hs() const -{ - uint roop_count; - DBUG_ENTER("ha_spider::support_bulk_access_hs"); - if (!share) - DBUG_RETURN(FALSE); - for (roop_count = 0; roop_count < share->all_link_count; roop_count++) - { - if (share->hs_dbton_ids[roop_count] == SPIDER_DBTON_SIZE) - DBUG_RETURN(FALSE); - } - DBUG_RETURN(TRUE); -} -#endif int ha_spider::init_union_table_name_pos_sql() { @@ -15909,10 +14806,6 @@ int ha_spider::lock_tables() DBUG_PRINT("info",("spider lock_table_type=%u", wide_handler->lock_table_type)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((conn_kinds & SPIDER_CONN_KIND_MYSQL)) - { -#endif if (!conns[search_link_idx]) { my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, @@ -16031,9 +14924,6 @@ int ha_spider::lock_tables() } } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif DBUG_RETURN(0); } @@ -16054,10 +14944,6 @@ int ha_spider::dml_init() { DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((conn_kinds & SPIDER_CONN_KIND_MYSQL)) - { -#endif if (!conns[search_link_idx]) { my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, @@ -16148,91 +15034,6 @@ int ha_spider::dml_init() conns[roop_count]->semi_trx_isolation = -1; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - reset_first_link_idx(); - } - if ((conn_kinds & SPIDER_CONN_KIND_HS_READ)) - { - SPIDER_CONN *hs_conn; - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - hs_conn = hs_r_conns[roop_count]; - if ( - hs_conn && - hs_conn->hsc_query_id != thd->query_id && - hs_conn->hs_pre_age == hs_conn->hs_age - ) { - double interval = spider_param_hs_ping_interval(thd); - time_t tmp_time = (time_t) time((time_t*) 0); - DBUG_PRINT("info", - ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); - DBUG_PRINT("info", ("spider interval=%f", interval)); - if ( - hs_conn->server_lost || - difftime(tmp_time, hs_conn->ping_time) >= interval - ) { - DBUG_PRINT("info", ("spider hsr[%d] need reconnect", roop_count)); - hs_conn->hs_pre_age++; - hs_conn->ping_time = tmp_time; - } - hs_conn->hsc_query_id = thd->query_id; - } - } - } - if ( -#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) - ( -#endif - conn_kinds & SPIDER_CONN_KIND_HS_WRITE -#if defined(HS_HAS_SQLCOM) && defined(HANDLER_HAS_DIRECT_UPDATE_ROWS) - ) || - /* for direct_update */ - wide_handler->sql_command == SQLCOM_HS_UPDATE || - wide_handler->sql_command == SQLCOM_HS_DELETE -#endif - ) { - SPIDER_CONN *hs_conn; - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count < (int) share->link_count; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - hs_conn = hs_w_conns[roop_count]; - if ( - hs_conn && - hs_conn->hsc_query_id != thd->query_id && - hs_conn->hs_pre_age == hs_conn->hs_age - ) { - double interval = spider_param_hs_ping_interval(thd); - time_t tmp_time = (time_t) time((time_t*) 0); - DBUG_PRINT("info", - ("spider difftime=%f", difftime(tmp_time, hs_conn->ping_time))); - DBUG_PRINT("info", ("spider interval=%f", interval)); - if ( - hs_conn->server_lost || - difftime(tmp_time, hs_conn->ping_time) >= interval - ) { - DBUG_PRINT("info", ("spider hsw[%d] need reconnect", roop_count)); - hs_conn->hs_pre_age++; - hs_conn->ping_time = tmp_time; - } - hs_conn->hsc_query_id = thd->query_id; - } - } - } -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (wide_handler->insert_with_update) { @@ -16285,14 +15086,6 @@ int ha_spider::bulk_access_begin( ) { DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - memset( - bulk_access_link_current->spider->result_list.hs_r_bulk_open_index, 0, - share->link_bitmap_size); - memset( - bulk_access_link_current->spider->result_list.hs_w_bulk_open_index, 0, - share->link_bitmap_size); -#endif bulk_access_link_current->spider->bulk_access_executing = FALSE; bulk_access_link_current->spider->bulk_access_pre_called = FALSE; bulk_access_link_current->used = TRUE; diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 969fbf850cd..5ccf3d5c4f5 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -55,10 +55,6 @@ public: SPIDER_SHARE *share; ulonglong spider_thread_id; ulonglong trx_conn_adjustment; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ulonglong trx_hs_r_conn_adjustment; - ulonglong trx_hs_w_conn_adjustment; -#endif uint mem_calc_id; const char *mem_calc_func_name; const char *mem_calc_file_name; @@ -71,14 +67,6 @@ public: char *conn_keys_first_ptr; char **conn_keys; SPIDER_CONN **conns; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_r_conn_keys; - SPIDER_CONN **hs_r_conns; - ulonglong *hs_r_conn_ages; - char **hs_w_conn_keys; - SPIDER_CONN **hs_w_conns; - ulonglong *hs_w_conn_ages; -#endif /* for active-standby mode */ uint *conn_link_idx; uchar *conn_can_fo; @@ -179,27 +167,8 @@ public: uchar *m_handler_opened; uint *m_handler_id; char **m_handler_cid; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uchar *r_handler_opened; - uint *r_handler_id; - uint *r_handler_index; - uchar *w_handler_opened; - uint *w_handler_id; - uint *w_handler_index; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uchar *do_hs_direct_update; - uint32 **hs_r_ret_fields; - uint32 **hs_w_ret_fields; - size_t *hs_r_ret_fields_num; - size_t *hs_w_ret_fields_num; - uchar *tmp_column_bitmap; -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS bool do_direct_update; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - bool maybe_do_hs_direct_update; -#endif uint direct_update_kinds; #endif spider_index_rnd_init prev_index_rnd_init; @@ -938,26 +907,6 @@ public: int reset_sql_sql( ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int reset_hs_sql( - ulong sql_type - ); - int reset_hs_keys( - ulong sql_type - ); - int reset_hs_upds( - ulong sql_type - ); - int reset_hs_strs( - ulong sql_type - ); - int reset_hs_strs_pos( - ulong sql_type - ); - int push_back_hs_upds( - SPIDER_HS_STRING_REF &info - ); -#endif int append_tmp_table_and_sql_for_bka( const key_range *start_key ); @@ -968,17 +917,9 @@ public: int reuse_union_table_and_sql_for_bka(); int append_insert_sql_part(); int append_update_sql_part(); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_increment_update_set_sql_part(); -#endif -#endif int append_update_set_sql_part(); #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int append_direct_update_set_sql_part(); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_direct_update_set_hs_part(); -#endif #endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS int append_dup_update_pushdown_sql_part( @@ -1045,13 +986,6 @@ public: const key_range *end_key, ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_key_where_hs_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type - ); -#endif int append_match_where_sql_part( ulong sql_type ); @@ -1106,13 +1040,6 @@ public: longlong limit, ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_limit_hs_part( - longlong offset, - longlong limit, - ulong sql_type - ); -#endif int reappend_limit_sql_part( longlong offset, longlong limit, @@ -1124,11 +1051,6 @@ public: int append_insert_values_sql_part( ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_insert_values_hs_part( - ulong sql_type - ); -#endif int append_into_sql_part( ulong sql_type ); @@ -1197,9 +1119,6 @@ public: bool support_use_handler_sql( int use_handler ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - bool support_bulk_access_hs() const; -#endif int init_union_table_name_pos_sql(); int set_union_table_name_pos_sql(); int append_lock_tables_list(); diff --git a/storage/spider/hs_client/allocator.hpp b/storage/spider/hs_client/allocator.hpp deleted file mode 100644 index c302e07804e..00000000000 --- a/storage/spider/hs_client/allocator.hpp +++ /dev/null @@ -1,43 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_ALLOCATOR_HPP -#define DENA_ALLOCATOR_HPP - -#if 0 -extern "C" { -#include -}; -#define DENA_MALLOC(x) tlsf_malloc(x) -#define DENA_REALLOC(x, y) tlsf_realloc(x, y) -#define DENA_FREE(x) tlsf_free(x) -#define DENA_NEWCHAR(x) static_cast(tlsf_malloc(x)) -#define DENA_DELETE(x) tlsf_free(x) -#endif - -#if 1 -#define DENA_MALLOC(x) malloc(x) -#define DENA_REALLOC(x, y) realloc(x, y) -#define DENA_FREE(x) free(x) -#define DENA_NEWCHAR(x) (new char[x]) -#define DENA_DELETE(x) (delete [] x) -#endif - -#if 1 -#define DENA_ALLOCA_ALLOCATE(typ, len) \ - (typ *) (alloca((len) * sizeof(typ))) -#define DENA_ALLOCA_FREE(x) -#else -#define DENA_ALLOCA_ALLOCATE(typ, len) \ - (typ *) (malloc((len) * sizeof(typ))) -#define DENA_ALLOCA_FREE(x) free(x) -#endif - -#endif - diff --git a/storage/spider/hs_client/auto_addrinfo.hpp b/storage/spider/hs_client/auto_addrinfo.hpp deleted file mode 100644 index 5262ad11d4a..00000000000 --- a/storage/spider/hs_client/auto_addrinfo.hpp +++ /dev/null @@ -1,49 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_AUTO_ADDRINFO_HPP -#define DENA_AUTO_ADDRINFO_HPP - -#ifndef __WIN__ -#include -#endif - -#include "util.hpp" - -namespace dena { - -struct auto_addrinfo : private noncopyable { - auto_addrinfo() : addr(0) { } - ~auto_addrinfo() { - reset(); - } - void reset(addrinfo *a = 0) { - if (addr != 0) { - freeaddrinfo(addr); - } - addr = a; - } - const addrinfo *get() const { return addr; } - int resolve(const char *node, const char *service, int flags = 0, - int family = AF_UNSPEC, int socktype = SOCK_STREAM, int protocol = 0) { - reset(); - addrinfo hints; - hints.ai_flags = flags; - hints.ai_family = family; - hints.ai_socktype = socktype; - hints.ai_protocol = protocol; - return getaddrinfo(node, service, &hints, &addr); - } - private: - addrinfo *addr; -}; - -}; - -#endif - diff --git a/storage/spider/hs_client/auto_file.hpp b/storage/spider/hs_client/auto_file.hpp deleted file mode 100644 index ddd1f8c9196..00000000000 --- a/storage/spider/hs_client/auto_file.hpp +++ /dev/null @@ -1,67 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_AUTO_FILE_HPP -#define DENA_AUTO_FILE_HPP - -/* -#ifndef __WIN__ -#include -#endif -*/ - -#include "util.hpp" - -namespace dena { - -struct auto_file : private noncopyable { - auto_file() : fd(-1) { } - ~auto_file() { - reset(); - } - int get() const { return fd; } - int close() { - if (fd < 0) { - return 0; - } - const int r = ::close(fd); - fd = -1; - return r; - } - void reset(int x = -1) { - if (fd >= 0) { - this->close(); - } - fd = x; - } - private: - int fd; -}; - -/* -struct auto_dir : private noncopyable { - auto_dir() : dp(0) { } - ~auto_dir() { - reset(); - } - DIR *get() const { return dp; } - void reset(DIR *d = 0) { - if (dp != 0) { - closedir(dp); - } - dp = d; - } - private: - DIR *dp; -}; -*/ - -}; - -#endif - diff --git a/storage/spider/hs_client/auto_ptrcontainer.hpp b/storage/spider/hs_client/auto_ptrcontainer.hpp deleted file mode 100644 index 3629f19c8ea..00000000000 --- a/storage/spider/hs_client/auto_ptrcontainer.hpp +++ /dev/null @@ -1,70 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_AUTO_PTRCONTAINER_HPP -#define DENA_AUTO_PTRCONTAINER_HPP - -namespace dena { - -/* -template -struct auto_ptrcontainer { - typedef Tcnt container_type; - typedef typename container_type::value_type value_type; - typedef typename container_type::pointer pointer; - typedef typename container_type::reference reference; - typedef typename container_type::const_reference const_reference; - typedef typename container_type::size_type size_type; - typedef typename container_type::difference_type difference_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - typedef typename container_type::reverse_iterator reverse_iterator; - typedef typename container_type::const_reverse_iterator - const_reverse_iterator; - iterator begin() { return cnt.begin(); } - const_iterator begin() const { return cnt.begin(); } - iterator end() { return cnt.end(); } - const_iterator end() const { return cnt.end(); } - reverse_iterator rbegin() { return cnt.rbegin(); } - reverse_iterator rend() { return cnt.rend(); } - const_reverse_iterator rbegin() const { return cnt.rbegin(); } - const_reverse_iterator rend() const { return cnt.rend(); } - size_type size() const { return cnt.size(); } - size_type max_size() const { return cnt.max_size(); } - bool empty() const { return cnt.empty(); } - reference front() { return cnt.front(); } - const_reference front() const { cnt.front(); } - reference back() { return cnt.back(); } - const_reference back() const { cnt.back(); } - void swap(auto_ptrcontainer& x) { cnt.swap(x.cnt); } - ~auto_ptrcontainer() { - for (iterator i = begin(); i != end(); ++i) { - delete *i; - } - } - template void push_back_ptr(Tap& ap) { - cnt.push_back(ap.get()); - ap.release(); - } - void erase_ptr(iterator i) { - delete *i; - cnt.erase(i); - } - reference operator [](size_type n) { return cnt[n]; } - const_reference operator [](size_type n) const { return cnt[n]; } - void clear() { cnt.clear(); } - private: - Tcnt cnt; -}; -*/ - -}; - -#endif - diff --git a/storage/spider/hs_client/config.cpp b/storage/spider/hs_client/config.cpp deleted file mode 100644 index ac5acbccd16..00000000000 --- a/storage/spider/hs_client/config.cpp +++ /dev/null @@ -1,286 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "config.hpp" - -namespace dena { - -unsigned int verbose_level = 0; - -uchar * -conf_get_key( - conf_param *param, - size_t *length, - my_bool not_used __attribute__ ((unused)) -) { - *length = param->key.length(); - return (uchar*) param->key.ptr(); -} - -config::config() -{ - if (my_hash_init(PSI_INSTRUMENT_ME, &conf_hash, &my_charset_bin, 32, 0, 0, - (my_hash_get_key) conf_get_key, 0, 0)) - init = FALSE; - else - init = TRUE; - return; -} - -config::~config() -{ - if (init) - { - conf_param *param; - while ((param = (conf_param *) my_hash_element(&conf_hash, 0))) - { - my_hash_delete(&conf_hash, (uchar*) param); - delete param; - } - my_hash_free(&conf_hash); - } -} - -conf_param * -config::find(const String& key) const -{ - if (init) - return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key.ptr(), - key.length()); - else - return NULL; -} - -conf_param * -config::find(const char *key) const -{ - if (init) - return (conf_param *) my_hash_search(&conf_hash, (const uchar*) key, - strlen(key)); - else - return NULL; -} - -String -config::get_str(const String& key, const String& def) const -{ - DENA_VERBOSE(30, list_all_params()); - conf_param *param = find(key); - if (!param) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key.ptr(), - def.ptr())); - return def; - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", key.ptr(), - param->val.ptr())); - return param->val; -} - -String -config::get_str(const char *key, const char *def) const -{ - DENA_VERBOSE(30, list_all_params()); - conf_param *param = find(key); - if (!param) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(default)\n", key, def)); - return String(def, strlen(def), &my_charset_bin); - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", - key, param->val.ptr())); - return param->val; -} - -long long -config::get_int(const String& key, long long def) const -{ - int err; - DENA_VERBOSE(30, list_all_params()); - conf_param *param = find(key); - if (!param) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key.ptr(), - def)); - return def; - } - const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err); - if (err) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key.ptr(), - def)); - return def; - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key.ptr(), r)); - return r; -} - -long long -config::get_int(const char *key, long long def) const -{ - int err; - DENA_VERBOSE(30, list_all_params()); - conf_param *param = find(key); - if (!param) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(default)\n", key, def)); - return def; - } - const long long r = my_strtoll10(param->val.ptr(), (char**) NULL, &err); - if (err) { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld(err)\n", key, def)); - return def; - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%lld\n", key, r)); - return r; -} - -bool -config::replace(const char *key, const char *val) -{ - uint32 val_len = strlen(val); - conf_param *param = find(key); - if (!param) { - /* create */ - if (!(param = new conf_param())) - return TRUE; - uint32 key_len = strlen(key); - if ( - param->key.reserve(key_len + 1) || - param->val.reserve(val_len + 1) - ) { - delete param; - return TRUE; - } - param->key.q_append(key, key_len); - param->val.q_append(val, val_len); - param->key.c_ptr_safe(); - param->val.c_ptr_safe(); - if (my_hash_insert(&conf_hash, (uchar*) param)) - { - delete param; - return TRUE; - } - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(create)\n", - param->key.ptr(), param->val.ptr())); - return FALSE; - } - /* replace */ - param->val.length(0); - if (param->val.reserve(val_len + 1)) - return TRUE; - param->val.q_append(val, val_len); - param->val.c_ptr_safe(); - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s(replace)\n", - param->key.ptr(), param->val.ptr())); - return FALSE; -} - -bool -config::replace(const char *key, long long val) -{ - char val_str[22]; - sprintf(val_str, "%lld", val); - return replace(key, val_str); -} - -bool -config::compare(const char *key, const char *val) -{ - conf_param *param = find(key); - if (!param) - return FALSE; - return !strcmp(param->val.ptr(), val); -} - -void -config::list_all_params() const -{ - conf_param *param; - DENA_VERBOSE(10, fprintf(stderr, "list_all_params start\n")); - for(ulong i = 0; i < conf_hash.records; i++) - { - if ((param = (conf_param *) my_hash_element((HASH *) &conf_hash, i))) - { - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", - param->key.ptr(), param->val.ptr())); - } - } - DENA_VERBOSE(10, fprintf(stderr, "list_all_params end\n")); -} - -config& -config::operator =(const config& x) -{ - DENA_VERBOSE(10, fprintf(stderr, "config operator = start")); - if (this != &x && init && x.init) { - conf_param *param, *new_param; - for(ulong i = 0; i < x.conf_hash.records; i++) - { - if ((param = (conf_param *) my_hash_element((HASH *) &x.conf_hash, i))) - if ((new_param = new conf_param())) - { - if ( - !new_param->key.copy(param->key) && - !new_param->val.copy(param->val) - ) { - new_param->key.c_ptr_safe(); - new_param->val.c_ptr_safe(); - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", - new_param->key.ptr(), new_param->val.ptr())); - if (my_hash_insert(&conf_hash, (uchar*) new_param)) - delete new_param; - } else - delete new_param; - } - } - } - DENA_VERBOSE(10, fprintf(stderr, "config operator = end %p", this)); - return *this; -} - -void -parse_args(int argc, char **argv, config& conf) -{ - conf_param *param; - for (int i = 1; i < argc; ++i) { - const char *const arg = argv[i]; - const char *const eq = strchr(arg, '='); - if (eq == 0) { - continue; - } - if (!(param = new conf_param())) - continue; - uint32 key_len = (uint32)(eq - arg); - uint32 val_len = strlen(eq + 1); - if ( - param->key.reserve(key_len + 1) || - param->val.reserve(val_len + 1) - ) { - delete param; - continue; - } - param->key.q_append(arg, key_len); - param->val.q_append(eq + 1, val_len); - param->key.c_ptr_safe(); - param->val.c_ptr_safe(); - if (my_hash_insert(&conf.conf_hash, (uchar*) param)) - { - delete param; - continue; - } - } - param = conf.find("verbose"); - if (param) { - verbose_level = atoi(param->val.c_ptr()); - } -} - -}; - diff --git a/storage/spider/hs_client/config.hpp b/storage/spider/hs_client/config.hpp deleted file mode 100644 index a3a986cc1fd..00000000000 --- a/storage/spider/hs_client/config.hpp +++ /dev/null @@ -1,76 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_CONFIG_HPP -#define DENA_CONFIG_HPP - -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" -#include "sql_class.h" - -#define DENA_VERBOSE(lv, x) if (dena::verbose_level >= (lv)) { (x); } - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#define INFO_KIND_HS_RET_FIELDS 1 -#define INFO_KIND_HS_APPEND_STRING_REF 3 -#define INFO_KIND_HS_CLEAR_STRING_REF 4 -#define INFO_KIND_HS_INCREMENT_BEGIN 5 -#define INFO_KIND_HS_INCREMENT_END 6 -#define INFO_KIND_HS_DECREMENT_BEGIN 7 -#define INFO_KIND_HS_DECREMENT_END 8 -#endif - -namespace dena { - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -struct uint32_info { - size_t info_size; - uint32 *info; -}; -#endif - -struct conf_param { - String key; - String val; -}; - -uchar *conf_get_key( - conf_param *share, - size_t *length, - my_bool not_used __attribute__ ((unused)) -); - -struct config { - bool init; - HASH conf_hash; - config(); - ~config(); - conf_param *find(const String& key) const; - conf_param *find(const char *key) const; - String get_str(const String& key, const String& def = - String("", &my_charset_bin)) const; - String get_str(const char *key, const char *def = "") const; - long long get_int(const String& key, long long def = 0) const; - long long get_int(const char *key, long long def = 0) const; - bool replace(const char *key, const char *val); - bool replace(const char *key, long long val); - bool compare(const char *key, const char *val); - void list_all_params() const; - config& operator =(const config& x); -}; - -void parse_args(int argc, char **argv, config& conf); - -extern unsigned int verbose_level; - -}; - -#endif - diff --git a/storage/spider/hs_client/escape.cpp b/storage/spider/hs_client/escape.cpp deleted file mode 100644 index f3e60afc387..00000000000 --- a/storage/spider/hs_client/escape.cpp +++ /dev/null @@ -1,129 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "hs_compat.h" -#include "escape.hpp" -#include "string_buffer.hpp" -#include "fatal.hpp" -#include "string_util.hpp" - -#define DBG_OP(x) -#define DBG_BUF(x) - -namespace dena { - -enum special_char_t { - special_char_escape_prefix = 0x01, /* SOH */ - special_char_noescape_min = 0x10, /* DLE */ - special_char_escape_shift = 0x40, /* '@' */ -}; - -void -escape_string(char *& wp, const char *start, const char *finish) -{ - while (start != finish) { - const unsigned char c = *start; - if (c >= special_char_noescape_min) { - wp[0] = c; /* no need to escape */ - } else { - wp[0] = special_char_escape_prefix; - ++wp; - wp[0] = c + special_char_escape_shift; - } - ++start; - ++wp; - } -} - -void -escape_string(string_buffer& ar, const char *start, const char *finish) -{ - const size_t buflen = (finish - start) * 2; - char *const wp_begin = ar.make_space(buflen); - char *wp = wp_begin; - escape_string(wp, start, finish); - ar.space_wrote(wp - wp_begin); -} - -bool -unescape_string(char *& wp, const char *start, const char *finish) -{ - /* works even if wp == start */ - while (start != finish) { - const unsigned char c = *start; - if (c != special_char_escape_prefix) { - wp[0] = c; - } else if (start + 1 != finish) { - ++start; - const unsigned char cn = *start; - if (cn < special_char_escape_shift) { - return false; - } - wp[0] = cn - special_char_escape_shift; - } else { - return false; - } - ++start; - ++wp; - } - return true; -} - -bool -unescape_string(string_buffer& ar, const char *start, const char *finish) -{ - const size_t buflen = finish - start; - char *const wp_begin = ar.make_space(buflen); - char *wp = wp_begin; - const bool r = unescape_string(wp, start, finish); - ar.space_wrote(wp - wp_begin); - return r; -} - -uint32 -read_ui32(char *& start, char *finish) -{ - char *const n_begin = start; - read_token(start, finish); - char *const n_end = start; - uint32 v = 0; - for (char *p = n_begin; p != n_end; ++p) { - const char ch = p[0]; - if (ch >= '0' && ch <= '9') { - v *= 10; - v += (ch - '0'); - } - } - return v; -} - -void -write_ui32(string_buffer& buf, uint32 v) -{ - char *wp = buf.make_space(12); - int len = snprintf(wp, 12, "%u", v); - if (len > 0) { - buf.space_wrote(len); - } -} - -void -write_ui64(string_buffer& buf, uint64 v) -{ - char *wp = buf.make_space(22); - int len = snprintf(wp, 22, "%llu", static_cast(v)); - if (len > 0) { - buf.space_wrote(len); - } -} - -}; - diff --git a/storage/spider/hs_client/escape.hpp b/storage/spider/hs_client/escape.hpp deleted file mode 100644 index 4c23e16701c..00000000000 --- a/storage/spider/hs_client/escape.hpp +++ /dev/null @@ -1,64 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#include "string_buffer.hpp" -#include "string_ref.hpp" -#include "string_util.hpp" - -#ifndef DENA_ESCAPE_HPP -#define DENA_ESCAPE_HPP - -namespace dena { - -void escape_string(char *& wp, const char *start, const char *finish); -void escape_string(string_buffer& ar, const char *start, const char *finish); -bool unescape_string(char *& wp, const char *start, const char *finish); - /* unescaped_string() works even if wp == start */ -bool unescape_string(string_buffer& ar, const char *start, const char *finish); - -uint32 read_ui32(char *& start, char *finish); -void write_ui32(string_buffer& buf, uint32 v); -void write_ui64(string_buffer& buf, uint64 v); - -inline bool -is_null_expression(const char *start, const char *finish) -{ - return (finish == start + 1 && start[0] == 0); -} - -inline void -read_token(char *& start, char *finish) -{ - char *const p = memchr_char(start, '\t', finish - start); - if (p == 0) { - start = finish; - } else { - start = p; - } -} - -inline void -skip_token_delim_fold(char *& start, char *finish) -{ - while (start != finish && start[0] == '\t') { - ++start; - } -} - -inline void -skip_one(char *& start, char *finish) -{ - if (start != finish) { - ++start; - } -} - -}; - -#endif - diff --git a/storage/spider/hs_client/fatal.cpp b/storage/spider/hs_client/fatal.cpp deleted file mode 100644 index 1ed20189a93..00000000000 --- a/storage/spider/hs_client/fatal.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "fatal.hpp" - -namespace dena { - -/* -const int opt_syslog = LOG_ERR | LOG_PID | LOG_CONS; -*/ - -void -fatal_abort(const String& message) -{ - fprintf(stderr, "FATAL_COREDUMP: %s\n", message.ptr()); -/* - syslog(opt_syslog, "FATAL_COREDUMP: %s", message.ptr()); -*/ - abort(); -} - -void -fatal_abort(const char *message) -{ - fprintf(stderr, "FATAL_COREDUMP: %s\n", message); -/* - syslog(opt_syslog, "FATAL_COREDUMP: %s", message); -*/ - abort(); -} - -}; - diff --git a/storage/spider/hs_client/fatal.hpp b/storage/spider/hs_client/fatal.hpp deleted file mode 100644 index 859b695baf3..00000000000 --- a/storage/spider/hs_client/fatal.hpp +++ /dev/null @@ -1,26 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_FATAL_HPP -#define DENA_FATAL_HPP - -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" -#include "sql_class.h" - -namespace dena { - -void fatal_abort(const String& message); -void fatal_abort(const char *message); - -}; - -#endif - diff --git a/storage/spider/hs_client/hstcpcli.cpp b/storage/spider/hs_client/hstcpcli.cpp deleted file mode 100644 index 791ee9a9e4c..00000000000 --- a/storage/spider/hs_client/hstcpcli.cpp +++ /dev/null @@ -1,662 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "hs_compat.h" -#include "sql_priv.h" -#include "probes_mysql.h" -#include "sql_class.h" - -#include "hstcpcli.hpp" -#include "auto_file.hpp" -#include "string_util.hpp" -#include "auto_addrinfo.hpp" -#include "escape.hpp" -#include "util.hpp" - -/* TODO */ -#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(MSG_NOSIGNAL) -#define MSG_NOSIGNAL 0 -#endif - -#define DBG(x) - -namespace dena { - -hstresult::hstresult() -{ - SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16, - MYF(MY_WME)); -} - -hstresult::~hstresult() -{ - delete_dynamic(&flds); -} - -struct hstcpcli : public hstcpcli_i, private noncopyable { - hstcpcli(const socket_args& args); - virtual ~hstcpcli(); - virtual void close(); - virtual int reconnect(); - virtual bool stable_point(); - virtual void request_buf_open_index(size_t pst_id, const char *dbn, - const char *tbl, const char *idx, const char *retflds, const char *filflds); - virtual void request_buf_auth(const char *secret, const char *typ); - virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op, - const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, - const string_ref& mod_op, const string_ref *mvs, size_t mvslen, - const hstcpcli_filter *fils, size_t filslen, int invalues_keypart, - const string_ref *invalues, size_t invalueslen); - virtual size_t request_buf_append(const char *start, const char *finish); - virtual void request_reset(); - virtual int request_send(); - virtual int response_recv(size_t& num_flds_r); - virtual int get_result(hstresult& result); - virtual const string_ref *get_next_row(); - virtual const string_ref *get_next_row_from_result(hstresult& result); - virtual size_t get_row_size(); - virtual size_t get_row_size_from_result(hstresult& result); - virtual void response_buf_remove(); - virtual int get_error_code(); - virtual String& get_error(); - virtual void clear_error(); - virtual int set_timeout(int send_timeout, int recv_timeout); - virtual size_t get_num_req_bufd() { return num_req_bufd; } - virtual size_t get_num_req_sent() { return num_req_sent; } - virtual size_t get_num_req_rcvd() { return num_req_rcvd; } - virtual size_t get_response_end_offset() { return response_end_offset; } - virtual const char *get_readbuf_begin() { return readbuf.begin(); } - virtual const char *get_readbuf_end() { return readbuf.end(); } - virtual const char *get_writebuf_begin() { return writebuf.begin(); } - virtual size_t get_writebuf_size() { return writebuf.size(); } - virtual void write_error_to_log(const char *func_name, const char *file_name, - ulong line_no); - private: - int read_more(); - int set_error(int code, const String& str); - int set_error(int code, const char *str); - private: - auto_file fd; - socket_args sargs; - string_buffer readbuf; - string_buffer writebuf; - size_t response_end_offset; /* incl newline */ - size_t cur_row_offset; - size_t cur_row_size; - size_t num_flds; - size_t num_req_bufd; /* buffered but not yet sent */ - size_t num_req_sent; /* sent but not yet received */ - size_t num_req_rcvd; /* received but not yet removed */ - int error_code; - String error_str; - DYNAMIC_ARRAY flds; - int errno_buf; -}; - -hstcpcli::hstcpcli(const socket_args& args) - : sargs(args), response_end_offset(0), cur_row_offset(0), cur_row_size(0), - num_flds(0), num_req_bufd(0), num_req_sent(0), num_req_rcvd(0), - error_code(0), errno_buf(0) -{ - String err; - SPD_INIT_DYNAMIC_ARRAY2(&flds, sizeof(string_ref), NULL, 16, 16, MYF(MY_WME)); - if (socket_connect(fd, sargs, err) != 0) { - set_error(-1, err); - } -} - -hstcpcli::~hstcpcli() -{ - delete_dynamic(&flds); -} - -void -hstcpcli::close() -{ - fd.close(); - readbuf.clear(); - writebuf.clear(); - response_end_offset = 0; - cur_row_offset = 0; - num_flds = 0; - num_req_bufd = 0; - num_req_sent = 0; - num_req_rcvd = 0; -} - -int -hstcpcli::reconnect() -{ - clear_error(); - close(); - String err; - if (socket_connect(fd, sargs, err) != 0) { - set_error(-1, err); - } - return error_code; -} - -int -hstcpcli::set_timeout(int send_timeout, int recv_timeout) -{ - String err; - sargs.send_timeout = send_timeout; - sargs.recv_timeout = recv_timeout; - if (socket_set_timeout(fd, sargs, err) != 0) { - set_error(-1, err); - } - return error_code; -} - -bool -hstcpcli::stable_point() -{ - /* returns true if cli can send a new request */ - return fd.get() >= 0 && num_req_bufd == 0 && num_req_sent == 0 && - num_req_rcvd == 0 && response_end_offset == 0; -} - -int -hstcpcli::get_error_code() -{ - return error_code; -} - -String& -hstcpcli::get_error() -{ - return error_str; -} - -int -hstcpcli::read_more() -{ - const size_t block_size = 4096; // FIXME - char *const wp = readbuf.make_space(block_size); - int rlen; - errno = 0; - while ((rlen = read(fd.get(), wp, block_size)) <= 0) { - errno_buf = errno; - if (rlen < 0) { - if (errno == EINTR || errno == EAGAIN) - { - errno = 0; - continue; - } - error_str = String("read: failed", &my_charset_bin); - } else { - error_str = String("read: eof", &my_charset_bin); - } - return rlen; - } - readbuf.space_wrote(rlen); - return rlen; -} - -void -hstcpcli::clear_error() -{ - DBG(fprintf(stderr, "CLEAR_ERROR: %d\n", error_code)); - error_code = 0; - error_str.length(0); -} - -int -hstcpcli::set_error(int code, const String& str) -{ - DBG(fprintf(stderr, "SET_ERROR: %d\n", code)); - error_code = code; - error_str = str; - return error_code; -} - -int -hstcpcli::set_error(int code, const char *str) -{ - uint32 str_len = strlen(str); - DBG(fprintf(stderr, "SET_ERROR: %d\n", code)); - error_code = code; - error_str.length(0); - if (error_str.reserve(str_len + 1)) - return 0; - error_str.q_append(str, str_len); - error_str.c_ptr_safe(); - return error_code; -} - -void -hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn, - const char *tbl, const char *idx, const char *retflds, const char *filflds) -{ -/* - if (num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_rcvd > 0) { - close(); - set_error(-1, "request_buf_open_index: protocol out of sync"); - return; - } - const string_ref dbn_ref(dbn, strlen(dbn)); - const string_ref tbl_ref(tbl, strlen(tbl)); - const string_ref idx_ref(idx, strlen(idx)); - const string_ref rfs_ref(retflds, strlen(retflds)); - writebuf.append_literal("P\t"); - append_uint32(writebuf, pst_id); // FIXME size_t ? - writebuf.append_literal("\t"); - writebuf.append(dbn_ref.begin(), dbn_ref.end()); - writebuf.append_literal("\t"); - writebuf.append(tbl_ref.begin(), tbl_ref.end()); - writebuf.append_literal("\t"); - writebuf.append(idx_ref.begin(), idx_ref.end()); - writebuf.append_literal("\t"); - writebuf.append(rfs_ref.begin(), rfs_ref.end()); - if (filflds != 0) { - const string_ref fls_ref(filflds, strlen(filflds)); - writebuf.append_literal("\t"); - writebuf.append(fls_ref.begin(), fls_ref.end()); - } - writebuf.append_literal("\n"); - ++num_req_bufd; -} - -void -hstcpcli::request_buf_auth(const char *secret, const char *typ) -{ -/* - if (num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_rcvd > 0) { - close(); - set_error(-1, "request_buf_auth: protocol out of sync"); - return; - } - if (typ == 0) { - typ = "1"; - } - const string_ref typ_ref(typ, strlen(typ)); - const string_ref secret_ref(secret, strlen(secret)); - writebuf.append_literal("A\t"); - writebuf.append(typ_ref.begin(), typ_ref.end()); - writebuf.append_literal("\t"); - writebuf.append(secret_ref.begin(), secret_ref.end()); - writebuf.append_literal("\n"); - ++num_req_bufd; -} - -namespace { - -void -append_delim_value(string_buffer& buf, const char *start, const char *finish) -{ - if (start == 0) { - /* null */ - const char t[] = "\t\0"; - buf.append(t, t + 2); - } else { - /* non-null */ - buf.append_literal("\t"); - escape_string(buf, start, finish); - } -} - -}; - -void -hstcpcli::request_buf_exec_generic(size_t pst_id, const string_ref& op, - const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, - const string_ref& mod_op, const string_ref *mvs, size_t mvslen, - const hstcpcli_filter *fils, size_t filslen, int invalues_keypart, - const string_ref *invalues, size_t invalueslen) -{ -/* - if (num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_rcvd > 0) { - close(); - set_error(-1, "request_buf_exec_generic: protocol out of sync"); - return; - } - append_uint32(writebuf, pst_id); // FIXME size_t ? - writebuf.append_literal("\t"); - writebuf.append(op.begin(), op.end()); - writebuf.append_literal("\t"); - append_uint32(writebuf, kvslen); // FIXME size_t ? - for (size_t i = 0; i < kvslen; ++i) { - const string_ref& kv = kvs[i]; - append_delim_value(writebuf, kv.begin(), kv.end()); - } - if (limit != 0 || skip != 0 || invalues_keypart >= 0 || - mod_op.size() != 0 || filslen != 0) { - /* has more option */ - writebuf.append_literal("\t"); - append_uint32(writebuf, limit); // FIXME size_t ? - if (skip != 0 || invalues_keypart >= 0 || - mod_op.size() != 0 || filslen != 0) { - writebuf.append_literal("\t"); - append_uint32(writebuf, skip); // FIXME size_t ? - } - if (invalues_keypart >= 0) { - writebuf.append_literal("\t@\t"); - append_uint32(writebuf, invalues_keypart); - writebuf.append_literal("\t"); - append_uint32(writebuf, invalueslen); - for (size_t i = 0; i < invalueslen; ++i) { - const string_ref& s = invalues[i]; - append_delim_value(writebuf, s.begin(), s.end()); - } - } - for (size_t i = 0; i < filslen; ++i) { - const hstcpcli_filter& f = fils[i]; - writebuf.append_literal("\t"); - writebuf.append(f.filter_type.begin(), f.filter_type.end()); - writebuf.append_literal("\t"); - writebuf.append(f.op.begin(), f.op.end()); - writebuf.append_literal("\t"); - append_uint32(writebuf, f.ff_offset); - append_delim_value(writebuf, f.val.begin(), f.val.end()); - } - if (mod_op.size() != 0) { - writebuf.append_literal("\t"); - writebuf.append(mod_op.begin(), mod_op.end()); - for (size_t i = 0; i < mvslen; ++i) { - const string_ref& mv = mvs[i]; - append_delim_value(writebuf, mv.begin(), mv.end()); - } - } - } - writebuf.append_literal("\n"); - ++num_req_bufd; -} - -size_t -hstcpcli::request_buf_append(const char *start, const char *finish) -{ -/* - if (num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_rcvd > 0) { - close(); - set_error(-1, "request_buf_append: protocol out of sync"); - return 0; - } - const char *nl = start; - size_t num_req = 0; - while ((nl = memchr_char(nl, '\n', finish - nl))) { - if (nl == finish) - break; - num_req++; - nl++; - } - num_req++; - writebuf.append(start, finish); - if (*(finish - 1) != '\n') - writebuf.append_literal("\n"); - num_req_bufd += num_req; - return num_req; -} - -void -hstcpcli::request_reset() -{ - if (num_req_bufd) { - writebuf.erase_front(writebuf.size()); - num_req_bufd = 0; - } -} - -int -hstcpcli::request_send() -{ - if (error_code < 0) { - return error_code; - } - clear_error(); - if (fd.get() < 0) { - close(); - return set_error(-1, "write: closed"); - } -/* - if (num_req_bufd == 0 || num_req_sent > 0 || num_req_rcvd > 0) { -*/ - if (num_req_bufd == 0 || num_req_rcvd > 0) { - close(); - return set_error(-1, "request_send: protocol out of sync"); - } - const size_t wrlen = writebuf.size(); - const ssize_t r = send(fd.get(), writebuf.begin(), wrlen, MSG_NOSIGNAL); - if (r <= 0) { - close(); - return set_error(-1, r < 0 ? "write: failed" : "write: eof"); - } - writebuf.erase_front(r); - if (static_cast(r) != wrlen) { - close(); - return set_error(-1, "write: incomplete"); - } - num_req_sent += num_req_bufd; - num_req_bufd = 0; - DBG(fprintf(stderr, "REQSEND 0\n")); - return 0; -} - -int -hstcpcli::response_recv(size_t& num_flds_r) -{ - if (error_code < 0) { - return error_code; - } - clear_error(); - if (num_req_bufd > 0 || num_req_sent == 0 || num_req_rcvd > 0 || - response_end_offset != 0) { - close(); - return set_error(-1, "response_recv: protocol out of sync"); - } - cur_row_offset = 0; - num_flds_r = num_flds = 0; - if (fd.get() < 0) { - return set_error(-1, "read: closed"); - } - size_t offset = 0; - while (true) { - const char *const lbegin = readbuf.begin() + offset; - const char *const lend = readbuf.end(); - if (lbegin < lend) - { - const char *const nl = memchr_char(lbegin, '\n', lend - lbegin); - if (nl != 0) { - offset += (nl + 1) - lbegin; - break; - } - offset += lend - lbegin; - } - if (read_more() <= 0) { - close(); - error_code = -1; - return error_code; - } - } - response_end_offset = offset; - --num_req_sent; - ++num_req_rcvd; - char *start = readbuf.begin(); - char *const finish = start + response_end_offset - 1; - const size_t resp_code = read_ui32(start, finish); - skip_one(start, finish); - num_flds_r = num_flds = read_ui32(start, finish); - if (resp_code != 0) { - skip_one(start, finish); - char *const err_begin = start; - read_token(start, finish); - char *const err_end = start; - String e = String(err_begin, (uint32)(err_end - err_begin), &my_charset_bin); - if (!e.length()) { - e = String("unknown_error", &my_charset_bin); - } - return set_error(resp_code, e); - } - cur_row_size = 0; - cur_row_offset = start - readbuf.begin(); - DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n", - String(readbuf.begin(), readbuf.begin() + response_end_offset) - .c_str(), - cur_row_offset, response_end_offset)); - DBG(fprintf(stderr, "RES 0\n")); - if (flds.max_element < num_flds) - { - if (allocate_dynamic(&flds, num_flds)) - return set_error(-1, "out of memory"); - } - flds.elements = num_flds; - return 0; -} - -int -hstcpcli::get_result(hstresult& result) -{ -/* - readbuf.swap(result.readbuf); -*/ - char *const wp = result.readbuf.make_space(response_end_offset); - memcpy(wp, readbuf.begin(), response_end_offset); - result.readbuf.space_wrote(response_end_offset); - result.response_end_offset = response_end_offset; - result.num_flds = num_flds; - result.cur_row_size = cur_row_size; - result.cur_row_offset = cur_row_offset; - if (result.flds.max_element < num_flds) - { - if (allocate_dynamic(&result.flds, num_flds)) - return set_error(-1, "out of memory"); - } - result.flds.elements = num_flds; - return 0; -} - -const string_ref * -hstcpcli::get_next_row() -{ - if (num_flds == 0 || flds.elements < num_flds) { - DBG(fprintf(stderr, "GNR NF 0\n")); - return 0; - } - char *start = readbuf.begin() + cur_row_offset; - char *const finish = readbuf.begin() + response_end_offset - 1; - if (start >= finish) { /* start[0] == nl */ - DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish)); - return 0; - } - for (size_t i = 0; i < num_flds; ++i) { - skip_one(start, finish); - char *const fld_begin = start; - read_token(start, finish); - char *const fld_end = start; - char *wp = fld_begin; - if (is_null_expression(fld_begin, fld_end)) { - /* null */ - ((string_ref *) flds.buffer)[i] = string_ref(); - } else { - unescape_string(wp, fld_begin, fld_end); /* in-place */ - ((string_ref *) flds.buffer)[i] = string_ref(fld_begin, wp); - } - } - cur_row_size = start - (readbuf.begin() + cur_row_offset); - cur_row_offset = start - readbuf.begin(); - return (string_ref *) flds.buffer; -} - -const string_ref * -hstcpcli::get_next_row_from_result(hstresult& result) -{ - if (result.num_flds == 0 || result.flds.elements < result.num_flds) { - DBG(fprintf(stderr, "GNR NF 0\n")); - return 0; - } - char *start = result.readbuf.begin() + result.cur_row_offset; - char *const finish = result.readbuf.begin() + result.response_end_offset - 1; - if (start >= finish) { /* start[0] == nl */ - DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish)); - return 0; - } - for (size_t i = 0; i < result.num_flds; ++i) { - skip_one(start, finish); - char *const fld_begin = start; - read_token(start, finish); - char *const fld_end = start; - char *wp = fld_begin; - if (is_null_expression(fld_begin, fld_end)) { - /* null */ - ((string_ref *) result.flds.buffer)[i] = string_ref(); - } else { - unescape_string(wp, fld_begin, fld_end); /* in-place */ - ((string_ref *) result.flds.buffer)[i] = string_ref(fld_begin, wp); - } - } - result.cur_row_size = - start - (result.readbuf.begin() + result.cur_row_offset); - result.cur_row_offset = start - result.readbuf.begin(); - return (string_ref *) result.flds.buffer; -} - -size_t -hstcpcli::get_row_size() -{ - return cur_row_size; -} - -size_t -hstcpcli::get_row_size_from_result(hstresult& result) -{ - return result.cur_row_size; -} - -void -hstcpcli::response_buf_remove() -{ - if (response_end_offset == 0) { - close(); - set_error(-1, "response_buf_remove: protocol out of sync"); - return; - } - readbuf.erase_front(response_end_offset); - response_end_offset = 0; - --num_req_rcvd; - cur_row_offset = 0; - num_flds = 0; -} - -void -hstcpcli::write_error_to_log( - const char *func_name, - const char *file_name, - ulong line_no -) { - if (errno_buf) { - time_t cur_time = (time_t) time((time_t*) 0); - struct tm lt; - struct tm *l_time = localtime_r(&cur_time, <); - fprintf(stderr, - "%04d%02d%02d %02d:%02d:%02d [ERROR] hstcpcli: [%d][%s]" - " [%s][%s][%lu] errno=%d\n", - l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday, - l_time->tm_hour, l_time->tm_min, l_time->tm_sec, - error_code, error_str.c_ptr_safe(), - func_name, file_name, line_no, errno_buf); - } -} - -hstcpcli_ptr -hstcpcli_i::create(const socket_args& args) -{ - return hstcpcli_ptr(new hstcpcli(args)); -} - -}; - diff --git a/storage/spider/hs_client/hstcpcli.hpp b/storage/spider/hs_client/hstcpcli.hpp deleted file mode 100644 index 06044f169a3..00000000000 --- a/storage/spider/hs_client/hstcpcli.hpp +++ /dev/null @@ -1,93 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_HSTCPCLI_HPP -#define DENA_HSTCPCLI_HPP - -#define HANDLERSOCKET_MYSQL_UTIL 1 - -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "config.hpp" -#include "socket.hpp" -#include "string_ref.hpp" -#include "string_buffer.hpp" - -namespace dena { - -struct hstcpcli_filter { - string_ref filter_type; - string_ref op; - size_t ff_offset; - string_ref val; - hstcpcli_filter() : ff_offset(0) { } -}; - -struct hstcpcli_i; -typedef hstcpcli_i *hstcpcli_ptr; - -struct hstresult { - hstresult(); - virtual ~hstresult(); - string_buffer readbuf; - size_t response_end_offset; - size_t num_flds; - size_t cur_row_offset; - size_t cur_row_size; - DYNAMIC_ARRAY flds; -}; - -struct hstcpcli_i { - virtual ~hstcpcli_i() = default; - virtual void close() = 0; - virtual int reconnect() = 0; - virtual bool stable_point() = 0; - virtual void request_buf_auth(const char *secret, const char *typ) = 0; - virtual void request_buf_open_index(size_t pst_id, const char *dbn, - const char *tbl, const char *idx, const char *retflds, - const char *filflds = 0) = 0; - virtual void request_buf_exec_generic(size_t pst_id, const string_ref& op, - const string_ref *kvs, size_t kvslen, uint32 limit, uint32 skip, - const string_ref& mod_op, const string_ref *mvs, size_t mvslen, - const hstcpcli_filter *fils = 0, size_t filslen = 0, - int invalues_keypart = -1, const string_ref *invalues = 0, - size_t invalueslen = 0) = 0; // FIXME: too long - virtual size_t request_buf_append(const char *start, const char *finish) = 0; - virtual void request_reset() = 0; - virtual int request_send() = 0; - virtual int response_recv(size_t& num_flds_r) = 0; - virtual int get_result(hstresult& result) = 0; - virtual const string_ref *get_next_row() = 0; - virtual const string_ref *get_next_row_from_result(hstresult& result) = 0; - virtual size_t get_row_size() = 0; - virtual size_t get_row_size_from_result(hstresult& result) = 0; - virtual void response_buf_remove() = 0; - virtual int get_error_code() = 0; - virtual String& get_error() = 0; - virtual void clear_error() = 0; - virtual int set_timeout(int send_timeout, int recv_timeout) = 0; - virtual size_t get_num_req_bufd() = 0; - virtual size_t get_num_req_sent() = 0; - virtual size_t get_num_req_rcvd() = 0; - virtual size_t get_response_end_offset() = 0; - virtual const char *get_readbuf_begin() = 0; - virtual const char *get_readbuf_end() = 0; - virtual const char *get_writebuf_begin() = 0; - virtual size_t get_writebuf_size() = 0; - virtual void write_error_to_log(const char *func_name, const char *file_name, - ulong line_no) = 0; - static hstcpcli_ptr create(const socket_args& args); -}; - -}; - -#endif - diff --git a/storage/spider/hs_client/mutex.hpp b/storage/spider/hs_client/mutex.hpp deleted file mode 100644 index 8e331fb6ab2..00000000000 --- a/storage/spider/hs_client/mutex.hpp +++ /dev/null @@ -1,48 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_MUTEX_HPP -#define DENA_MUTEX_HPP - -#include "fatal.hpp" -#include "util.hpp" - -namespace dena { - -struct condition; - -struct mutex : private noncopyable { - friend struct condition; - mutex() { - if (pthread_mutex_init(&mtx, 0) != 0) { - fatal_abort("pthread_mutex_init"); - } - } - ~mutex() { - if (pthread_mutex_destroy(&mtx) != 0) { - fatal_abort("pthread_mutex_destroy"); - } - } - void lock() const { - if (pthread_mutex_lock(&mtx) != 0) { - fatal_abort("pthread_mutex_lock"); - } - } - void unlock() const { - if (pthread_mutex_unlock(&mtx) != 0) { - fatal_abort("pthread_mutex_unlock"); - } - } - private: - mutable pthread_mutex_t mtx; -}; - -}; - -#endif - diff --git a/storage/spider/hs_client/socket.cpp b/storage/spider/hs_client/socket.cpp deleted file mode 100644 index 469acb2725f..00000000000 --- a/storage/spider/hs_client/socket.cpp +++ /dev/null @@ -1,306 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include -#ifndef __WIN__ -#include -#include -#endif - -#include "mysql_version.h" -#include "hs_compat.h" -#include -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "socket.hpp" -#include "string_util.hpp" -#include "fatal.hpp" - -/* -struct sockaddr_un { - short sun_family; - char sun_path[108]; -}; -*/ - -namespace dena { - -void -ignore_sigpipe() -{ -#if defined(SIGPIPE) && !defined(__WIN__) - if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { - fatal_abort("SIGPIPE SIG_IGN"); - } -#endif -} - -void -socket_args::set(const config& conf) -{ - timeout = (int) conf.get_int("timeout", 600); - listen_backlog = (int) conf.get_int("listen_backlog", 256); - String node = conf.get_str("host", ""); - String port = conf.get_str("port", ""); - if (node.length() || port.length()) { - if (family == AF_UNIX || !strcmp(node.c_ptr(), "/")) { - set_unix_domain(port.c_ptr()); - } else { - const char *nd = !node.length() ? 0 : node.c_ptr(); - if (resolve(nd, port.c_ptr()) != 0) { - String message("getaddrinfo failed: ", &my_charset_bin); - message.reserve(node.length() + sizeof(":") - 1 + port.length()); - message.append(node); - message.q_append(":", sizeof(":") - 1); - message.append(port); - fatal_abort(message); - } - } - } - sndbuf = (int) conf.get_int("sndbuf", 0); - rcvbuf = (int) conf.get_int("rcvbuf", 0); -} - -void -socket_args::set_unix_domain(const char *path) -{ -#ifndef __WIN__ - family = AF_UNIX; - addr = sockaddr_storage(); - addrlen = sizeof(sockaddr_un); - sockaddr_un *const ap = reinterpret_cast(&addr); - ap->sun_family = AF_UNIX; - strncpy(ap->sun_path, path, sizeof(ap->sun_path) - 1); -#endif -} - -int -socket_args::resolve(const char *node, const char *service) -{ - const int flags = (node == 0) ? AI_PASSIVE : 0; - auto_addrinfo ai; - addr = sockaddr_storage(); - addrlen = 0; - const int r = ai.resolve(node, service, flags, family, socktype, protocol); - if (r != 0) { - return r; - } - memcpy(&addr, ai.get()->ai_addr, ai.get()->ai_addrlen); - addrlen = ai.get()->ai_addrlen; - return 0; -} - -int -socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r) -{ - if (!args.nonblocking) { -#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) - if (args.recv_timeout != 0) { -#ifndef __WIN__ - struct timeval tv; - tv.tv_sec = args.recv_timeout; - tv.tv_usec = 0; -#else - int tv = args.recv_timeout * 1000; -#endif - if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO, -#ifndef __WIN__ - (const void *) &tv, -#else - (const char *) &tv, -#endif - sizeof(tv)) != 0) { - return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); - } - } - if (args.send_timeout != 0) { -#ifndef __WIN__ - struct timeval tv; - tv.tv_sec = args.send_timeout; - tv.tv_usec = 0; -#else - int tv = args.send_timeout * 1000; -#endif - if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO, -#ifndef __WIN__ - (const void *) &tv, -#else - (const char *) &tv, -#endif - sizeof(tv)) != 0) { - return errno_string("setsockopt SO_SNDTIMEO", errno, err_r); - } - } -#endif - } - return 0; -} - -int -socket_set_options(auto_file& fd, const socket_args& args, String& err_r) -{ - if (args.timeout != 0 && !args.nonblocking) { -#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) -#ifndef __WIN__ - struct timeval tv; - tv.tv_sec = args.timeout; - tv.tv_usec = 0; -#else - int tv = args.timeout * 1000; -#endif - if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO, -#ifndef __WIN__ - (const void *) &tv, -#else - (const char *) &tv, -#endif - sizeof(tv)) != 0) { - return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); - } -#ifndef __WIN__ - tv.tv_sec = args.timeout; - tv.tv_usec = 0; -#else - tv = args.timeout * 1000; -#endif - if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO, -#ifndef __WIN__ - (const void *) &tv, -#else - (const char *) &tv, -#endif - sizeof(tv)) != 0) { - return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); - } -#endif - } -#ifndef __WIN__ - if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) { - return errno_string("fcntl O_NONBLOCK", errno, err_r); - } -#endif - if (args.sndbuf != 0) { - const int v = args.sndbuf; - if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDBUF, -#ifndef __WIN__ - (const void *) &v, -#else - (const char *) &v, -#endif - sizeof(v)) != 0) { - return errno_string("setsockopt SO_SNDBUF", errno, err_r); - } - } - if (args.rcvbuf != 0) { - const int v = args.rcvbuf; - if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVBUF, -#ifndef __WIN__ - (const void *) &v, -#else - (const char *) &v, -#endif - sizeof(v)) != 0) { - return errno_string("setsockopt SO_RCVBUF", errno, err_r); - } - } - return 0; -} - -int -socket_open(auto_file& fd, const socket_args& args, String& err_r) -{ - fd.reset((int) socket(args.family, args.socktype, args.protocol)); - if (fd.get() < 0) { - return errno_string("socket", errno, err_r); - } - return socket_set_options(fd, args, err_r); -} - -int -socket_connect(auto_file& fd, const socket_args& args, String& err_r) -{ - int r = 0; - if ((r = socket_open(fd, args, err_r)) != 0) { - return r; - } - if (connect(fd.get(), reinterpret_cast(&args.addr), - args.addrlen) != 0) { - if (!args.nonblocking -#ifndef __WIN__ - || errno != EINPROGRESS -#endif - ) { - return errno_string("connect", errno, err_r); - } - } - return 0; -} - -int -socket_bind(auto_file& fd, const socket_args& args, String& err_r) -{ - fd.reset((int) socket(args.family, args.socktype, args.protocol)); - if (fd.get() < 0) { - return errno_string("socket", errno, err_r); - } - if (args.reuseaddr) { -#ifndef __WIN__ - if (args.family == AF_UNIX) { - const sockaddr_un *const ap = - reinterpret_cast(&args.addr); - if (unlink(ap->sun_path) != 0 && errno != ENOENT) { - return errno_string("unlink uds", errno, err_r); - } - } else { -#endif - int v = 1; - if (setsockopt(fd.get(), SOL_SOCKET, SO_REUSEADDR, -#ifndef __WIN__ - (const void *) &v, -#else - (const char *) &v, -#endif - sizeof(v)) != 0) { - return errno_string("setsockopt SO_REUSEADDR", errno, err_r); - } -#ifndef __WIN__ - } -#endif - } - if (bind(fd.get(), reinterpret_cast(&args.addr), - args.addrlen) != 0) { - return errno_string("bind", errno, err_r); - } - if (listen(fd.get(), args.listen_backlog) != 0) { - return errno_string("listen", errno, err_r); - } -#ifndef __WIN__ - if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) { - return errno_string("fcntl O_NONBLOCK", errno, err_r); - } -#endif - return 0; -} - -int -socket_accept(int listen_fd, auto_file& fd, const socket_args& args, - sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r) -{ - fd.reset((int) accept(listen_fd, reinterpret_cast(&addr_r), - &addrlen_r)); - if (fd.get() < 0) { - return errno_string("accept", errno, err_r); - } - return socket_set_options(fd, args, err_r); -} - -}; - diff --git a/storage/spider/hs_client/socket.hpp b/storage/spider/hs_client/socket.hpp deleted file mode 100644 index e4f7530aec9..00000000000 --- a/storage/spider/hs_client/socket.hpp +++ /dev/null @@ -1,57 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_SOCKET_HPP -#define DENA_SOCKET_HPP - -#include "mysql_version.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "auto_addrinfo.hpp" -#include "auto_file.hpp" -#include "config.hpp" - -namespace dena { - -struct socket_args { - sockaddr_storage addr; - socklen_t addrlen; - int family; - int socktype; - int protocol; - int timeout; - int send_timeout; - int recv_timeout; - int listen_backlog; - bool reuseaddr; - bool nonblocking; - bool use_epoll; - int sndbuf; - int rcvbuf; - socket_args() : addr(), addrlen(0), family(AF_INET), socktype(SOCK_STREAM), - protocol(0), timeout(600), send_timeout(600), recv_timeout(600), - listen_backlog(256), reuseaddr(true), nonblocking(false), use_epoll(false), - sndbuf(0), rcvbuf(0) { } - void set(const config& conf); - void set_unix_domain(const char *path); - int resolve(const char *node, const char *service); -}; - -void ignore_sigpipe(); -int socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r); -int socket_bind(auto_file& fd, const socket_args& args, String& err_r); -int socket_connect(auto_file& fd, const socket_args& args, String& err_r); -int socket_accept(int listen_fd, auto_file& fd, const socket_args& args, - sockaddr_storage& addr_r, socklen_t& addrlen_r, String& err_r); - -}; - -#endif - diff --git a/storage/spider/hs_client/string_buffer.hpp b/storage/spider/hs_client/string_buffer.hpp deleted file mode 100644 index c9a6074819b..00000000000 --- a/storage/spider/hs_client/string_buffer.hpp +++ /dev/null @@ -1,146 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_STRING_BUFFER_HPP -#define DENA_STRING_BUFFER_HPP - -/* -#include -#include -*/ - -#include "util.hpp" -#include "allocator.hpp" -#include "fatal.hpp" - -namespace dena { - -struct string_buffer : private noncopyable { - string_buffer() : buffer(0), begin_offset(0), end_offset(0), alloc_size(0) { } - ~string_buffer() { - real_free(); - } - void real_free() { - if (alloc_size) { - DENA_FREE(buffer); - buffer = 0; - begin_offset = 0; - end_offset = 0; - alloc_size = 0; - } - } - size_t real_size() { - return alloc_size; - } - const char *begin() const { - return buffer + begin_offset; - } - const char *end() const { - return buffer + end_offset; - } - char *begin() { - return buffer + begin_offset; - } - char *end() { - return buffer + end_offset; - } - size_t size() const { - return end_offset - begin_offset; - } - void clear() { - begin_offset = end_offset = 0; - } - void resize(size_t len) { - if (size() < len) { - reserve(len); - memset(buffer + end_offset, 0, len - size()); - } - end_offset = begin_offset + len; - } - void reserve(size_t len) { - if (alloc_size >= begin_offset + len) { - return; - } - size_t asz = alloc_size; - while (asz < begin_offset + len) { - if (asz == 0) { - asz = 16; - } - const size_t asz_n = asz << 1; - if (asz_n < asz) { - fatal_abort("string_buffer::resize() overflow"); - } - asz = asz_n; - } - void *const p = DENA_REALLOC(buffer, asz); - if (p == 0) { - fatal_abort("string_buffer::resize() realloc"); - } - buffer = static_cast(p); - alloc_size = asz; - } - void erase_front(size_t len) { - if (len >= size()) { - clear(); - } else { - begin_offset += len; - } - } - char *make_space(size_t len) { - reserve(size() + len); - return buffer + end_offset; - } - void space_wrote(size_t len) { - len = len < alloc_size - end_offset ? len : alloc_size - end_offset; - end_offset += len; - } - template - void append_literal(const char (& str)[N]) { - append(str, str + N - 1); - } - void append(const char *start, const char *finish) { - const size_t len = finish - start; - reserve(size() + len); - memcpy(buffer + end_offset, start, len); - end_offset += len; - } - void append_2(const char *s1, const char *f1, const char *s2, - const char *f2) { - const size_t l1 = f1 - s1; - const size_t l2 = f2 - s2; - reserve(end_offset + l1 + l2); - memcpy(buffer + end_offset, s1, l1); - memcpy(buffer + end_offset + l1, s2, l2); - end_offset += l1 + l2; - } - void swap(string_buffer& sb) { - char *tmp_buffer = buffer; - size_t tmp_begin_offset = begin_offset; - size_t tmp_end_offset = end_offset; - size_t tmp_alloc_size = alloc_size; - buffer = sb.buffer; - begin_offset = sb.begin_offset; - end_offset = sb.end_offset; - alloc_size = sb.alloc_size; - sb.buffer = tmp_buffer; - sb.begin_offset = tmp_begin_offset; - sb.end_offset = tmp_end_offset; - sb.alloc_size = tmp_alloc_size; - } - private: - char *buffer; - size_t begin_offset; - size_t end_offset; - size_t alloc_size; -}; - -}; - -#endif - diff --git a/storage/spider/hs_client/string_ref.hpp b/storage/spider/hs_client/string_ref.hpp deleted file mode 100644 index 028c4146c73..00000000000 --- a/storage/spider/hs_client/string_ref.hpp +++ /dev/null @@ -1,106 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_STRING_REF_HPP -#define DENA_STRING_REF_HPP - -namespace dena { - -struct string_wref { - typedef char value_type; - char *begin() const { return start; } - char *end() const { return start + length; } - size_t size() const { return length; } - private: - char *start; - size_t length; - public: - string_wref(char *s = 0, size_t len = 0) : start(s), length(len) { } -}; - -struct string_ref { - typedef const char value_type; - const char *begin() const { return start; } - const char *end() const { return start + length; } - size_t size() const { return length; } - void set(const char *s, size_t len) { start = s; length = len; } - void set(const char *s, const char *f) { start = s; length = f - s; } - private: - const char *start; - size_t length; - public: - string_ref(const char *s = 0, size_t len = 0) : start(s), length(len) { } - string_ref(const char *s, const char *f) : start(s), length(f - s) { } - string_ref(const string_wref& w) : start(w.begin()), length(w.size()) { } -}; - -template inline bool -operator ==(const string_ref& x, const char (& y)[N]) { - return (x.size() == N - 1) && (::memcmp(x.begin(), y, N - 1) == 0); -} - -inline bool -operator ==(const string_ref& x, const string_ref& y) { - return (x.size() == y.size()) && - (::memcmp(x.begin(), y.begin(), x.size()) == 0); -} - -inline bool -operator !=(const string_ref& x, const string_ref& y) { - return (x.size() != y.size()) || - (::memcmp(x.begin(), y.begin(), x.size()) != 0); -} - -struct string_ref_list_wrap { - string_ref_list_wrap() { - if (SPD_INIT_DYNAMIC_ARRAY2(&string_ref_list, sizeof(string_ref), - NULL, 16, 16, MYF(MY_WME))) - string_ref_list_init = FALSE; - else - string_ref_list_init = TRUE; - } - virtual ~string_ref_list_wrap() { - if (string_ref_list_init) delete_dynamic(&string_ref_list); } - void clear() { - if (string_ref_list_init) string_ref_list.elements = 0; } - void push_back(string_ref &e) { - if (string_ref_list_init) insert_dynamic(&string_ref_list, (uchar*) &e); - return; } - size_t size() { - return string_ref_list_init ? string_ref_list.elements : 0; } - bool resize(size_t new_size) { - if (string_ref_list_init) { - if (string_ref_list.max_element < new_size && allocate_dynamic( - &string_ref_list, new_size)) return TRUE; - string_ref_list.elements = new_size; - return FALSE; - } - return TRUE; - } - bool empty() { - return string_ref_list_init ? string_ref_list.elements ? - FALSE : TRUE : TRUE; } - string_ref &operator [](size_t n) { - return ((string_ref *) (string_ref_list.buffer + - string_ref_list.size_of_element * n))[0]; } - bool string_ref_list_init; - DYNAMIC_ARRAY string_ref_list; -}; - -inline String * -q_append_str(String *str, const char *p) { - uint32 p_len = strlen(p); - if (str->reserve(p_len)) return NULL; - str->q_append(p, p_len); return str; -} - -}; - -#endif - diff --git a/storage/spider/hs_client/string_util.cpp b/storage/spider/hs_client/string_util.cpp deleted file mode 100644 index 647cf877805..00000000000 --- a/storage/spider/hs_client/string_util.cpp +++ /dev/null @@ -1,202 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011-2017 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#include -#include "mysql_version.h" -#include "hs_compat.h" -#include "sql_priv.h" -#include "probes_mysql.h" - -#include "string_util.hpp" - -namespace dena { - -string_wref -get_token(char *& wp, char *wp_end, char delim) -{ - char *const wp_begin = wp; - char *const p = memchr_char(wp_begin, delim, wp_end - wp_begin); - if (p == 0) { - wp = wp_end; - return string_wref(wp_begin, wp_end - wp_begin); - } - wp = p + 1; - return string_wref(wp_begin, p - wp_begin); -} - -uint32 -atoi_uint32_nocheck(const char *start, const char *finish) -{ - uint32 v = 0; - for (; start != finish; ++start) { - const char c = *start; - if (c < '0' || c > '9') { - break; - } - v *= 10; - v += (uint32) (c - '0'); - } - return v; -} - -long long -atoll_nocheck(const char *start, const char *finish) -{ - long long v = 0; - bool negative = false; - if (start != finish) { - if (start[0] == '-') { - ++start; - negative = true; - } else if (start[0] == '+') { - ++start; - } - } - for (; start != finish; ++start) { - const char c = *start; - if (c < '0' || c > '9') { - break; - } - v *= 10; - if (negative) { - v -= (long long) (c - '0'); - } else { - v += (long long) (c - '0'); - } - } - return v; -} - -void -append_uint32(string_buffer& buf, uint32 v) -{ - char *const wp = buf.make_space(64); - const int len = snprintf(wp, 64, "%lu", static_cast(v)); - if (len > 0) { - buf.space_wrote(len); - } -} - -/* -String * -to_stdstring(uint32 v) -{ - char buf[64]; - int str_len; - String *str; - str_len = snprintf(buf, sizeof(buf), "%lu", static_cast(v)); - if ((str = new String(str_len + 1))) - str->q_append(buf, str_len); - return str; -} -*/ - -int -errno_string(const char *s, int en, String& err_r) -{ - char buf[64]; - int str_len; - str_len = snprintf(buf, sizeof(buf), "%s: %d", s, en); - if (!err_r.reserve(str_len + 1)) - err_r.q_append(buf, str_len); - return en; -} - -size_t -split(char delim, const string_ref& buf, string_ref *parts, - size_t parts_len) -{ - size_t i = 0; - const char *start = buf.begin(); - const char *const finish = buf.end(); - for (i = 0; i < parts_len; ++i) { - const char *const p = memchr_char(start, delim, finish - start); - if (p == 0) { - parts[i] = string_ref(start, finish - start); - ++i; - break; - } - parts[i] = string_ref(start, p - start); - start = p + 1; - } - const size_t r = i; - for (; i < parts_len; ++i) { - parts[i] = string_ref(); - } - return r; -} - -size_t -split(char delim, const string_wref& buf, string_wref *parts, - size_t parts_len) -{ - size_t i = 0; - char *start = buf.begin(); - char *const finish = buf.end(); - for (i = 0; i < parts_len; ++i) { - char *const p = memchr_char(start, delim, finish - start); - if (p == 0) { - parts[i] = string_wref(start, finish - start); - ++i; - break; - } - parts[i] = string_wref(start, p - start); - start = p + 1; - } - const size_t r = i; - for (; i < parts_len; ++i) { - parts[i] = string_wref(); - } - return r; -} - -size_t -split(char delim, const string_ref& buf, DYNAMIC_ARRAY& parts_r) -{ - size_t i = 0; - const char *start = buf.begin(); - const char *finish = buf.end(); - while (true) { - const char *p = memchr_char(start, delim, finish - start); - if (p == 0) { - string_ref param(start, finish - start); - insert_dynamic(&parts_r, (uchar *) ¶m); - break; - } - string_ref param(start, p - start); - insert_dynamic(&parts_r, (uchar *) ¶m); - start = p + 1; - } - const size_t r = i; - return r; -} - -size_t -split(char delim, const string_wref& buf, DYNAMIC_ARRAY& parts_r) -{ - size_t i = 0; - char *start = buf.begin(); - char *finish = buf.end(); - while (true) { - char *p = memchr_char(start, delim, finish - start); - if (p == 0) { - string_wref param(start, finish - start); - insert_dynamic(&parts_r, (uchar *) ¶m); - break; - } - string_wref param(start, p - start); - insert_dynamic(&parts_r, (uchar *) ¶m); - start = p + 1; - } - const size_t r = i; - return r; -} - -}; - diff --git a/storage/spider/hs_client/string_util.hpp b/storage/spider/hs_client/string_util.hpp deleted file mode 100644 index b886addecfb..00000000000 --- a/storage/spider/hs_client/string_util.hpp +++ /dev/null @@ -1,51 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_STRING_UTIL_HPP -#define DENA_STRING_UTIL_HPP - -#include "string_buffer.hpp" -#include "string_ref.hpp" - -namespace dena { - -inline const char * -memchr_char(const char *s, int c, size_t n) -{ - return static_cast(memchr(s, c, n)); -} - -inline char * -memchr_char(char *s, int c, size_t n) -{ - return static_cast(memchr(s, c, n)); -} - -string_wref get_token(char *& wp, char *wp_end, char delim); -uint32 atoi_uint32_nocheck(const char *start, const char *finish); -/* -String *to_stdstring(uint32 v); -*/ -void append_uint32(string_buffer& buf, uint32 v); -long long atoll_nocheck(const char *start, const char *finish); - -int errno_string(const char *s, int en, String& err_r); - -size_t split(char delim, const string_ref& buf, string_ref *parts, - size_t parts_len); -size_t split(char delim, const string_wref& buf, string_wref *parts, - size_t parts_len); -size_t split(char delim, const string_ref& buf, - DYNAMIC_ARRAY& parts_r); -size_t split(char delim, const string_wref& buf, - DYNAMIC_ARRAY& parts_r); -}; - -#endif - diff --git a/storage/spider/hs_client/thread.hpp b/storage/spider/hs_client/thread.hpp deleted file mode 100644 index 79fba706a42..00000000000 --- a/storage/spider/hs_client/thread.hpp +++ /dev/null @@ -1,84 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. - * Copyright (C) 2011 Kentoku SHIBA - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_THREAD_HPP -#define DENA_THREAD_HPP - -#include "fatal.hpp" - -namespace dena { - -/* -template -struct thread : private noncopyable { - template thread(const Ta& arg, size_t stack_sz = 256 * 1024) - : obj(arg), thr(0), need_join(false), stack_size(stack_sz) { } - template thread(const Ta0& a0, - volatile Ta1& a1, size_t stack_sz = 256 * 1024) - : obj(a0, a1), thr(0), need_join(false), stack_size(stack_sz) { } - ~thread() { - join(); - } - void start() { - if (!start_nothrow()) { - fatal_abort("thread::start"); - } - } - bool start_nothrow() { - if (need_join) { - return need_join; - } - void *const arg = this; - pthread_attr_t attr; - if (pthread_attr_init(&attr) != 0) { - fatal_abort("pthread_attr_init"); - } - if (pthread_attr_setstacksize(&attr, stack_size) != 0) { - fatal_abort("pthread_attr_setstacksize"); - } - const int r = pthread_create(&thr, &attr, thread_main, arg); - if (pthread_attr_destroy(&attr) != 0) { - fatal_abort("pthread_attr_destroy"); - } - if (r != 0) { - return need_join; - } - need_join = true; - return need_join; - } - void join() { - if (!need_join) { - return; - } - int e = 0; - if ((e = pthread_join(thr, 0)) != 0) { - fatal_abort("pthread_join"); - } - need_join = false; - } - T& operator *() { return obj; } - T *operator ->() { return &obj; } - private: - static void *thread_main(void *arg) { - thread *p = static_cast(arg); - p->obj(); - return 0; - } - private: - T obj; - pthread_t thr; - bool need_join; - size_t stack_size; -}; -*/ - -}; - -#endif - diff --git a/storage/spider/hs_client/util.hpp b/storage/spider/hs_client/util.hpp deleted file mode 100644 index 60b5441703d..00000000000 --- a/storage/spider/hs_client/util.hpp +++ /dev/null @@ -1,25 +0,0 @@ - -// vim:sw=2:ai - -/* - * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved. - * See COPYRIGHT.txt for details. - */ - -#ifndef DENA_UTIL_HPP -#define DENA_UTIL_HPP - -namespace dena { - -/* boost::noncopyable */ -struct noncopyable { - noncopyable() = default; - private: - noncopyable(const noncopyable&); - noncopyable& operator =(const noncopyable&); -}; - -}; - -#endif - diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index a9f89048966..1ac0c8f9b73 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -103,20 +103,6 @@ const char *spider_open_connections_func_name; const char *spider_open_connections_file_name; ulong spider_open_connections_line_no; pthread_mutex_t spider_conn_mutex; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -HASH spider_hs_r_conn_hash; -uint spider_hs_r_conn_hash_id; -const char *spider_hs_r_conn_hash_func_name; -const char *spider_hs_r_conn_hash_file_name; -ulong spider_hs_r_conn_hash_line_no; -pthread_mutex_t spider_hs_r_conn_mutex; -HASH spider_hs_w_conn_hash; -uint spider_hs_w_conn_hash_id; -const char *spider_hs_w_conn_hash_func_name; -const char *spider_hs_w_conn_hash_file_name; -ulong spider_hs_w_conn_hash_line_no; -pthread_mutex_t spider_hs_w_conn_mutex; -#endif /* for spider_open_connections and trx_conn_hash */ uchar *spider_conn_get_key( @@ -310,10 +296,6 @@ void spider_free_conn_from_trx( spider_conn_clear_queue(conn); conn->use_for_active_standby = FALSE; conn->error_mode = 1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if ( trx_free || ( @@ -412,134 +394,6 @@ void spider_free_conn_from_trx( } } else if (roop_count) (*roop_count)++; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider_db_hs_request_buf_reset(conn); - if ( - trx_free || - ( - ( - conn->server_lost || - spider_param_hs_r_conn_recycle_mode(trx->thd) != 2 - ) && - !conn->opened_handlers - ) - ) { - conn->thd = NULL; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&trx->trx_hs_r_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&trx->trx_hs_r_conn_hash, (uchar*) conn); -#endif - - DBUG_ASSERT(conn->opened_handlers == - conn->db_conn->get_opened_handler_count()); - if (conn->db_conn->get_opened_handler_count()) - { - conn->db_conn->reset_opened_handler(); - } - - if ( - !trx_free && - !conn->server_lost && - !conn->queued_connect && - spider_param_hs_r_conn_recycle_mode(trx->thd) == 1 - ) { - /* conn_recycle_mode == 1 */ - *conn->conn_key = '0'; - pthread_mutex_lock(&spider_hs_r_conn_mutex); - uint old_elements = spider_hs_r_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_hs_r_conn_hash, - conn->conn_key_hash_value, (uchar*) conn)) -#else - if (my_hash_insert(&spider_hs_r_conn_hash, (uchar*) conn)) -#endif - { - pthread_mutex_unlock(&spider_hs_r_conn_mutex); - spider_free_conn(conn); - } else { - if (spider_hs_r_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - spider_hs_r_conn_hash, - (spider_hs_r_conn_hash.array.max_element - old_elements) * - spider_hs_r_conn_hash.array.size_of_element); - } - pthread_mutex_unlock(&spider_hs_r_conn_mutex); - } - } else { - /* conn_recycle_mode == 0 */ - spider_free_conn(conn); - } - } else if (roop_count) - (*roop_count)++; - } else { - spider_db_hs_request_buf_reset(conn); - if ( - trx_free || - ( - ( - conn->server_lost || - spider_param_hs_w_conn_recycle_mode(trx->thd) != 2 - ) && - !conn->opened_handlers - ) - ) { - conn->thd = NULL; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&trx->trx_hs_w_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&trx->trx_hs_w_conn_hash, (uchar*) conn); -#endif - - DBUG_ASSERT(conn->opened_handlers == - conn->db_conn->get_opened_handler_count()); - if (conn->db_conn->get_opened_handler_count()) - { - conn->db_conn->reset_opened_handler(); - } - - if ( - !trx_free && - !conn->server_lost && - !conn->queued_connect && - spider_param_hs_w_conn_recycle_mode(trx->thd) == 1 - ) { - /* conn_recycle_mode == 1 */ - *conn->conn_key = '0'; - pthread_mutex_lock(&spider_hs_w_conn_mutex); - uint old_elements = spider_hs_w_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&spider_hs_w_conn_hash, - conn->conn_key_hash_value, (uchar*) conn)) -#else - if (my_hash_insert(&spider_hs_w_conn_hash, (uchar*) conn)) -#endif - { - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - spider_free_conn(conn); - } else { - if (spider_hs_w_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - spider_hs_w_conn_hash, - (spider_hs_w_conn_hash.array.max_element - old_elements) * - spider_hs_w_conn_hash.array.size_of_element); - } - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - } - } else { - /* conn_recycle_mode == 0 */ - spider_free_conn(conn); - } - } else if (roop_count) - (*roop_count)++; - } -#endif DBUG_VOID_RETURN; } @@ -567,10 +421,6 @@ SPIDER_CONN *spider_create_conn( UTC = my_tz_find(current_thd, &tz_00_name); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif bool tables_on_different_db_are_joinable; if (share->sql_dbton_ids[link_idx] != SPIDER_DBTON_SIZE) { @@ -727,113 +577,13 @@ SPIDER_CONN *spider_create_conn( conn->tgt_port = share->tgt_ports[link_idx]; conn->tgt_ssl_vsc = share->tgt_ssl_vscs[link_idx]; conn->dbton_id = share->sql_dbton_ids[link_idx]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) { - if (!(conn = (SPIDER_CONN *) - spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_CONN_3, MYF(MY_WME | MY_ZEROFILL), - &conn, (uint) (sizeof(*conn)), - &tmp_name, (uint) (share->hs_read_conn_keys_lengths[link_idx] + 1), - &tmp_host, (uint) (share->tgt_hosts_lengths[link_idx] + 1), - &tmp_socket, (uint) (share->hs_read_socks_lengths[link_idx] + 1), - &tmp_wrapper, - (uint) (share->tgt_wrappers_lengths[link_idx] + 1), - &need_mon, (uint) (sizeof(int)), - NullS)) - ) { - *error_num = HA_ERR_OUT_OF_MEM; - goto error_alloc_conn; - } - - conn->default_database.init_calc_mem(SPD_MID_CREATE_CONN_4); - conn->conn_key_length = share->hs_read_conn_keys_lengths[link_idx]; - conn->conn_key = tmp_name; - memcpy(conn->conn_key, share->hs_read_conn_keys[link_idx], - share->hs_read_conn_keys_lengths[link_idx]); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - conn->conn_key_hash_value = share->hs_read_conn_keys_hash_value[link_idx]; -#endif - conn->tgt_host_length = share->tgt_hosts_lengths[link_idx]; - conn->tgt_host = tmp_host; - memcpy(conn->tgt_host, share->tgt_hosts[link_idx], - share->tgt_hosts_lengths[link_idx]); - conn->hs_sock_length = share->hs_read_socks_lengths[link_idx]; - if (conn->hs_sock_length) - { - conn->hs_sock = tmp_socket; - memcpy(conn->hs_sock, share->hs_read_socks[link_idx], - share->hs_read_socks_lengths[link_idx]); - } else - conn->hs_sock = NULL; - conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx]; - conn->tgt_wrapper = tmp_wrapper; - memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx], - share->tgt_wrappers_lengths[link_idx]); - conn->hs_port = share->hs_read_ports[link_idx]; - conn->dbton_id = share->hs_dbton_ids[link_idx]; - } else { - if (!(conn = (SPIDER_CONN *) - spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_CONN_5, MYF(MY_WME | MY_ZEROFILL), - &conn, (uint) (sizeof(*conn)), - &tmp_name, (uint) (share->hs_write_conn_keys_lengths[link_idx] + 1), - &tmp_host, (uint) (share->tgt_hosts_lengths[link_idx] + 1), - &tmp_socket, (uint) (share->hs_write_socks_lengths[link_idx] + 1), - &tmp_wrapper, - (uint) (share->tgt_wrappers_lengths[link_idx] + 1), - &need_mon, (uint) (sizeof(int)), - NullS)) - ) { - *error_num = HA_ERR_OUT_OF_MEM; - goto error_alloc_conn; - } - - conn->default_database.init_calc_mem(SPD_MID_CREATE_CONN_6); - conn->conn_key_length = share->hs_write_conn_keys_lengths[link_idx]; - conn->conn_key = tmp_name; - memcpy(conn->conn_key, share->hs_write_conn_keys[link_idx], - share->hs_write_conn_keys_lengths[link_idx]); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - conn->conn_key_hash_value = share->hs_write_conn_keys_hash_value[link_idx]; -#endif - conn->tgt_host_length = share->tgt_hosts_lengths[link_idx]; - conn->tgt_host = tmp_host; - memcpy(conn->tgt_host, share->tgt_hosts[link_idx], - share->tgt_hosts_lengths[link_idx]); - conn->hs_sock_length = share->hs_write_socks_lengths[link_idx]; - if (conn->hs_sock_length) - { - conn->hs_sock = tmp_socket; - memcpy(conn->hs_sock, share->hs_write_socks[link_idx], - share->hs_write_socks_lengths[link_idx]); - } else - conn->hs_sock = NULL; - conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx]; - conn->tgt_wrapper = tmp_wrapper; - memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx], - share->tgt_wrappers_lengths[link_idx]); - conn->hs_port = share->hs_write_ports[link_idx]; - conn->dbton_id = share->hs_dbton_ids[link_idx]; - } -#endif if (conn->dbton_id == SPIDER_DBTON_SIZE) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif my_printf_error( ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, MYF(0), conn->tgt_wrapper); *error_num = ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - my_printf_error( - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, - MYF(0), conn->tgt_wrapper); - *error_num = ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM; - } -#endif goto error_invalid_wrapper; } if (!(conn->db_conn = spider_dbton[conn->dbton_id].create_db_conn(conn))) @@ -957,33 +707,11 @@ SPIDER_CONN *spider_get_conn( DBUG_PRINT("info",("spider link_idx=%u", link_idx)); DBUG_PRINT("info",("spider base_link_idx=%u", base_link_idx)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif #ifdef DBUG_TRACE spider_print_keys(conn_key, share->conn_keys_lengths[link_idx]); #endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - conn_key = share->hs_read_conn_keys[link_idx]; -#ifdef DBUG_TRACE - spider_print_keys(conn_key, share->hs_read_conn_keys_lengths[link_idx]); -#endif - } else { - conn_key = share->hs_write_conn_keys[link_idx]; -#ifdef DBUG_TRACE - spider_print_keys(conn_key, share->hs_write_conn_keys_lengths[link_idx]); -#endif - } -#endif #ifdef SPIDER_HAS_HASH_VALUE_TYPE if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (conn_kind == SPIDER_CONN_KIND_MYSQL && - ( -#endif (another && !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &trx->trx_another_conn_hash, @@ -994,79 +722,25 @@ SPIDER_CONN *spider_get_conn( &trx->trx_conn_hash, share->conn_keys_hash_value[link_idx], (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_READ && - !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &trx->trx_hs_r_conn_hash, - share->hs_read_conn_keys_hash_value[link_idx], - (uchar*) conn_key, share->hs_read_conn_keys_lengths[link_idx])) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_WRITE && - !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &trx->trx_hs_w_conn_hash, - share->hs_write_conn_keys_hash_value[link_idx], - (uchar*) conn_key, share->hs_write_conn_keys_lengths[link_idx])) - ) -#endif ) #else if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (conn_kind == SPIDER_CONN_KIND_MYSQL && - ( -#endif (another && !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_another_conn_hash, (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) || (!another && !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash, (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_READ && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_hs_r_conn_hash, - (uchar*) conn_key, share->hs_read_conn_keys_lengths[link_idx])) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_WRITE && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_hs_w_conn_hash, - (uchar*) conn_key, share->hs_write_conn_keys_lengths[link_idx])) - ) -#endif ) #endif { if ( !trx->thd || -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (conn_kind == SPIDER_CONN_KIND_MYSQL && -#endif ( (spider_param_conn_recycle_mode(trx->thd) & 1) || spider_param_conn_recycle_strict(trx->thd) ) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_READ && - ( - (spider_param_hs_r_conn_recycle_mode(trx->thd) & 1) || - spider_param_hs_r_conn_recycle_strict(trx->thd) - ) - ) || - (conn_kind == SPIDER_CONN_KIND_HS_WRITE && - ( - (spider_param_hs_w_conn_recycle_mode(trx->thd) & 1) || - spider_param_hs_w_conn_recycle_strict(trx->thd) - ) - ) -#endif ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif pthread_mutex_lock(&spider_conn_mutex); #ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( @@ -1118,94 +792,6 @@ SPIDER_CONN *spider_get_conn( conn->use_for_active_standby = TRUE; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - pthread_mutex_lock(&spider_hs_r_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &spider_hs_r_conn_hash, - share->hs_read_conn_keys_hash_value[link_idx], - (uchar*) share->hs_read_conn_keys[link_idx], - share->hs_read_conn_keys_lengths[link_idx]))) -#else - if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_hs_r_conn_hash, - (uchar*) share->hs_read_conn_keys[link_idx], - share->hs_read_conn_keys_lengths[link_idx]))) -#endif - { - pthread_mutex_unlock(&spider_hs_r_conn_mutex); - DBUG_PRINT("info",("spider create new hs r conn")); - if (!(conn = spider_create_conn(share, spider, link_idx, - base_link_idx, conn_kind, error_num))) - goto error; - *conn->conn_key = *conn_key; - if (spider) - { - spider->hs_r_conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) - conn->use_for_active_standby = TRUE; - } - } else { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_hs_r_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&spider_hs_r_conn_hash, (uchar*) conn); -#endif - pthread_mutex_unlock(&spider_hs_r_conn_mutex); - DBUG_PRINT("info",("spider get global hs r conn")); - if (spider) - { - spider->hs_r_conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) - conn->use_for_active_standby = TRUE; - } - } - } else { - pthread_mutex_lock(&spider_hs_w_conn_mutex); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &spider_hs_w_conn_hash, - share->hs_write_conn_keys_hash_value[link_idx], - (uchar*) share->hs_write_conn_keys[link_idx], - share->hs_write_conn_keys_lengths[link_idx]))) -#else - if (!(conn = (SPIDER_CONN*) my_hash_search(&spider_hs_w_conn_hash, - (uchar*) share->hs_write_conn_keys[link_idx], - share->hs_write_conn_keys_lengths[link_idx]))) -#endif - { - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - DBUG_PRINT("info",("spider create new hs w conn")); - if (!(conn = spider_create_conn(share, spider, link_idx, - base_link_idx, conn_kind, error_num))) - goto error; - *conn->conn_key = *conn_key; - if (spider) - { - spider->hs_w_conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) - conn->use_for_active_standby = TRUE; - } - } else { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_hs_w_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&spider_hs_w_conn_hash, (uchar*) conn); -#endif - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - DBUG_PRINT("info",("spider get global hs w conn")); - if (spider) - { - spider->hs_w_conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) - conn->use_for_active_standby = TRUE; - } - } - } -#endif } else { DBUG_PRINT("info",("spider create new conn")); /* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */ @@ -1215,19 +801,7 @@ SPIDER_CONN *spider_get_conn( *conn->conn_key = *conn_key; if (spider) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif spider->conns[base_link_idx] = conn; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider->hs_r_conns[base_link_idx] = conn; - } else { - spider->hs_w_conns[base_link_idx] = conn; - } -#endif if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) conn->use_for_active_standby = TRUE; } @@ -1235,10 +809,6 @@ SPIDER_CONN *spider_get_conn( conn->thd = trx->thd; conn->priority = share->priority; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (another) { uint old_elements = trx->trx_another_conn_hash.array.max_element; @@ -1283,67 +853,9 @@ SPIDER_CONN *spider_get_conn( trx->trx_conn_hash.array.size_of_element); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - uint old_elements = trx->trx_hs_r_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_hs_r_conn_hash, - share->hs_read_conn_keys_hash_value[link_idx], - (uchar*) conn)) -#else - if (my_hash_insert(&trx->trx_hs_r_conn_hash, (uchar*) conn)) -#endif - { - spider_free_conn(conn); - *error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - if (trx->trx_hs_r_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - trx->trx_hs_r_conn_hash, - (trx->trx_hs_r_conn_hash.array.max_element - old_elements) * - trx->trx_hs_r_conn_hash.array.size_of_element); - } - } else { - uint old_elements = trx->trx_hs_w_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_hs_w_conn_hash, - share->hs_write_conn_keys_hash_value[link_idx], - (uchar*) conn)) -#else - if (my_hash_insert(&trx->trx_hs_w_conn_hash, (uchar*) conn)) -#endif - { - spider_free_conn(conn); - *error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - if (trx->trx_hs_w_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - trx->trx_hs_w_conn_hash, - (trx->trx_hs_w_conn_hash.array.max_element - old_elements) * - trx->trx_hs_w_conn_hash.array.size_of_element); - } - } -#endif } else if (spider) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif spider->conns[base_link_idx] = conn; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider->hs_r_conns[base_link_idx] = conn; - } else { - spider->hs_w_conns[base_link_idx] = conn; - } -#endif if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) conn->use_for_active_standby = TRUE; } @@ -1360,19 +872,12 @@ SPIDER_CONN *spider_get_conn( conn->queued_ping = FALSE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (unlikely(spider && spider->wide_handler->top_share && (*error_num = spider_conn_queue_loop_check( conn, spider, base_link_idx)))) { goto error; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif DBUG_PRINT("info",("spider conn=%p", conn)); DBUG_RETURN(conn); @@ -2407,14 +1912,6 @@ int spider_set_conn_bg_param( ) { if ((error_num = spider_create_conn_thread(spider->conns[roop_count]))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = spider_create_conn_thread( - spider->hs_r_conns[roop_count]))) - DBUG_RETURN(error_num); - if ((error_num = spider_create_conn_thread( - spider->hs_w_conns[roop_count]))) - DBUG_RETURN(error_num); -#endif } #ifdef SPIDER_HAS_GROUP_BY_HANDLER } @@ -2741,19 +2238,9 @@ int spider_bg_conn_search( bool with_lock = FALSE; DBUG_ENTER("spider_bg_conn_search"); DBUG_PRINT("info",("spider spider=%p", spider)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = spider->conns[link_idx]; with_lock = (spider_conn_lock_mode(spider) != SPIDER_LOCK_MODE_NO_LOCK); first_conn = spider->conns[first_link_idx]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - conn = spider->hs_r_conns[link_idx]; - else - conn = spider->hs_w_conns[link_idx]; -#endif if (first) { if (spider->use_pre_call) @@ -3212,21 +2699,12 @@ void *spider_bg_conn_action( !result_list->bgs_current->result ) { ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (spider->sql_kind[conn->link_idx] == SPIDER_SQL_KIND_SQL) { sql_type = SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL; } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - sql_type = SPIDER_SQL_TYPE_SELECT_HS; - } -#endif pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (spider->use_fields) { @@ -3554,27 +3032,12 @@ void *spider_bg_sts_action( uint *conn_link_idx; uchar *conn_can_fo; char **conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_r_conn_keys; - char **hs_w_conn_keys; -#endif spider_db_handler **dbton_hdl; THD *thd; my_thread_init(); DBUG_ENTER("spider_bg_sts_action"); /* init start */ char *ptr; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ptr = (char *) my_alloca( - (sizeof(int) * share->link_count) + - (sizeof(SPIDER_CONN *) * share->link_count) + - (sizeof(uint) * share->link_count) + - (sizeof(uchar) * share->link_bitmap_size) + - (sizeof(char *) * share->link_count) + - (sizeof(char *) * share->link_count) + - (sizeof(char *) * share->link_count) + - (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE)); -#else ptr = (char *) my_alloca( (sizeof(int) * share->link_count) + (sizeof(SPIDER_CONN *) * share->link_count) + @@ -3582,7 +3045,6 @@ void *spider_bg_sts_action( (sizeof(uchar) * share->link_bitmap_size) + (sizeof(char *) * share->link_count) + (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE)); -#endif if (!ptr) { pthread_mutex_lock(&share->sts_mutex); @@ -3603,12 +3065,6 @@ void *spider_bg_sts_action( ptr += (sizeof(uchar) * share->link_bitmap_size); conn_keys = (char **) ptr; ptr += (sizeof(char *) * share->link_count); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_r_conn_keys = (char **) ptr; - ptr += (sizeof(char *) * share->link_count); - hs_w_conn_keys = (char **) ptr; - ptr += (sizeof(char *) * share->link_count); -#endif dbton_hdl = (spider_db_handler **) ptr; pthread_mutex_lock(&share->sts_mutex); if (!(thd = SPIDER_new_THD(next_thread_id()))) @@ -3651,10 +3107,6 @@ void *spider_bg_sts_action( spider.need_mons = need_mons; spider.conn_keys_first_ptr = share->conn_keys[0]; spider.conn_keys = conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider.hs_r_conn_keys = hs_r_conn_keys; - spider.hs_w_conn_keys = hs_w_conn_keys; -#endif spider.dbton_handler = dbton_hdl; memset(conns, 0, sizeof(SPIDER_CONN *) * share->link_count); memset(need_mons, 0, sizeof(int) * share->link_count); @@ -3908,27 +3360,12 @@ void *spider_bg_crd_action( uint *conn_link_idx; uchar *conn_can_fo; char **conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_r_conn_keys; - char **hs_w_conn_keys; -#endif spider_db_handler **dbton_hdl; THD *thd; my_thread_init(); DBUG_ENTER("spider_bg_crd_action"); /* init start */ char *ptr; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ptr = (char *) my_alloca( - (sizeof(int) * share->link_count) + - (sizeof(SPIDER_CONN *) * share->link_count) + - (sizeof(uint) * share->link_count) + - (sizeof(uchar) * share->link_bitmap_size) + - (sizeof(char *) * share->link_count) + - (sizeof(char *) * share->link_count) + - (sizeof(char *) * share->link_count) + - (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE)); -#else ptr = (char *) my_alloca( (sizeof(int) * share->link_count) + (sizeof(SPIDER_CONN *) * share->link_count) + @@ -3936,7 +3373,6 @@ void *spider_bg_crd_action( (sizeof(uchar) * share->link_bitmap_size) + (sizeof(char *) * share->link_count) + (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE)); -#endif if (!ptr) { pthread_mutex_lock(&share->crd_mutex); @@ -3957,12 +3393,6 @@ void *spider_bg_crd_action( ptr += (sizeof(uchar) * share->link_bitmap_size); conn_keys = (char **) ptr; ptr += (sizeof(char *) * share->link_count); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_r_conn_keys = (char **) ptr; - ptr += (sizeof(char *) * share->link_count); - hs_w_conn_keys = (char **) ptr; - ptr += (sizeof(char *) * share->link_count); -#endif dbton_hdl = (spider_db_handler **) ptr; pthread_mutex_lock(&share->crd_mutex); if (!(thd = SPIDER_new_THD(next_thread_id()))) @@ -4009,10 +3439,6 @@ void *spider_bg_crd_action( spider.need_mons = need_mons; spider.conn_keys_first_ptr = share->conn_keys[0]; spider.conn_keys = conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider.hs_r_conn_keys = hs_r_conn_keys; - spider.hs_w_conn_keys = hs_w_conn_keys; -#endif spider.dbton_handler = dbton_hdl; memset(conns, 0, sizeof(SPIDER_CONN *) * share->link_count); memset(need_mons, 0, sizeof(int) * share->link_count); @@ -4694,51 +4120,14 @@ bool spider_conn_use_handler( DBUG_PRINT("info",("spider use_handler=%d", use_handler)); DBUG_PRINT("info",("spider spider->conn_kind[link_idx]=%u", spider->conn_kind[link_idx])); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[link_idx] != SPIDER_CONN_KIND_MYSQL) - { - DBUG_PRINT("info",("spider TRUE by HS")); - spider->sql_kinds |= SPIDER_SQL_KIND_HS; - spider->sql_kind[link_idx] = SPIDER_SQL_KIND_HS; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->do_direct_update && - spider_bit_is_set(spider->do_hs_direct_update, link_idx) - ) { - DBUG_PRINT("info",("spider using HS direct_update")); - spider->direct_update_kinds |= SPIDER_SQL_KIND_HS; - } -#endif - DBUG_RETURN(TRUE); - } -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (spider->do_direct_update) { spider->sql_kinds |= SPIDER_SQL_KIND_SQL; spider->sql_kind[link_idx] = SPIDER_SQL_KIND_SQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider_bit_is_set(spider->do_hs_direct_update, link_idx)) - { - spider->direct_update_kinds |= SPIDER_SQL_KIND_HS; - DBUG_PRINT("info",("spider TRUE by using HS direct_update")); - DBUG_RETURN(TRUE); - } else { -#endif spider->direct_update_kinds |= SPIDER_SQL_KIND_SQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif DBUG_PRINT("info",("spider FALSE by using direct_update")); DBUG_RETURN(FALSE); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - DBUG_PRINT("info",("spider TRUE by using BOTH")); - DBUG_RETURN(TRUE); - } -#endif } #endif if (spider->use_spatial_index) @@ -4796,173 +4185,12 @@ bool spider_conn_need_open_handler( uint idx, int link_idx ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_CONN *conn; -#endif DBUG_ENTER("spider_conn_need_open_handler"); DBUG_PRINT("info",("spider spider=%p", spider)); if (spider->handler_opened(link_idx, spider->conn_kind[link_idx])) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->do_direct_update && - spider_bit_is_set(spider->do_hs_direct_update, link_idx) - ) { - conn = spider->hs_w_conns[link_idx]; - if ( - !conn->server_lost && - conn->hs_pre_age == spider->hs_w_conn_ages[link_idx] - ) { - DBUG_PRINT("info",("spider hs_write is already opened")); - DBUG_RETURN(FALSE); - } - } else -#endif - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif DBUG_PRINT("info",("spider HA already opened")); DBUG_RETURN(FALSE); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - { - DBUG_PRINT("info",("spider r_handler_index[%d]=%d", - link_idx, spider->r_handler_index[link_idx])); - DBUG_PRINT("info",("spider idx=%d", idx)); - DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu", - spider->hs_pushed_ret_fields_num)); - DBUG_PRINT("info",("spider hs_r_ret_fields_num[%d]=%lu", - link_idx, spider->hs_r_ret_fields_num[link_idx])); - DBUG_PRINT("info",("spider hs_r_ret_fields[%d]=%p", - link_idx, spider->hs_r_ret_fields[link_idx])); -#ifndef DBUG_OFF - if ( - spider->hs_pushed_ret_fields_num < MAX_FIELDS && - spider->hs_r_ret_fields[link_idx] && - spider->hs_pushed_ret_fields_num == - spider->hs_r_ret_fields_num[link_idx] - ) { - int roop_count; - for (roop_count = 0; roop_count < (int) spider->hs_pushed_ret_fields_num; - ++roop_count) - { - DBUG_PRINT("info",("spider hs_pushed_ret_fields[%d]=%u", - roop_count, spider->hs_pushed_ret_fields[roop_count])); - DBUG_PRINT("info",("spider hs_r_ret_fields[%d][%d]=%u", - link_idx, roop_count, - spider->hs_r_ret_fields[link_idx][roop_count])); - } - } -#endif - if ( - spider->r_handler_index[link_idx] == idx -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - && ( - ( - spider->hs_pushed_ret_fields_num == MAX_FIELDS && - spider->hs_r_ret_fields_num[link_idx] == MAX_FIELDS - ) || - ( - spider->hs_pushed_ret_fields_num < MAX_FIELDS && - spider->hs_r_ret_fields[link_idx] && - spider->hs_pushed_ret_fields_num == - spider->hs_r_ret_fields_num[link_idx] && - !memcmp(spider->hs_pushed_ret_fields, - spider->hs_r_ret_fields[link_idx], - sizeof(uint32) * spider->hs_pushed_ret_fields_num) - ) - ) -#endif - ) { - SPIDER_CONN *conn = spider->hs_r_conns[link_idx]; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->conn_id=%llu", conn->conn_id)); - DBUG_PRINT("info",("spider conn->connection_id=%llu", - conn->connection_id)); - DBUG_PRINT("info",("spider conn->server_lost=%s", - conn->server_lost ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider conn->hs_pre_age=%llu", conn->hs_pre_age)); - DBUG_PRINT("info",("spider hs_w_conn_ages[%d]=%llu", - link_idx, spider->hs_w_conn_ages[link_idx])); - if ( - !conn->server_lost && - conn->hs_pre_age == spider->hs_r_conn_ages[link_idx] - ) { - DBUG_PRINT("info",("spider hs_r same idx")); - DBUG_RETURN(FALSE); - } - } - } else if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_WRITE) - { - DBUG_PRINT("info",("spider w_handler_index[%d]=%d", - link_idx, spider->w_handler_index[link_idx])); - DBUG_PRINT("info",("spider idx=%d", idx)); - DBUG_PRINT("info",("spider hs_pushed_ret_fields_num=%zu", - spider->hs_pushed_ret_fields_num)); - DBUG_PRINT("info",("spider hs_w_ret_fields_num[%d]=%lu", - link_idx, spider->hs_w_ret_fields_num[link_idx])); - DBUG_PRINT("info",("spider hs_w_ret_fields[%d]=%p", - link_idx, spider->hs_w_ret_fields[link_idx])); -#ifndef DBUG_OFF - if ( - spider->hs_pushed_ret_fields_num < MAX_FIELDS && - spider->hs_w_ret_fields[link_idx] && - spider->hs_pushed_ret_fields_num == - spider->hs_w_ret_fields_num[link_idx] - ) { - int roop_count; - for (roop_count = 0; roop_count < (int) spider->hs_pushed_ret_fields_num; - ++roop_count) - { - DBUG_PRINT("info",("spider hs_pushed_ret_fields[%d]=%u", - roop_count, spider->hs_pushed_ret_fields[roop_count])); - DBUG_PRINT("info",("spider hs_w_ret_fields[%d][%d]=%u", - link_idx, roop_count, - spider->hs_w_ret_fields[link_idx][roop_count])); - } - } -#endif - if ( - spider->w_handler_index[link_idx] == idx -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - && ( - ( - spider->hs_pushed_ret_fields_num == MAX_FIELDS && - spider->hs_w_ret_fields_num[link_idx] == MAX_FIELDS - ) || - ( - spider->hs_pushed_ret_fields_num < MAX_FIELDS && - spider->hs_w_ret_fields[link_idx] && - spider->hs_pushed_ret_fields_num == - spider->hs_w_ret_fields_num[link_idx] && - !memcmp(spider->hs_pushed_ret_fields, - spider->hs_w_ret_fields[link_idx], - sizeof(uint32) * spider->hs_pushed_ret_fields_num) - ) - ) -#endif - ) { - SPIDER_CONN *conn = spider->hs_w_conns[link_idx]; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->conn_id=%llu", conn->conn_id)); - DBUG_PRINT("info",("spider conn->connection_id=%llu", - conn->connection_id)); - DBUG_PRINT("info",("spider conn->server_lost=%s", - conn->server_lost ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider conn->hs_pre_age=%llu", conn->hs_pre_age)); - DBUG_PRINT("info",("spider hs_w_conn_ages[%d]=%llu", - link_idx, spider->hs_w_conn_ages[link_idx])); - if ( - !conn->server_lost && - conn->hs_pre_age == spider->hs_w_conn_ages[link_idx] - ) { - DBUG_PRINT("info",("spider hs_w same idx")); - DBUG_RETURN(FALSE); - } - } - } -#endif } DBUG_RETURN(TRUE); } diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index a9f62e0626d..2498804ac06 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -132,36 +132,16 @@ int spider_db_connect( DBUG_PRINT("info",("spider net_read_timeout=%u", conn->net_read_timeout)); DBUG_PRINT("info",("spider net_write_timeout=%u", conn->net_write_timeout)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if ((error_num = spider_reset_conn_setted_parameter(conn, thd))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif if (conn->dbton_id == SPIDER_DBTON_SIZE) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif my_printf_error( ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, MYF(0), conn->tgt_wrapper); DBUG_RETURN(ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - my_printf_error( - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, - MYF(0), conn->tgt_wrapper); - DBUG_RETURN(ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM); - } -#endif } if ((error_num = conn->db_conn->connect( @@ -291,10 +271,6 @@ int spider_db_conn_queue_action( } pthread_mutex_assert_owner(&conn->mta_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (conn->queued_ping) { if ((error_num = spider_db_ping(conn->queued_ping_spider, conn, @@ -583,13 +559,6 @@ int spider_db_conn_queue_action( conn->db_conn->fin_loop_check(); } spider_conn_clear_queue(conn); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (conn->server_lost) - { - DBUG_PRINT("info", ("spider no connect queue")); - DBUG_RETURN(CR_SERVER_GONE_ERROR); - } -#endif DBUG_RETURN(0); } @@ -673,10 +642,6 @@ int spider_db_query( int error_num; DBUG_ENTER("spider_db_query"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif DBUG_PRINT("info", ("spider conn->db_conn %p", conn->db_conn)); if ( !conn->in_before_query && @@ -696,17 +661,6 @@ int spider_db_query( if ((error_num = conn->db_conn->exec_query(query, length, quick_mode))) DBUG_RETURN(error_num); DBUG_RETURN(0); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn->queued_net_timeout) - { - if (conn->db_conn->set_net_timeout()) - DBUG_RETURN(ER_SPIDER_HS_NUM); - conn->queued_net_timeout = FALSE; - } - DBUG_RETURN(conn->db_conn->exec_query(NULL, 0, quick_mode)); - } -#endif } int spider_db_errorno( @@ -716,10 +670,6 @@ int spider_db_errorno( DBUG_ENTER("spider_db_errorno"); DBUG_ASSERT(conn->need_mon); pthread_mutex_assert_owner(&conn->mta_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif if (conn->server_lost) { *conn->need_mon = ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM; @@ -819,57 +769,6 @@ int spider_db_errorno( } DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (conn->db_conn->is_server_gone_error(0)) - { - my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), - conn->db_conn->get_errno(), conn->db_conn->get_error()); - *conn->need_mon = ER_SPIDER_HS_NUM; - DBUG_PRINT("info", ("spider conn=%p SERVER_LOST", conn)); - conn->server_lost = TRUE; - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(ER_SPIDER_HS_NUM); - } else if (conn->db_conn->is_dup_entry_error(0)) - { - *conn->need_mon = 0; - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY); - } - my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), - conn->db_conn->get_errno(), conn->db_conn->get_error()); - if (spider_param_log_result_errors() >= 1) - { - time_t cur_time = (time_t) time((time_t*) 0); - struct tm lt; - struct tm *l_time = localtime_r(&cur_time, <); - fprintf(stderr, "%04d%02d%02d %02d:%02d:%02d [ERROR SPIDER RESULT] " - "to %ld: %d %s\n", - l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday, - l_time->tm_hour, l_time->tm_min, l_time->tm_sec, - (ulong) current_thd->thread_id, conn->db_conn->get_errno(), - conn->db_conn->get_error()); - } - *conn->need_mon = ER_SPIDER_HS_NUM; - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(ER_SPIDER_HS_NUM); - } -#endif if (!conn->mta_conn_mutex_unlock_later) { DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); @@ -896,10 +795,6 @@ int spider_db_set_names_internal( int *need_mon ) { DBUG_ENTER("spider_db_set_names_internal"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif pthread_mutex_assert_owner(&conn->mta_conn_mutex); DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); DBUG_ASSERT(conn->mta_conn_mutex_lock_already); @@ -943,9 +838,6 @@ int spider_db_set_names_internal( share->tgt_dbs_lengths[all_link_idx] + 1); conn->default_database.length(share->tgt_dbs_lengths[all_link_idx]); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif DBUG_RETURN(0); } @@ -1702,14 +1594,6 @@ int spider_db_append_key_where_internal( case SPIDER_SQL_TYPE_HANDLER: sql_kind = SPIDER_SQL_KIND_HANDLER; break; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - case SPIDER_SQL_TYPE_SELECT_HS: - case SPIDER_SQL_TYPE_INSERT_HS: - case SPIDER_SQL_TYPE_UPDATE_HS: - case SPIDER_SQL_TYPE_DELETE_HS: - sql_kind = SPIDER_SQL_KIND_HS; - break; -#endif default: sql_kind = SPIDER_SQL_KIND_SQL; break; @@ -1930,14 +1814,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } -#endif } else { DBUG_PRINT("info", ("spider start_key->flag=%d", start_key->flag)); switch (start_key->flag) @@ -2008,17 +1884,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_EQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_EQUAL_STR, SPIDER_SQL_HS_EQUAL_LEN); - } -#endif break; case HA_READ_AFTER_KEY: if (sql_kind == SPIDER_SQL_KIND_SQL) @@ -2087,17 +1952,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_GT_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_GT_STR, SPIDER_SQL_HS_GT_LEN); - } -#endif break; case HA_READ_BEFORE_KEY: result_list->desc_flg = TRUE; @@ -2167,17 +2021,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_LT_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_LT_STR, SPIDER_SQL_HS_LT_LEN); - } -#endif break; case HA_READ_KEY_OR_PREV: case HA_READ_PREFIX_LAST_OR_PREV: @@ -2241,18 +2084,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_LTEQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_LTEQUAL_STR, - SPIDER_SQL_HS_LTEQUAL_LEN); - } -#endif break; case HA_READ_MBR_CONTAIN: if (str->reserve(SPIDER_SQL_MBR_CONTAIN_LEN)) @@ -2393,18 +2224,6 @@ int spider_db_append_key_where_internal( #endif } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else { - if (spider_dbton[share->use_hs_dbton_ids[0]].db_util-> - append_column_value(spider, NULL, field, ptr, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (str->reserve(SPIDER_SQL_HS_GTEQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HS_GTEQUAL_STR, - SPIDER_SQL_HS_GTEQUAL_LEN); - } -#endif break; } } @@ -2432,10 +2251,6 @@ int spider_db_append_key_where_internal( } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (sql_kind != SPIDER_SQL_KIND_HS) - { -#endif if ( (key_eq && use_key == end_key) || (!key_eq && end_key_part_map) @@ -2659,9 +2474,6 @@ int spider_db_append_key_where_internal( } if (use_both && (!start_key_part_map || !end_key_part_map)) break; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif } if ((error_num = dbton_hdl->append_where_terminator_part(sql_type, set_order, key_count))) @@ -2705,15 +2517,6 @@ int spider_db_append_key_where( SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((spider->sql_kinds & SPIDER_SQL_KIND_HS)) - { - DBUG_PRINT("info",("spider call internal by SPIDER_SQL_KIND_HS")); - if ((error_num = spider->append_key_where_hs_part(start_key, end_key, - SPIDER_SQL_TYPE_SELECT_HS))) - DBUG_RETURN(error_num); - } -#endif DBUG_RETURN(0); } @@ -3119,10 +2922,6 @@ int spider_db_fetch_table( SPIDER_DB_ROW *row; Field **field; DBUG_ENTER("spider_db_fetch_table"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif if (result_list->quick_mode == 0) { SPIDER_DB_RESULT *result = current->result; @@ -3205,21 +3004,7 @@ int spider_db_fetch_table( #ifdef SPIDER_HAS_GROUP_BY_HANDLER } #endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (!(row = result_list->hs_result->fetch_row_from_result_buffer( - result_list->hs_result_buf))) - { - table->status = STATUS_NOT_FOUND; - DBUG_RETURN(HA_ERR_END_OF_FILE); - } - } -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif for ( field = table->field; *field; @@ -3247,68 +3032,6 @@ int spider_db_fetch_table( } row->next(); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if (spider->hs_pushed_ret_fields_num == MAX_FIELDS) - { -#endif - spider_db_handler *dbton_hdl = spider->dbton_handler[row->dbton_id]; - for ( - field = table->field; - *field; - field++ - ) { - if (dbton_hdl->minimum_select_bit_is_set((*field)->field_index)) - { -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = - dbug_tmp_use_all_columns(table, table->write_set); -#endif - if ((error_num = spider_db_fetch_row(share, *field, row, ptr_diff))) - DBUG_RETURN(error_num); -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->write_set, tmp_map); -#endif - row->next(); - } - } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - } else { - uint32 *field_idxs = spider->hs_pushed_ret_fields; - size_t field_idxs_num = spider->hs_pushed_ret_fields_num; - Field *tf; - int roop_count; - if (spider->hs_pushed_lcl_fields_num != - result_list->hs_result->num_fields()) - { - DBUG_PRINT("info", ("spider different field_num %zu %u", - spider->hs_pushed_lcl_fields_num, - result_list->hs_result->num_fields())); - DBUG_RETURN(ER_SPIDER_UNKNOWN_NUM); - } - for (roop_count = 0; roop_count < (int) field_idxs_num; - roop_count++) - { - tf = spider->get_top_table_field(field_idxs[roop_count]); - if ((tf = spider->field_exchange(tf))) - { -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = - dbug_tmp_use_all_columns(table, table->write_set); -#endif - if ((error_num = spider_db_fetch_row(share, tf, row, ptr_diff))) - DBUG_RETURN(error_num); -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->write_set, tmp_map); -#endif - row->next(); - } - } - } -#endif - } -#endif table->status = 0; DBUG_RETURN(0); } @@ -3561,10 +3284,6 @@ void spider_db_free_one_result_for_start_next( DBUG_ENTER("spider_db_free_one_result_for_start_next"); spider_bg_all_conn_break(spider); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif if (result_list->low_mem_read) { if (result) @@ -3593,24 +3312,6 @@ void spider_db_free_one_result_for_start_next( result = (SPIDER_RESULT *) result->next; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (result_list->hs_has_result) - { - if (result_list->hs_result) - { - result_list->hs_result->free_result(); - delete result_list->hs_result; - result_list->hs_result = NULL; - } - if (result_list->hs_result_buf) - { - result_list->hs_result_buf->clear(); - } - result_list->hs_has_result = FALSE; - } - } -#endif DBUG_VOID_RETURN; } @@ -3719,27 +3420,6 @@ int spider_db_free_result( delete tmp_pos_row; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (result_list->hs_has_result) - { - if (result_list->hs_result) - { - result_list->hs_result->free_result(); - delete result_list->hs_result; - result_list->hs_result = NULL; - } - if (result_list->hs_result_buf) - { - if (result_list->hs_result_buf->check_size( - spider_param_hs_result_free_size(trx->thd, share->hs_result_free_size)) - ) { - trx->hs_result_free_count++; - } - result_list->hs_result_buf->clear(); - } - result_list->hs_has_result = FALSE; - } -#endif if ( final || @@ -3929,10 +3609,6 @@ int spider_db_store_result( SPIDER_RESULT_LIST *result_list = &spider->result_list; SPIDER_RESULT *current; DBUG_ENTER("spider_db_store_result"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = spider->conns[link_idx]; DBUG_PRINT("info",("spider conn->connection_id=%llu", conn->connection_id)); @@ -4416,66 +4092,6 @@ int spider_db_store_result( DBUG_PRINT("info", ("spider first_position[]=%p", ¤t->first_position[result_list->current_row_num])); DBUG_PRINT("info", ("spider row=%p", current->first_position[result_list->current_row_num].row)); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - conn = spider->hs_r_conns[link_idx]; - else - conn = spider->hs_w_conns[link_idx]; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->connection_id=%llu", - conn->connection_id)); - DBUG_PRINT("info",("spider spider->connection_ids[%d]=%llu", - link_idx, spider->connection_ids[link_idx])); - if (conn->connection_id != spider->connection_ids[link_idx]) - { - my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, - ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); - } - if (spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_clear_bit(spider->db_request_phase, link_idx); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - if (!(result_list->hs_result = conn->db_conn->store_result( - &result_list->hs_result_buf, &request_key, &error_num))) - { - if (!error_num) - { - spider_db_errorno(conn); - DBUG_RETURN(ER_SPIDER_HS_NUM); - } else { - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - } - DBUG_RETURN(error_num); - } - result_list->hs_conn = conn->db_conn; - result_list->hs_has_result = TRUE; - if (!conn->mta_conn_mutex_unlock_later) - { - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - } -#endif DBUG_RETURN(0); } @@ -4489,9 +4105,6 @@ int spider_db_store_result_for_reuse_cursor( SPIDER_RESULT_LIST *result_list = &spider->result_list; SPIDER_RESULT *current; DBUG_ENTER("spider_db_store_result_for_reuse_cursor"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_ASSERT(spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL); -#endif conn = spider->conns[link_idx]; DBUG_PRINT("info",("spider conn->connection_id=%llu", conn->connection_id)); @@ -5021,9 +4634,6 @@ int spider_db_seek_next( SPIDER_RESULT_LIST *result_list = &spider->result_list; DBUG_ENTER("spider_db_seek_next"); if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->conn_kind[spider->result_link_idx] == SPIDER_CONN_KIND_MYSQL && -#endif result_list->current_row_num >= result_list->current->record_num ) { DBUG_PRINT("info",("spider result_list->current_row_num=%lld", @@ -6488,9 +6098,6 @@ int spider_db_bulk_insert_init( DBUG_ENTER("spider_db_bulk_insert_init"); spider->sql_kinds = 0; spider->reset_sql_sql(SPIDER_SQL_TYPE_INSERT_SQL); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->reset_hs_sql(SPIDER_SQL_TYPE_OTHER_HS); -#endif for ( roop_count = spider_conn_link_idx_next(share->link_statuses, spider->conn_link_idx, -1, share->link_count, @@ -6503,67 +6110,15 @@ int spider_db_bulk_insert_init( if (spider->conns[roop_count]) spider->conns[roop_count]->ignore_dup_key = spider->wide_handler->ignore_dup_key; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - spider_conn_use_handler(spider, spider->lock_mode, roop_count) && - ( - !spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_WRITE) || -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - spider->hs_w_ret_fields_num[roop_count] < MAX_FIELDS || -#endif - spider->hs_w_conns[roop_count]->server_lost - ) - ) { - if ((error_num = spider_db_open_handler(spider, - spider->hs_w_conns[roop_count], roop_count))) - { - if ( - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - spider->wide_handler->trx, - spider->wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(error_num); - } - spider->set_handler_opened(roop_count); - } -#else spider_conn_use_handler(spider, spider->wide_handler->lock_mode, roop_count); -#endif } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) - { -#endif if ( (error_num = spider->append_insert_sql_part()) || (error_num = spider->append_into_sql_part( SPIDER_SQL_TYPE_INSERT_SQL)) ) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (spider->sql_kinds & SPIDER_SQL_KIND_HS) - { - spider->result_list.hs_upd_rows = 0; - } -#endif DBUG_RETURN(0); } @@ -6574,19 +6129,12 @@ int spider_db_bulk_insert( bool bulk_end ) { int error_num, first_insert_link_idx = -1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_RESULT_LIST *result_list = &spider->result_list; -#endif SPIDER_SHARE *share = spider->share; THD *thd = spider->wide_handler->trx->thd; DBUG_ENTER("spider_db_bulk_insert"); if (!bulk_end) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) - { -#endif if ((error_num = spider->append_insert_values_sql_part( SPIDER_SQL_TYPE_INSERT_SQL))) { @@ -6594,16 +6142,6 @@ int spider_db_bulk_insert( spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } - if (spider->sql_kinds & SPIDER_SQL_KIND_HS) - { - if ((error_num = spider->append_insert_values_hs_part( - SPIDER_SQL_TYPE_INSERT_HS))) - DBUG_RETURN(error_num); - result_list->hs_upd_rows++; - } -#endif } if (spider->is_bulk_insert_exec_period(bulk_end)) @@ -6633,10 +6171,6 @@ int spider_db_bulk_insert( ) { ulong sql_type; spider_db_handler *dbton_handler; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[roop_count2] == SPIDER_CONN_KIND_MYSQL) - { -#endif sql_type = SPIDER_SQL_TYPE_INSERT_SQL; conn = spider->conns[roop_count2]; dbton_handler = spider->dbton_handler[conn->dbton_id]; @@ -6650,16 +6184,6 @@ int spider_db_bulk_insert( } pthread_mutex_lock(&conn->mta_conn_mutex); SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - sql_type = SPIDER_SQL_TYPE_INSERT_HS; - conn = spider->hs_w_conns[roop_count2]; - dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); - } -#endif conn->need_mon = &spider->need_mons[roop_count2]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6755,43 +6279,6 @@ int spider_db_bulk_insert( insert_info = conn->db_conn->inserted_info(dbton_handler, copy_info); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind != SPIDER_CONN_KIND_MYSQL) - { - uint roop_count; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider result_list->hs_upd_rows=%llu", - result_list->hs_upd_rows)); - for (roop_count = 0; roop_count < result_list->hs_upd_rows; - roop_count++) - { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count2)) - { - spider_clear_bit(spider->db_request_phase, roop_count2); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count2]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_RETURN(error_num); - } - } - } -#endif SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (first_insert_link_idx == -1) @@ -6892,16 +6379,7 @@ int spider_db_bulk_bulk_insert( spider->conn_link_idx, roop_count2, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[roop_count2] == SPIDER_CONN_KIND_MYSQL) - { -#endif conn = spider->conns[roop_count2]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - conn = spider->hs_w_conns[roop_count2]; - } -#endif pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -6918,44 +6396,6 @@ int spider_db_bulk_bulk_insert( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind != SPIDER_CONN_KIND_MYSQL) - { - uint roop_count; - SPIDER_RESULT_LIST *result_list = &spider->result_list; - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider result_list->hs_upd_rows=%llu", - result_list->hs_upd_rows)); - for (roop_count = 0; roop_count < result_list->hs_upd_rows; - roop_count++) - { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count2)) - { - spider_clear_bit(spider->db_request_phase, roop_count2); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count2]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_RETURN(error_num); - } - } - } -#endif SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (first_insert_link_idx == -1) @@ -7026,16 +6466,7 @@ int spider_db_update_auto_increment( (auto_increment_mode == 3 && !table->auto_increment_field_not_null) ) { last_insert_id = spider->conns[link_idx]->db_conn->last_insert_id(); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_MYSQL) - { -#endif affected_rows = spider->conns[link_idx]->db_conn->affected_rows(); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - affected_rows = spider->result_list.hs_upd_rows; - } -#endif DBUG_PRINT("info",("spider last_insert_id=%llu", last_insert_id)); share->lgtm_tblhnd_share->auto_increment_value = last_insert_id + affected_rows; @@ -7503,27 +6934,8 @@ int spider_db_direct_update( spider->do_direct_update ? "TRUE" : "FALSE")); DBUG_PRINT("info", ("spider direct_update_kinds=%u", spider->direct_update_kinds)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - ( - spider->do_direct_update && - (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) - ) || - ( - !spider->do_direct_update && -#endif - (spider->sql_kinds & SPIDER_SQL_KIND_SQL) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - ) -#endif - ) { -#endif if ((error_num = spider->append_update_sql_part())) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif /* SQL access -> SQL remote access @@ -7544,17 +6956,6 @@ int spider_db_direct_update( (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) */ -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->hs_increment || spider->hs_decrement) - { - if ( - (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) && - (error_num = spider->append_increment_update_set_sql_part()) - ) { - DBUG_RETURN(error_num); - } - } else { -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS if (!spider->do_direct_update) { @@ -7573,19 +6974,8 @@ int spider_db_direct_update( ) { DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) && - (error_num = spider->append_direct_update_set_hs_part()) - ) { - DBUG_RETURN(error_num); - } -#endif } #endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif result_list->desc_flg = FALSE; result_list->sorted = TRUE; @@ -7615,22 +7005,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) - { - if ( - (error_num = spider->append_key_where_hs_part( - (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, - (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, - SPIDER_SQL_TYPE_UPDATE_HS)) || - (error_num = spider->append_limit_hs_part( - result_list->internal_offset, result_list->limit_num, - SPIDER_SQL_TYPE_UPDATE_HS)) - ) { - DBUG_RETURN(error_num); - } - } -#endif for ( roop_count = spider_conn_link_idx_next(share->link_statuses, @@ -7642,20 +7016,9 @@ int spider_db_direct_update( SPIDER_LINK_STATUS_RECOVERY) ) { ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif DBUG_PRINT("info", ("spider exec sql")); conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_UPDATE_SQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - DBUG_PRINT("info", ("spider exec hs")); - conn = spider->hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_UPDATE_HS; - } -#endif spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -7750,10 +7113,6 @@ int spider_db_direct_update( } DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif if (!counted) { *update_rows = spider->conns[roop_count]->db_conn->affected_rows(); @@ -7762,48 +7121,6 @@ int spider_db_direct_update( DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); counted = TRUE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count)) - { - spider_clear_bit(spider->db_request_phase, roop_count); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!counted) - { - *update_rows = conn->db_conn->affected_rows(); - DBUG_PRINT("info", ("spider update_rows = %llu", *update_rows)); - *found_rows = conn->db_conn->matched_rows(); - DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); - counted = TRUE; - } - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - } -#endif DBUG_ASSERT(conn->mta_conn_mutex_lock_already); DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; @@ -7815,11 +7132,6 @@ int spider_db_direct_update( pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->reset_hs_sql(SPIDER_SQL_TYPE_UPDATE_HS); - spider->reset_hs_keys(SPIDER_SQL_TYPE_UPDATE_HS); - spider->reset_hs_upds(SPIDER_SQL_TYPE_UPDATE_HS); -#endif DBUG_RETURN(0); } #else @@ -8061,18 +7373,8 @@ int spider_db_bulk_direct_update( spider->conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif DBUG_PRINT("info", ("spider exec sql")); conn = spider->conns[roop_count]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - DBUG_PRINT("info", ("spider exec hs")); - conn = spider->hs_w_conns[roop_count]; - } -#endif pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); @@ -8085,10 +7387,6 @@ int spider_db_bulk_direct_update( { error_num = tmp_error_num; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif if (!counted) { *update_rows = spider->conns[roop_count]->db_conn->affected_rows(); @@ -8097,48 +7395,6 @@ int spider_db_bulk_direct_update( DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); counted = TRUE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count)) - { - spider_clear_bit(spider->db_request_phase, roop_count); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!counted) - { - *update_rows = conn->db_conn->affected_rows(); - DBUG_PRINT("info", ("spider update_rows = %llu", *update_rows)); - *found_rows = conn->db_conn->matched_rows(); - DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); - counted = TRUE; - } - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_ASSERT(conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = FALSE; - conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - } -#endif DBUG_ASSERT(conn->mta_conn_mutex_lock_already); DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; @@ -8296,22 +7552,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) - { - if ( - (error_num = spider->append_key_where_hs_part( - (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, - (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, - SPIDER_SQL_TYPE_DELETE_HS)) || - (error_num = spider->append_limit_hs_part( - result_list->internal_offset, result_list->limit_num, - SPIDER_SQL_TYPE_DELETE_HS)) - ) { - DBUG_RETURN(error_num); - } - } -#endif for ( roop_count = spider_conn_link_idx_next(share->link_statuses, @@ -8323,20 +7563,9 @@ int spider_db_direct_delete( SPIDER_LINK_STATUS_RECOVERY) ) { ulong sql_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif DBUG_PRINT("info", ("spider exec sql")); conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_DELETE_SQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - DBUG_PRINT("info", ("spider exec hs")); - conn = spider->hs_w_conns[roop_count]; - sql_type = SPIDER_SQL_TYPE_DELETE_HS; - } -#endif spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) @@ -8429,50 +7658,12 @@ int spider_db_direct_delete( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider_bit_is_set(spider->do_hs_direct_update, roop_count)) - { -#endif if (!counted) { *delete_rows = spider->conns[roop_count]->db_conn->affected_rows(); DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, roop_count)) - { - spider_clear_bit(spider->db_request_phase, roop_count); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[roop_count]; - request_key.next = NULL; - if ((result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!counted) - { - *delete_rows = conn->db_conn->affected_rows(); - DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); - counted = TRUE; - } - result->free_result(); - delete result; - } else { - if (!error_num) - { - error_num = spider_db_errorno(conn); - } - DBUG_RETURN(error_num); - } - } -#endif #ifdef HA_CAN_BULK_ACCESS } #endif @@ -8485,15 +7676,6 @@ int spider_db_direct_delete( if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) error_num2 = error_num; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) - { - if ((error_num = spider->reset_hs_sql(SPIDER_SQL_TYPE_DELETE_HS))) - error_num2 = error_num; - if ((error_num = spider->reset_hs_keys(SPIDER_SQL_TYPE_DELETE_HS))) - error_num2 = error_num; - } -#endif DBUG_RETURN(error_num2); } #else @@ -10550,36 +9732,16 @@ int spider_db_udf_direct_sql_connect( DBUG_PRINT("info",("spider net_read_timeout=%u", conn->net_read_timeout)); DBUG_PRINT("info",("spider net_write_timeout=%u", conn->net_write_timeout)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif if ((error_num = spider_reset_conn_setted_parameter(conn, thd))) DBUG_RETURN(error_num); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif if (conn->dbton_id == SPIDER_DBTON_SIZE) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif my_printf_error( ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, MYF(0), conn->tgt_wrapper); DBUG_RETURN(ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - my_printf_error( - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, - MYF(0), conn->tgt_wrapper); - DBUG_RETURN(ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM); - } -#endif } /* @@ -10616,10 +9778,6 @@ int spider_db_udf_direct_sql_ping( DBUG_RETURN(error_num); conn->server_lost = FALSE; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif if ((error_num = conn->db_conn->ping())) { spider_db_disconnect(conn); @@ -10637,9 +9795,6 @@ int spider_db_udf_direct_sql_ping( DBUG_RETURN(error_num); } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif conn->ping_time = (time_t) time((time_t*) 0); DBUG_RETURN(0); } @@ -10734,23 +9889,6 @@ int spider_db_udf_direct_sql( !(error_num = spider_db_udf_direct_sql_set_names(direct_sql, trx, conn)) && !(error_num = spider_db_udf_direct_sql_select_db(direct_sql, conn)) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode != 0) - { - st_spider_db_request_key request_key; - request_key.spider_thread_id = direct_sql->trx->spider_thread_id; - request_key.query_id = direct_sql->trx->thd->query_id; - request_key.handler = direct_sql; - request_key.request_id = 1; - request_key.next = NULL; - if ((error_num = conn->db_conn->append_sql( - direct_sql->sql, direct_sql->sql_length, &request_key))) - { - c_thd->lex->sql_command = sql_command_backup; - DBUG_RETURN(error_num); - } - } -#endif spider_conn_set_timeout_from_direct_sql(conn, thd, direct_sql); if (spider_db_query( conn, @@ -11004,9 +10142,6 @@ int spider_db_udf_direct_sql_select_db( DBUG_ENTER("spider_db_udf_direct_sql_select_db"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - direct_sql->access_mode == 0 && -#endif spider_dbton[conn->dbton_id].db_util->database_has_default_value() ) { DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); @@ -11052,10 +10187,6 @@ int spider_db_udf_direct_sql_set_names( int error_num, need_mon = 0; DBUG_ENTER("spider_db_udf_direct_sql_set_names"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if ( !conn->access_charset || @@ -11079,9 +10210,6 @@ int spider_db_udf_direct_sql_set_names( } conn->access_charset = trx->udf_access_charset; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif DBUG_RETURN(0); } @@ -12147,15 +11275,7 @@ int spider_db_open_handler( int error_num; SPIDER_SHARE *share = spider->share; uint *handler_id_ptr = -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - conn->conn_kind == SPIDER_CONN_KIND_MYSQL ? -#endif &spider->m_handler_id[link_idx] -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - : conn->conn_kind == SPIDER_CONN_KIND_HS_READ ? - &spider->r_handler_id[link_idx] : - &spider->w_handler_id[link_idx] -#endif ; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; DBUG_ENTER("spider_db_open_handler"); @@ -12170,20 +11290,17 @@ int spider_db_open_handler( conn->mta_conn_mutex_unlock_later = TRUE; if (!spider->handler_opened(link_idx, conn->conn_kind)) *handler_id_ptr = conn->opened_handlers; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif - if (!spider->handler_opened(link_idx, conn->conn_kind)) - my_sprintf(spider->m_handler_cid[link_idx], - (spider->m_handler_cid[link_idx], SPIDER_SQL_HANDLER_CID_FORMAT, - *handler_id_ptr)); + if (!spider->handler_opened(link_idx, conn->conn_kind)) + my_sprintf(spider->m_handler_cid[link_idx], + (spider->m_handler_cid[link_idx], + SPIDER_SQL_HANDLER_CID_FORMAT, + *handler_id_ptr)); - if ((error_num = dbton_hdl->append_open_handler_part( - SPIDER_SQL_TYPE_HANDLER, *handler_id_ptr, conn, link_idx))) - { - goto error; - } + if ((error_num = dbton_hdl->append_open_handler_part( + SPIDER_SQL_TYPE_HANDLER, *handler_id_ptr, conn, link_idx))) + { + goto error; + } spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, @@ -12198,154 +11315,6 @@ int spider_db_open_handler( goto error; } dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - uint reconnect = 0; - if (conn->hs_pre_age != conn->hs_age && conn->server_lost) - { - spider_conn_queue_connect(share, conn, link_idx); - reconnect |= 1; - } - if ((error_num = spider_db_conn_queue_action(conn))) - { - goto error; - } - if (conn->hs_pre_age != conn->hs_age) - { - if (conn->db_conn->ping()) - { - my_printf_error(ER_SPIDER_HS_NUM, ER_SPIDER_HS_STR, MYF(0), - conn->db_conn->get_errno(), conn->db_conn->get_error()); - spider->need_mons[link_idx] = ER_SPIDER_HS_NUM; - error_num = ER_SPIDER_HS_NUM; - goto error; - } - conn->opened_handlers = 0; - conn->db_conn->reset_opened_handler(); - conn->hs_age = conn->hs_pre_age; - reconnect |= 2; - } - if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - if (spider->hs_r_conn_ages[link_idx] != conn->hs_age) - { - spider->clear_handler_opened(link_idx, SPIDER_CONN_KIND_HS_READ); - *handler_id_ptr = conn->opened_handlers; - } - } else { - if (spider->hs_w_conn_ages[link_idx] != conn->hs_age) - { - spider->clear_handler_opened(link_idx, SPIDER_CONN_KIND_HS_WRITE); - *handler_id_ptr = conn->opened_handlers; - } - } - -#ifdef HA_CAN_BULK_ACCESS - if (!spider->is_bulk_access_clone) - { -#endif - conn->db_conn->reset_request_queue(); -#ifdef HA_CAN_BULK_ACCESS - } else if (!spider->bulk_access_executing) - { - if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider_set_bit(spider->result_list.hs_r_bulk_open_index, link_idx); - } else { - spider_set_bit(spider->result_list.hs_w_bulk_open_index, link_idx); - } - } -#endif - if ((error_num = dbton_hdl->append_open_handler_part( - SPIDER_SQL_TYPE_OTHER_HS, *handler_id_ptr, conn, link_idx))) - { - goto error; - } -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone && !spider->bulk_access_executing) - { - spider->connection_ids[link_idx] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if (dbton_hdl->execute_sql( - SPIDER_SQL_TYPE_SELECT_HS, - conn, - -1, - &spider->need_mons[link_idx]) - ) { - error_num = spider_db_errorno(conn); - goto error; - } - - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_clear_bit(spider->db_request_phase, link_idx); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = - spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - if (!(result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!error_num) - { - spider_db_errorno(conn); - error_num = ER_SPIDER_HS_NUM; - } - goto error; - } else { - conn->ping_time = (time_t) time((time_t*) 0); - } - result->free_result(); - delete result; -#ifdef HA_CAN_BULK_ACCESS - } -#endif - if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - spider->r_handler_index[link_idx] = spider->active_index; - spider->hs_r_conn_ages[link_idx] = conn->hs_age; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->sql_command != SQLCOM_HS_INSERT && - spider->hs_pushed_ret_fields_num < MAX_FIELDS - ) { - spider->hs_r_ret_fields_num[link_idx] = - spider->hs_pushed_ret_fields_num; - memcpy(spider->hs_r_ret_fields[link_idx], spider->hs_pushed_ret_fields, - sizeof(uint32) * spider->hs_pushed_ret_fields_num); - } else { - spider->hs_r_ret_fields_num[link_idx] = MAX_FIELDS; - } -#endif - } else { - spider->w_handler_index[link_idx] = spider->active_index; - spider->hs_w_conn_ages[link_idx] = conn->hs_age; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->sql_command != SQLCOM_HS_INSERT && - spider->hs_pushed_ret_fields_num < MAX_FIELDS - ) { - spider->hs_w_ret_fields_num[link_idx] = - spider->hs_pushed_ret_fields_num; - memcpy(spider->hs_w_ret_fields[link_idx], spider->hs_pushed_ret_fields, - sizeof(uint32) * spider->hs_pushed_ret_fields_num); - } else { - spider->hs_w_ret_fields_num[link_idx] = MAX_FIELDS; - } -#endif - } - } -#endif if (!spider->handler_opened(link_idx, conn->conn_kind)) { if ((error_num = dbton_hdl->insert_opened_handler(conn, link_idx))) @@ -12379,74 +11348,10 @@ int spider_db_bulk_open_handler( int link_idx ) { int error_num = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - bool opening_index = FALSE; -#endif DBUG_ENTER("spider_db_bulk_open_handler"); DBUG_PRINT("info",("spider spider=%p", spider)); DBUG_PRINT("info",("spider conn=%p", conn)); DBUG_PRINT("info",("spider link_idx=%d", link_idx)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_ASSERT(conn->conn_kind != SPIDER_CONN_KIND_MYSQL); - if (conn->conn_kind == SPIDER_CONN_KIND_HS_READ) - { - if (spider_bit_is_set(spider->result_list.hs_r_bulk_open_index, link_idx)) - { - DBUG_PRINT("info",("spider SPIDER_CONN_KIND_HS_READ")); - spider_clear_bit(spider->result_list.hs_r_bulk_open_index, link_idx); - opening_index = TRUE; - } - } else { - if (spider_bit_is_set(spider->result_list.hs_w_bulk_open_index, link_idx)) - { - DBUG_PRINT("info",("spider SPIDER_CONN_KIND_HS_WRITE")); - spider_clear_bit(spider->result_list.hs_w_bulk_open_index, link_idx); - opening_index = TRUE; - } - } - if (opening_index) - { - DBUG_PRINT("info",("spider conn->connection_id=%llu", - conn->connection_id)); - DBUG_PRINT("info",("spider spider->connection_ids[%d]=%llu", - link_idx, spider->connection_ids[link_idx])); - if (conn->connection_id != spider->connection_ids[link_idx]) - { - my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, - ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); - DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); - } - - bool tmp_mta_conn_mutex_unlock_later; - pthread_mutex_assert_owner(&conn->mta_conn_mutex); - tmp_mta_conn_mutex_unlock_later = conn->mta_conn_mutex_unlock_later; - conn->mta_conn_mutex_unlock_later = TRUE; - SPIDER_DB_RESULT *result; - if (spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_clear_bit(spider->db_request_phase, link_idx); - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id; - request_key.query_id = spider->wide_handler->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - if (!(result = conn->db_conn->use_result(spider, &request_key, - &error_num))) - { - if (!error_num) - { - spider_db_errorno(conn); - error_num = ER_SPIDER_HS_NUM; - } - } else { - result->free_result(); - delete result; - } - conn->mta_conn_mutex_unlock_later = tmp_mta_conn_mutex_unlock_later; - } -#endif DBUG_RETURN(error_num); } #endif @@ -12471,10 +11376,6 @@ int spider_db_close_handler( conn->mta_conn_mutex_unlock_later = TRUE; if (spider->handler_opened(link_idx, tgt_conn_kind)) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { -#endif dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); if ((error_num = dbton_hdl->append_close_handler_part( SPIDER_SQL_TYPE_HANDLER, link_idx))) @@ -12501,14 +11402,6 @@ int spider_db_close_handler( goto error; } dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { -/* - conn->hs_conn->close(); - conn->server_lost = TRUE; -*/ - } -#endif if ((error_num = dbton_hdl->delete_opened_handler(conn, link_idx))) goto error; conn->opened_handlers--; @@ -12532,22 +11425,6 @@ error: DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -void spider_db_hs_request_buf_reset( - SPIDER_CONN *conn -) { - DBUG_ENTER("spider_db_hs_request_buf_reset"); - if (conn->bulk_access_requests) - { - if (conn->db_conn->is_connected()) - { - conn->db_conn->reset_request_queue(); - } - conn->bulk_access_requests = 0; - } - DBUG_VOID_RETURN; -} -#endif bool spider_db_conn_is_network_error( int error_num diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h index cbfc3e724ed..bae4ee35439 100644 --- a/storage/spider/spd_db_conn.h +++ b/storage/spider/spd_db_conn.h @@ -1217,11 +1217,6 @@ int spider_db_close_handler( uint tgt_conn_kind ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -void spider_db_hs_request_buf_reset( - SPIDER_CONN *conn -); -#endif bool spider_db_conn_is_network_error( int error_num diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc deleted file mode 100644 index a9d42f54c24..00000000000 --- a/storage/spider/spd_db_handlersocket.cc +++ /dev/null @@ -1,6311 +0,0 @@ -/* Copyright (C) 2012-2018 Kentoku Shiba - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ - -#define MYSQL_SERVER 1 -#include -#include "mysql_version.h" -#include "spd_environ.h" -#include "sql_priv.h" -#include "probes_mysql.h" -#include "sql_analyse.h" - -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#include "spd_err.h" -#include "spd_param.h" -#include "spd_db_include.h" -#include "spd_include.h" -#include "spd_db_handlersocket.h" -#include "ha_spider.h" -#include "spd_db_conn.h" -#include "spd_trx.h" -#include "spd_conn.h" -#include "spd_malloc.h" - -extern handlerton *spider_hton_ptr; -extern HASH spider_open_connections; -extern HASH spider_ipport_conns; -extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; -extern const char spider_dig_upper[]; - -#define SPIDER_SQL_INTERVAL_STR " + interval " -#define SPIDER_SQL_INTERVAL_LEN (sizeof(SPIDER_SQL_INTERVAL_STR) - 1) -#define SPIDER_SQL_NEGINTERVAL_STR " - interval " -#define SPIDER_SQL_NEGINTERVAL_LEN (sizeof(SPIDER_SQL_NEGINTERVAL_STR) - 1) - -#define SPIDER_SQL_NAME_QUOTE_STR "" -#define SPIDER_SQL_NAME_QUOTE_LEN (sizeof(SPIDER_SQL_NAME_QUOTE_STR) - 1) -static const char *name_quote_str = SPIDER_SQL_NAME_QUOTE_STR; - -#define SPIDER_SQL_TYPE_FULL_HS (SPIDER_SQL_TYPE_SELECT_HS | \ - SPIDER_SQL_TYPE_INSERT_HS | SPIDER_SQL_TYPE_UPDATE_HS | \ - SPIDER_SQL_TYPE_DELETE_HS | SPIDER_SQL_TYPE_OTHER_HS) - -static uchar SPIDER_SQL_LINESTRING_HEAD_STR[] = - {0x00,0x00,0x00,0x00,0x01,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00}; -#define SPIDER_SQL_LINESTRING_HEAD_LEN sizeof(SPIDER_SQL_LINESTRING_HEAD_STR) - -static const char *spider_db_timefunc_interval_str[] = -{ - " year", " quarter", " month", " week", " day", - " hour", " minute", " second", " microsecond", - " year_month", " day_hour", " day_minute", - " day_second", " hour_minute", " hour_second", - " minute_second", " day_microsecond", " hour_microsecond", - " minute_microsecond", " second_microsecond" -}; - -static SPIDER_HS_STRING_REF spider_null_string_ref = SPIDER_HS_STRING_REF(); - -int spider_handlersocket_init() -{ - DBUG_ENTER("spider_handlersocket_init"); - DBUG_RETURN(0); -} - -int spider_handlersocket_deinit() -{ - DBUG_ENTER("spider_handlersocket_deinit"); - DBUG_RETURN(0); -} - -spider_db_share *spider_handlersocket_create_share( - SPIDER_SHARE *share -) { - DBUG_ENTER("spider_handlersocket_create_share"); - DBUG_RETURN(new spider_handlersocket_share(share)); -} - -spider_db_handler *spider_handlersocket_create_handler( - ha_spider *spider, - spider_db_share *db_share -) { - DBUG_ENTER("spider_handlersocket_create_handler"); - DBUG_RETURN(new spider_handlersocket_handler(spider, - (spider_handlersocket_share *) db_share)); -} - -SPIDER_DB_CONN *spider_handlersocket_create_conn( - SPIDER_CONN *conn -) { - DBUG_ENTER("spider_handlersocket_create_conn"); - DBUG_RETURN(new spider_db_handlersocket(conn)); -} - -bool spider_handlersocket_support_direct_join( -) { - DBUG_ENTER("spider_handlersocket_support_direct_join"); - DBUG_RETURN(FALSE); -} - -spider_db_handlersocket_util spider_db_handlersocket_utility; - -SPIDER_DBTON spider_dbton_handlersocket = { - 0, - SPIDER_DB_WRAPPER_MYSQL, - SPIDER_DB_ACCESS_TYPE_NOSQL, - spider_handlersocket_init, - spider_handlersocket_deinit, - spider_handlersocket_create_share, - spider_handlersocket_create_handler, - NULL, - spider_handlersocket_create_conn, - spider_handlersocket_support_direct_join, - &spider_db_handlersocket_utility, - "For communicating using the handlersocket protocol", - "0.1.0", - SPIDER_MATURITY_BETA -}; - -#ifndef HANDLERSOCKET_MYSQL_UTIL -spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -int spider_db_hs_string_ref_buffer::init() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::init"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -void spider_db_hs_string_ref_buffer::clear() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::clear"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_conds.clear(); - DBUG_VOID_RETURN; -} - -int spider_db_hs_string_ref_buffer::push_back( - SPIDER_HS_STRING_REF &cond -) { - DBUG_ENTER("spider_db_hs_string_ref_buffer::push_back"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_conds.push_back(cond); - DBUG_RETURN(0); -} - -SPIDER_HS_STRING_REF *spider_db_hs_string_ref_buffer::ptr() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::ptr"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(&hs_conds[0]); -} - -uint spider_db_hs_string_ref_buffer::size() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::size"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN((uint) hs_conds.size()); -} -#else -spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer() : hs_da_init(FALSE) -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::spider_db_hs_string_ref_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::~spider_db_hs_string_ref_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - if (hs_da_init) - { - spider_free_mem_calc(spider_current_trx, - hs_conds_id, hs_conds.max_element * hs_conds.size_of_element); - delete_dynamic(&hs_conds); - } - DBUG_VOID_RETURN; -} - -int spider_db_hs_string_ref_buffer::init() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!hs_da_init) - { - SPD_INIT_DYNAMIC_ARRAY2(&hs_conds, sizeof(SPIDER_HS_STRING_REF), - NULL, 16, 16, MYF(MY_WME)); - spider_alloc_calc_mem_init(hs_conds, SPD_MID_DB_HS_STRING_REF_BUFFER_INIT_1); - spider_alloc_calc_mem(spider_current_trx, - hs_conds, hs_conds.max_element * hs_conds.size_of_element); - hs_da_init = TRUE; - } - DBUG_RETURN(0); -} - -void spider_db_hs_string_ref_buffer::clear() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::clear"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_conds.elements = 0; - DBUG_VOID_RETURN; -} - -int spider_db_hs_string_ref_buffer::push_back( - SPIDER_HS_STRING_REF &cond -) { - uint old_elements = hs_conds.max_element; - DBUG_ENTER("spider_db_hs_string_ref_buffer::push_back"); - DBUG_PRINT("info",("spider this=%p", this)); - if (insert_dynamic(&hs_conds, (uchar *) &cond)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (hs_conds.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - hs_conds, - (hs_conds.max_element - old_elements) * hs_conds.size_of_element); - } - DBUG_RETURN(0); -} - -SPIDER_HS_STRING_REF *spider_db_hs_string_ref_buffer::ptr() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::ptr"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN((SPIDER_HS_STRING_REF *) hs_conds.buffer); -} - -uint spider_db_hs_string_ref_buffer::size() -{ - DBUG_ENTER("spider_db_hs_string_ref_buffer::size"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(hs_conds.elements); -} -#endif - -spider_db_hs_str_buffer::spider_db_hs_str_buffer() : hs_da_init(FALSE) -{ - DBUG_ENTER("spider_db_hs_str_buffer::spider_db_hs_str_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_hs_str_buffer::~spider_db_hs_str_buffer() -{ - DBUG_ENTER("spider_db_hs_str_buffer::~spider_db_hs_str_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - if (hs_da_init) - { - spider_free_mem_calc(spider_current_trx, - hs_conds_id, hs_conds.max_element * hs_conds.size_of_element); - delete_dynamic(&hs_conds); - } - DBUG_VOID_RETURN; -} - -int spider_db_hs_str_buffer::init() -{ - DBUG_ENTER("spider_db_hs_str_buffer::init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!hs_da_init) - { - SPD_INIT_DYNAMIC_ARRAY2(&hs_conds, sizeof(spider_string *), - NULL, 16, 16, MYF(MY_WME)); - spider_alloc_calc_mem_init(hs_conds, SPD_MID_DB_HS_STR_BUFFER_INIT_1); - spider_alloc_calc_mem(spider_current_trx, - hs_conds, hs_conds.max_element * hs_conds.size_of_element); - hs_da_init = TRUE; - } - DBUG_RETURN(0); -} - -void spider_db_hs_str_buffer::clear() -{ - uint i; - spider_string *element; - DBUG_ENTER("spider_db_hs_str_buffer::clear"); - DBUG_PRINT("info",("spider this=%p", this)); - for (i = 0; i < hs_conds.elements; i++) - { - get_dynamic(&hs_conds, (uchar *) &element, i); - element->free(); - spider_free(spider_current_trx, element, MYF(0)); - } - hs_conds.elements = 0; - DBUG_VOID_RETURN; -} - -spider_string *spider_db_hs_str_buffer::add( - uint *strs_pos, - const char *str, - uint str_len -) { - spider_string *element; - DBUG_ENTER("spider_db_hs_str_buffer::add"); - DBUG_PRINT("info",("spider this=%p", this)); - if (hs_conds.elements <= *strs_pos + 1) - { - if (!(element = (spider_string *) spider_malloc(spider_current_trx, SPD_MID_DB_HS_STR_BUFFER_ADD_1, - sizeof(spider_string), MYF(MY_WME | MY_ZEROFILL)))) - DBUG_RETURN(NULL); - element->init_calc_mem(SPD_MID_DB_HS_STR_BUFFER_ADD_2); - element->set_charset(&my_charset_bin); - if ((element->reserve(str_len + 1))) - { - spider_free(spider_current_trx, element, MYF(0)); - DBUG_RETURN(NULL); - } - element->q_append(str, str_len); - uint old_elements = hs_conds.max_element; - if (insert_dynamic(&hs_conds, (uchar *) &element)) - { - element->free(); - spider_free(spider_current_trx, element, MYF(0)); - DBUG_RETURN(NULL); - } - if (hs_conds.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - hs_conds, - (hs_conds.max_element - old_elements) * - hs_conds.size_of_element); - } - } else { - element = ((spider_string **) hs_conds.buffer)[*strs_pos]; - element->length(0); - if ((element->reserve(str_len + 1))) - DBUG_RETURN(NULL); - element->q_append(str, str_len); - } - (*strs_pos)++; - DBUG_RETURN(element); -} - -spider_db_handlersocket_row::spider_db_handlersocket_row() : - spider_db_row(spider_dbton_handlersocket.dbton_id), - hs_row(NULL), field_count(0), row_size(0), cloned(FALSE) -{ - DBUG_ENTER("spider_db_handlersocket_row::spider_db_handlersocket_row"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_handlersocket_row::~spider_db_handlersocket_row() -{ - DBUG_ENTER("spider_db_handlersocket_row::~spider_db_handlersocket_row"); - DBUG_PRINT("info",("spider this=%p", this)); - if (cloned) - { - spider_free(spider_current_trx, hs_row_first, MYF(0)); - } - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket_row::store_to_field( - Field *field, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_row::store_to_field"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!hs_row->begin()) - { - DBUG_PRINT("info", ("spider field is null")); - field->set_null(); - field->reset(); - } else { -#ifndef DBUG_OFF - char buf[MAX_FIELD_WIDTH]; - spider_string tmp_str(buf, MAX_FIELD_WIDTH, field->charset()); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_ROW_STORE_TO_FIELD_1); - tmp_str.length(0); - tmp_str.append(hs_row->begin(), hs_row->size(), &my_charset_bin); - DBUG_PRINT("info", ("spider val=%s", tmp_str.c_ptr_safe())); -#endif - field->set_notnull(); - if (field->flags & BLOB_FLAG) - { - DBUG_PRINT("info", ("spider blob field")); - ((Field_blob *)field)->set_ptr( - hs_row->size(), (uchar *) hs_row->begin()); - } else - field->store(hs_row->begin(), hs_row->size(), &my_charset_bin); - } - DBUG_RETURN(0); -} - -int spider_db_handlersocket_row::append_to_str( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_row::append_to_str"); - DBUG_PRINT("info",("spider this=%p", this)); - if (str->reserve(hs_row->size())) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(hs_row->begin(), hs_row->size()); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_row::append_escaped_to_str( - spider_string *str, - uint dbton_id -) { - DBUG_ENTER("spider_db_handlersocket_row::append_escaped_to_str"); - DBUG_PRINT("info",("spider this=%p", this)); - spider_string tmp_str(hs_row->begin(), hs_row->size() + 1, &my_charset_bin); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_ROW_APPEND_ESCAPED_TO_STR_1); - tmp_str.length(hs_row->size()); - if (str->reserve(hs_row->size() * 2 + 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - spider_dbton[dbton_id].db_util->append_escaped_util(str, tmp_str.get_str()); - str->mem_calc(); - DBUG_RETURN(0); -} - -void spider_db_handlersocket_row::first() -{ - DBUG_ENTER("spider_db_handlersocket_row::first"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_row = hs_row_first; - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket_row::next() -{ - DBUG_ENTER("spider_db_handlersocket_row::next"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_row++; - DBUG_VOID_RETURN; -} - -bool spider_db_handlersocket_row::is_null() -{ - DBUG_ENTER("spider_db_handlersocket_row::is_null"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(!hs_row->begin()); -} - -int spider_db_handlersocket_row::val_int() -{ - DBUG_ENTER("spider_db_handlersocket_row::val_int"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(atoi(hs_row->begin())); -} - -double spider_db_handlersocket_row::val_real() -{ - DBUG_ENTER("spider_db_handlersocket_row::val_real"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(hs_row->begin() ? my_atof(hs_row->begin()) : 0.0); -} - -my_decimal *spider_db_handlersocket_row::val_decimal( - my_decimal *decimal_value, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_row::val_decimal"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!hs_row->begin()) - DBUG_RETURN(NULL); - -#ifdef SPIDER_HAS_DECIMAL_OPERATION_RESULTS_VALUE_TYPE - decimal_operation_results(str2my_decimal(0, hs_row->begin(), hs_row->size(), - access_charset, decimal_value), "", ""); -#else - decimal_operation_results(str2my_decimal(0, hs_row->begin(), hs_row->size(), - access_charset, decimal_value)); -#endif - - DBUG_RETURN(decimal_value); -} - -SPIDER_DB_ROW *spider_db_handlersocket_row::clone() -{ - spider_db_handlersocket_row *clone_row; - char *tmp_char; - uint i; - DBUG_ENTER("spider_db_handlersocket_row::clone"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(clone_row = new spider_db_handlersocket_row(dbton_id))) - { - DBUG_RETURN(NULL); - } - if (!spider_bulk_malloc(spider_current_trx, SPD_MID_DB_HANDLERSOCKET_ROW_CLONE_1, MYF(MY_WME), - &clone_row->hs_row, (uint) (sizeof(SPIDER_HS_STRING_REF) * field_count), - &tmp_char, (uint) (row_size), - NullS) - ) { - delete clone_row; - DBUG_RETURN(NULL); - } - for (i = 0; i < field_count; i++) - { - memcpy(tmp_char, hs_row_first[i].begin(), hs_row_first[i].size()); - clone_row->hs_row[i].set(tmp_char, hs_row_first[i].size()); - tmp_char += hs_row_first[i].size(); - } - clone_row->hs_row_first = clone_row->hs_row; - clone_row->cloned = TRUE;; - clone_row->row_size = row_size;; - DBUG_RETURN(NULL); -} - -int spider_db_handlersocket_row::store_to_tmp_table( - TABLE *tmp_table, - spider_string *str -) { - uint i; - SPIDER_HS_STRING_REF *tmp_hs_row = hs_row; - DBUG_ENTER("spider_db_handlersocket_row::store_to_tmp_table"); - DBUG_PRINT("info",("spider this=%p", this)); - str->length(0); - for (i = 0; i < field_count; i++) - { - if (tmp_hs_row->begin()) - { - if (str->reserve(tmp_hs_row->size())) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(tmp_hs_row->begin(), tmp_hs_row->size()); - } - tmp_hs_row++; - } - tmp_table->field[0]->set_notnull(); - tmp_table->field[0]->store( - (const char *) hs_row, - sizeof(SPIDER_HS_STRING_REF) * field_count, &my_charset_bin); - tmp_table->field[1]->set_notnull(); - tmp_table->field[1]->store( - str->ptr(), str->length(), &my_charset_bin); - tmp_table->field[2]->set_null(); - DBUG_RETURN(tmp_table->file->ha_write_row(tmp_table->record[0])); -} - -uint spider_db_handlersocket_row::get_byte_size() -{ - DBUG_ENTER("spider_db_handlersocket_row::get_byte_size"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(row_size); -} - - -spider_db_handlersocket_result_buffer::spider_db_handlersocket_result_buffer( -) : spider_db_result_buffer() -{ - DBUG_ENTER("spider_db_handlersocket_result_buffer::spider_db_handlersocket_result_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_handlersocket_result_buffer::~spider_db_handlersocket_result_buffer() -{ - DBUG_ENTER( - "spider_db_handlersocket_result_buffer::~spider_db_handlersocket_result_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket_result_buffer::clear() -{ - DBUG_ENTER("spider_db_handlersocket_result_buffer::clear"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_result.readbuf.clear(); - DBUG_VOID_RETURN; -} - -bool spider_db_handlersocket_result_buffer::check_size( - longlong size -) { - DBUG_ENTER("spider_db_handlersocket_result_buffer::check_size"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((uint) hs_result.readbuf.real_size() > size) - { - hs_result.readbuf.real_free(); - DBUG_RETURN(TRUE); - } - DBUG_RETURN(FALSE); -} - -spider_db_handlersocket_result::spider_db_handlersocket_result( - SPIDER_DB_CONN *in_db_conn -) : spider_db_result(in_db_conn), row(in_db_conn->dbton_id) -{ - DBUG_ENTER("spider_db_handlersocket_result::spider_db_handlersocket_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_handlersocket_result::~spider_db_handlersocket_result() -{ - DBUG_ENTER( - "spider_db_handlersocket_result::~spider_db_handlersocket_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -bool spider_db_handlersocket_result::has_result() -{ - DBUG_ENTER("spider_db_handlersocket_result::has_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(((*hs_conn_p)->get_response_end_offset() > 0)); -} - -void spider_db_handlersocket_result::free_result() -{ - DBUG_ENTER("spider_db_handlersocket_result::free_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ((*hs_conn_p)->get_response_end_offset() > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - DBUG_VOID_RETURN; -} - -SPIDER_DB_ROW *spider_db_handlersocket_result::current_row() -{ - DBUG_ENTER("spider_db_handlersocket_result::current_row"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN((SPIDER_DB_ROW *) row.clone()); -} - -SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row() -{ - DBUG_ENTER("spider_db_handlersocket_result::fetch_row"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(row.hs_row = (SPIDER_HS_STRING_REF *) - (*hs_conn_p)->get_next_row())) - { - store_error_num = HA_ERR_END_OF_FILE; - DBUG_RETURN(NULL); - } - row.field_count = field_count; - row.hs_row_first = row.hs_row; - row.row_size = (*hs_conn_p)->get_row_size(); - DBUG_RETURN((SPIDER_DB_ROW *) &row); -} - -SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row_from_result_buffer( - spider_db_result_buffer *spider_res_buf -) { - spider_db_handlersocket_result_buffer *hs_res_buf; - DBUG_ENTER("spider_db_handlersocket_result::fetch_row_from_result_buffer"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_res_buf = (spider_db_handlersocket_result_buffer *) spider_res_buf; - if (!(row.hs_row = (SPIDER_HS_STRING_REF *) - (*hs_conn_p)->get_next_row_from_result(hs_res_buf->hs_result))) - { - store_error_num = HA_ERR_END_OF_FILE; - DBUG_RETURN(NULL); - } - row.field_count = field_count; - row.hs_row_first = row.hs_row; - row.row_size = (*hs_conn_p)->get_row_size_from_result(hs_res_buf->hs_result); - DBUG_RETURN((SPIDER_DB_ROW *) &row); -} - -SPIDER_DB_ROW *spider_db_handlersocket_result::fetch_row_from_tmp_table( - TABLE *tmp_table -) { - uint i; - spider_string tmp_str1, tmp_str2; - const char *row_ptr; - SPIDER_HS_STRING_REF *tmp_hs_row; - uint field_count; - DBUG_ENTER("spider_db_handlersocket_result::fetch_row_from_tmp_table"); - DBUG_PRINT("info",("spider this=%p", this)); - tmp_str1.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_RESULT_FETCH_ROW_FROM_TMP_TABLE_1); - tmp_str2.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_RESULT_FETCH_ROW_FROM_TMP_TABLE_2); - tmp_table->field[0]->val_str(tmp_str1.get_str()); - tmp_table->field[1]->val_str(tmp_str2.get_str()); - tmp_str1.mem_calc(); - tmp_str2.mem_calc(); - row_ptr = tmp_str2.ptr(); - tmp_hs_row = (SPIDER_HS_STRING_REF *) tmp_str1.ptr(); - field_count = tmp_str1.length() / sizeof(SPIDER_HS_STRING_REF); - row.hs_row = tmp_hs_row; - row.field_count = field_count; - row.hs_row_first = row.hs_row; - for (i = 0; i < field_count; i++) - { - if (tmp_hs_row->begin()) - { - uint length = tmp_hs_row->size(); - tmp_hs_row->set(row_ptr, length); - row_ptr += length; - } - tmp_hs_row++; - } - row.row_size = row_ptr - tmp_str2.ptr(); - DBUG_RETURN((SPIDER_DB_ROW *) &row); -} - -int spider_db_handlersocket_result::fetch_table_status( - int mode, - ha_statistics &stat -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_status"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_result::fetch_table_records( - int mode, - ha_rows &records -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_records"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_result::fetch_table_cardinality( - int mode, - TABLE *table, - longlong *cardinality, - uchar *cardinality_upd, - int bitmap_size -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_cardinality"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_result::fetch_table_mon_status( - int &status -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_mon_status"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -longlong spider_db_handlersocket_result::num_rows() -{ - DBUG_ENTER("spider_db_handlersocket_result::num_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN((longlong) 0); -} - -uint spider_db_handlersocket_result::num_fields() -{ - DBUG_ENTER("spider_db_handlersocket_result::num_fields"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(field_count); -} - -void spider_db_handlersocket_result::move_to_pos( - longlong pos -) { - DBUG_ENTER("spider_db_handlersocket_result::move_to_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket_result::get_errno() -{ - DBUG_ENTER("spider_db_handlersocket_result::get_errno"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider store_error_num=%d", store_error_num)); - DBUG_RETURN(store_error_num); -} - -#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE -int spider_db_handlersocket_result::fetch_columns_for_discover_table_structure( - spider_string *str, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_columns_for_discover_table_structure"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} - -int spider_db_handlersocket_result::fetch_index_for_discover_table_structure( - spider_string *str, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_index_for_discover_table_structure"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} - -int spider_db_handlersocket_result::fetch_table_for_discover_table_structure( - spider_string *str, - SPIDER_SHARE *spider_share, - CHARSET_INFO *access_charset -) { - DBUG_ENTER("spider_db_handlersocket_result::fetch_table_for_discover_table_structure"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} -#endif - -spider_db_handlersocket::spider_db_handlersocket( - SPIDER_CONN *conn -) : spider_db_conn(conn), - handler_open_array_inited(FALSE), - request_key_req_first(NULL), - request_key_req_last(NULL), - request_key_snd_first(NULL), - request_key_snd_last(NULL), - request_key_reuse_first(NULL), - request_key_reuse_last(NULL) -{ - DBUG_ENTER("spider_db_handlersocket::spider_db_handlersocket"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL -#else - hs_conn = NULL; -#endif - DBUG_VOID_RETURN; -} - -spider_db_handlersocket::~spider_db_handlersocket() -{ - st_spider_db_request_key *tmp_request_key; - DBUG_ENTER("spider_db_handlersocket::~spider_db_handlersocket"); - DBUG_PRINT("info",("spider this=%p", this)); - if (handler_open_array_inited) - { - reset_opened_handler(); - spider_free_mem_calc(spider_current_trx, - handler_open_array_id, - handler_open_array.max_element * - handler_open_array.size_of_element); - delete_dynamic(&handler_open_array); - } - while (request_key_req_first) - { - tmp_request_key = request_key_req_first->next; - spider_free(spider_current_trx, request_key_req_first, MYF(0)); - request_key_req_first = tmp_request_key; - } - while (request_key_snd_first) - { - tmp_request_key = request_key_snd_first->next; - spider_free(spider_current_trx, request_key_snd_first, MYF(0)); - request_key_snd_first = tmp_request_key; - } - while (request_key_reuse_first) - { - tmp_request_key = request_key_reuse_first->next; - spider_free(spider_current_trx, request_key_reuse_first, MYF(0)); - request_key_reuse_first = tmp_request_key; - } - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::init() -{ - DBUG_ENTER("spider_db_handlersocket::init"); - DBUG_PRINT("info",("spider this=%p", this)); - if ( - SPD_INIT_DYNAMIC_ARRAY2(&handler_open_array, - sizeof(SPIDER_LINK_FOR_HASH *), NULL, 16, 16, MYF(MY_WME)) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - spider_alloc_calc_mem_init(handler_open_array, SPD_MID_DB_HANDLERSOCKET_INIT_1); - spider_alloc_calc_mem(spider_current_trx, - handler_open_array, - handler_open_array.max_element * - handler_open_array.size_of_element); - handler_open_array_inited = TRUE; - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::is_connected() -{ - DBUG_ENTER("spider_db_handlersocket::is_connected"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL - DBUG_RETURN(hs_conn.operator->()); -#else - DBUG_RETURN(hs_conn); -#endif -} - -void spider_db_handlersocket::bg_connect() -{ - DBUG_ENTER("spider_db_handlersocket::bg_connect"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::connect( - char *tgt_host, - char *tgt_username, - char *tgt_password, - long tgt_port, - char *tgt_socket, - char *server_name, - int connect_retry_count, - longlong connect_retry_interval -) { - DBUG_ENTER("spider_db_handlersocket::connect"); - DBUG_PRINT("info",("spider this=%p", this)); - SPIDER_HS_SOCKARGS sockargs; - sockargs.timeout = conn->connect_timeout; - sockargs.recv_timeout = conn->net_read_timeout; - sockargs.send_timeout = conn->net_write_timeout; - if (conn->hs_sock) - { - sockargs.family = AF_UNIX; - sockargs.set_unix_domain(conn->hs_sock); - } else { - char port_str[6]; - my_sprintf(port_str, (port_str, "%05ld", conn->hs_port)); - if (sockargs.resolve(conn->tgt_host, port_str) != 0) - { - my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), - conn->tgt_host); - DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); - } - } -#ifndef HANDLERSOCKET_MYSQL_UTIL - if (!(hs_conn.operator->())) -#else - if (!(hs_conn)) -#endif - { - hs_conn = SPIDER_HS_CONN_CREATE(sockargs); - } else { - hs_conn->reconnect(); - spider_db_hs_request_buf_reset(conn); - } -#ifndef HANDLERSOCKET_MYSQL_UTIL - if (!(hs_conn.operator->())) -#else - if (!(hs_conn)) -#endif - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - while (hs_conn->get_error_code()) - { - THD *thd = current_thd; - if ( - !connect_retry_count || - (thd && thd->killed) - ) { - my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), - conn->tgt_host); - DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); - } - connect_retry_count--; - my_sleep((ulong) connect_retry_interval); - hs_conn->reconnect(); - } - reset_request_key_req(); - reset_request_key_snd(); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::ping() -{ - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::ping"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ((*hs_conn_p)->reconnect()) - { - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(ER_SPIDER_HS_NUM); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - - reset_request_key_req(); - reset_request_key_snd(); - conn->opened_handlers = 0; - conn->db_conn->reset_opened_handler(); - ++conn->connection_id; - DBUG_RETURN(0); -} - -void spider_db_handlersocket::bg_disconnect() -{ - DBUG_ENTER("spider_db_handlersocket::bg_disconnect"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket::disconnect() -{ - DBUG_ENTER("spider_db_handlersocket::disconnect"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL - if (hs_conn.operator->()) -#else - DBUG_PRINT("info",("spider hs_conn=%p", hs_conn)); - if (hs_conn) -#endif - { - hs_conn->close(); -#ifndef HANDLERSOCKET_MYSQL_UTIL - SPIDER_HS_CONN tmp_hs_conn; - tmp_hs_conn = hs_conn; -#else - delete hs_conn; - hs_conn = NULL; -#endif - } - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::set_net_timeout() -{ - DBUG_ENTER("spider_db_handlersocket::set_net_timeout"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(hs_conn->set_timeout( - conn->net_write_timeout, - conn->net_read_timeout - )); -} - -int spider_db_handlersocket::exec_query( - const char *query, - uint length, - int quick_mode -) { - DBUG_ENTER("spider_db_handlersocket::query"); - DBUG_PRINT("info",("spider this=%p", this)); - SPIDER_HS_CONN *hs_conn_p = &hs_conn; -#ifndef HANDLERSOCKET_MYSQL_UTIL - DBUG_PRINT("info", ("spider hs_conn %p", hs_conn.operator->())); -#else - DBUG_PRINT("info", ("spider hs_conn %p", hs_conn)); -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (spider_param_general_log()) - { - const char *tgt_str = conn->hs_sock ? conn->hs_sock : conn->tgt_host; - uint32 tgt_len = strlen(tgt_str); - spider_string tmp_query_str((*hs_conn_p)->get_writebuf_size() + - conn->tgt_wrapper_length + - tgt_len + (SPIDER_SQL_SPACE_LEN * 2)); - tmp_query_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_EXEC_QUERY_1); - tmp_query_str.length(0); - tmp_query_str.q_append(conn->tgt_wrapper, conn->tgt_wrapper_length); - tmp_query_str.q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - tmp_query_str.q_append(tgt_str, tgt_len); - tmp_query_str.q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - tmp_query_str.q_append((*hs_conn_p)->get_writebuf_begin(), - (*hs_conn_p)->get_writebuf_size()); - general_log_write(current_thd, COM_QUERY, tmp_query_str.ptr(), - tmp_query_str.length()); - } - if ((*hs_conn_p)->request_send() < 0) - { - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(ER_SPIDER_HS_NUM); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - move_request_key_to_snd(); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::get_errno() -{ - DBUG_ENTER("spider_db_handlersocket::get_errno"); - DBUG_PRINT("info",("spider this=%p", this)); - stored_error = hs_conn->get_error_code(); - DBUG_PRINT("info",("spider stored_error=%d", stored_error)); - DBUG_RETURN(stored_error); -} - -const char *spider_db_handlersocket::get_error() -{ - const char *error_ptr; - DBUG_ENTER("spider_db_handlersocket::get_error"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL - error_ptr = hs_conn->get_error().c_str(); -#else - error_ptr = hs_conn->get_error().c_ptr(); -#endif - DBUG_PRINT("info",("spider error=%s", error_ptr)); - DBUG_RETURN(error_ptr); -} - -bool spider_db_handlersocket::is_server_gone_error( - int error_num -) { - bool server_gone; - DBUG_ENTER("spider_db_handlersocket::is_server_gone_error"); - DBUG_PRINT("info",("spider this=%p", this)); - server_gone = (hs_conn->get_error_code() < 0); - DBUG_PRINT("info",("spider server_gone=%s", server_gone ? "TRUE" : "FALSE")); - DBUG_RETURN(server_gone); -} - -bool spider_db_handlersocket::is_dup_entry_error( - int error_num -) { - bool dup_entry; - DBUG_ENTER("spider_db_handlersocket::is_dup_entry_error"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifndef HANDLERSOCKET_MYSQL_UTIL - const char *c_str = hs_conn->get_error().c_str(); -#else - const char *c_str = hs_conn->get_error().c_ptr_safe(); -#endif - dup_entry = - ( - c_str[0] == '1' && - c_str[1] == '2' && - c_str[2] == '1' && - c_str[3] == '\0' - ); - DBUG_PRINT("info",("spider dup_entry=%s", dup_entry ? "TRUE" : "FALSE")); - DBUG_RETURN(dup_entry); -} - -bool spider_db_handlersocket::is_xa_nota_error( - int error_num -) { - bool xa_nota; - DBUG_ENTER("spider_db_handlersocket::is_xa_nota_error"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - xa_nota = (stored_error == ER_XAER_NOTA); - DBUG_PRINT("info",("spider xa_nota=%s", xa_nota ? "TRUE" : "FALSE")); - DBUG_RETURN(xa_nota); -} - -spider_db_result *spider_db_handlersocket::store_result( - spider_db_result_buffer **spider_res_buf, - st_spider_db_request_key *request_key, - int *error_num -) { - int internal_error; - spider_db_handlersocket_result *result; - spider_db_handlersocket_result_buffer *hs_res_buf; - DBUG_ENTER("spider_db_handlersocket::store_result"); - DBUG_PRINT("info",("spider this=%p", this)); - if (*spider_res_buf) - { - hs_res_buf = (spider_db_handlersocket_result_buffer *) *spider_res_buf; - } else { - if (!(hs_res_buf = new spider_db_handlersocket_result_buffer())) - { - *error_num = HA_ERR_OUT_OF_MEM; - DBUG_RETURN(NULL); - } - *spider_res_buf = (spider_db_result_buffer *) hs_res_buf; - } - hs_res_buf->clear(); - if (!(result = new spider_db_handlersocket_result(this))) - { - *error_num = HA_ERR_OUT_OF_MEM; - DBUG_RETURN(NULL); - } - *error_num = 0; - result->hs_conn_p = &hs_conn; - size_t num_fields; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - if (request_key) - { - int tmp_res, tmp_err = (*hs_conn_p)->get_error_code(); - while ((tmp_res = check_request_key(request_key)) == 1) - { - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ((internal_error = (*hs_conn_p)->response_recv(num_fields))) - { - if (!tmp_err && internal_error > 0) - { - (*hs_conn_p)->clear_error(); - } else { - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (internal_error > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->clear_error(); - } - delete result; - DBUG_RETURN(NULL); - } - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->response_buf_remove(); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - if (tmp_res == -1) - { - DBUG_PRINT("info",("spider ER_SPIDER_REQUEST_KEY_NUM")); - *error_num = ER_SPIDER_REQUEST_KEY_NUM; - DBUG_RETURN(NULL); - } - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ( - (internal_error = (*hs_conn_p)->response_recv(num_fields)) || - (*error_num = (*hs_conn_p)->get_result(hs_res_buf->hs_result)) - ) { - if (*error_num) - { - *error_num = HA_ERR_OUT_OF_MEM; - } - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (internal_error > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - delete result; - DBUG_RETURN(NULL); - } -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf02 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - field_count = (uint) num_fields; - result->field_count = field_count; - DBUG_RETURN(result); -} - -spider_db_result *spider_db_handlersocket::use_result( - ha_spider *spider, - st_spider_db_request_key *request_key, - int *error_num -) { - int internal_error; - spider_db_handlersocket_result *result; - DBUG_ENTER("spider_db_handlersocket::use_result"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(result = new spider_db_handlersocket_result(this))) - { - *error_num = HA_ERR_OUT_OF_MEM; - DBUG_RETURN(NULL); - } - *error_num = 0; - result->hs_conn_p = &hs_conn; - size_t num_fields; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - if (request_key) - { - int tmp_res, tmp_err = (*hs_conn_p)->get_error_code(); - while ((tmp_res = check_request_key(request_key)) == 1) - { - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ((internal_error = (*hs_conn_p)->response_recv(num_fields))) - { - if (!tmp_err && internal_error > 0) - { - (*hs_conn_p)->clear_error(); - } else { - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (internal_error > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->clear_error(); - } - delete result; - DBUG_RETURN(NULL); - } - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->response_buf_remove(); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - if (tmp_res == -1) - { - DBUG_PRINT("info",("spider ER_SPIDER_REQUEST_KEY_NUM")); - *error_num = ER_SPIDER_REQUEST_KEY_NUM; - DBUG_RETURN(NULL); - } - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if ( - (internal_error = (*hs_conn_p)->response_recv(num_fields)) - ) { - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf01 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (internal_error > 0) - { - (*hs_conn_p)->response_buf_remove(); - if ((*hs_conn_p)->get_error_code()) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - } - delete result; - DBUG_RETURN(NULL); - } -#ifndef DBUG_OFF - if ((*hs_conn_p)->get_response_end_offset() > 0 && - (*hs_conn_p)->get_readbuf_begin()) - { - char tmp_buf[MAX_FIELD_WIDTH]; - String tmp_str(tmp_buf, MAX_FIELD_WIDTH, &my_charset_bin); - tmp_str.length(0); - tmp_str.append((*hs_conn_p)->get_readbuf_begin(), - (*hs_conn_p)->get_response_end_offset(), &my_charset_bin); - DBUG_PRINT("info",("spider hs readbuf02 size=%zu str=%s", - (*hs_conn_p)->get_response_end_offset(), tmp_str.c_ptr_safe())); - } -#endif - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - field_count = (uint) num_fields; - result->field_count = field_count; - DBUG_RETURN(result); -} - -int spider_db_handlersocket::next_result() -{ - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::next_result"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - if ((*hs_conn_p)->stable_point()) - DBUG_RETURN(-1); - DBUG_RETURN(0); -} - -uint spider_db_handlersocket::affected_rows() -{ - int error_num; - const SPIDER_HS_STRING_REF *hs_row; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::affected_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - if ( - field_count != 1 || - !(hs_row = (*hs_conn_p)->get_next_row()) || - !hs_row->begin() - ) { - DBUG_RETURN(0); - } - DBUG_RETURN((uint) my_strtoll10(hs_row->begin(), (char**) NULL, &error_num)); -} - -uint spider_db_handlersocket::matched_rows() -{ - DBUG_ENTER("spider_db_handlersocket::matched_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::inserted_info( - spider_db_handler *handler, - ha_copy_info *copy_info -) { - DBUG_ENTER("spider_db_handlersocket::inserted_info"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -ulonglong spider_db_handlersocket::last_insert_id() -{ - DBUG_ENTER("spider_db_handlersocket::last_insert_id"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::set_character_set( - const char *csname -) { - DBUG_ENTER("spider_db_handlersocket::set_character_set"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::select_db( - const char *dbname -) { - DBUG_ENTER("spider_db_handlersocket::select_db"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::consistent_snapshot( - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::consistent_snapshot"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::trx_start_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::trx_start_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::start_transaction( - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::start_transaction"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::commit( - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::commit"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::rollback( - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::rollback"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::xa_start_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::xa_start_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::xa_start( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_start"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::xa_end( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_end"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::xa_prepare( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_prepare"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::xa_commit( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_commit"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::xa_rollback( - XID *xid, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::xa_rollback"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_trx_isolation_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_trx_isolation_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_trx_isolation( - int trx_isolation, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_trx_isolation"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_autocommit_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_autocommit_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_autocommit( - bool autocommit, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_autocommit"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_sql_log_off_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_sql_log_off_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_sql_log_off( - bool sql_log_off, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_sql_log_off"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_wait_timeout_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_wait_timeout_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_wait_timeout( - int wait_timeout, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_wait_timeout"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_sql_mode_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_sql_mode_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_sql_mode( - sql_mode_t sql_mode, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_sql_mode"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::set_time_zone_in_bulk_sql() -{ - DBUG_ENTER("spider_db_handlersocket::set_time_zone_in_bulk_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::set_time_zone( - Time_zone *time_zone, - int *need_mon -) { - DBUG_ENTER("spider_db_handlersocket::set_time_zone"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket::show_master_status( - SPIDER_TRX *trx, - SPIDER_SHARE *share, - int all_link_idx, - int *need_mon, - TABLE *table, - spider_string *str, - int mode, - SPIDER_DB_RESULT **res1, - SPIDER_DB_RESULT **res2 -) { - DBUG_ENTER("spider_db_handlersocket::show_master_status"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key -) { - int error_num; - size_t req_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - if (!(req_num = (*hs_conn_p)->request_buf_append(sql, sql + sql_length))) - { - DBUG_PRINT("info",("spider hs %d %s", - (*hs_conn_p)->get_error_code(), - (*hs_conn_p)->get_error().ptr())); - (*hs_conn_p)->write_error_to_log(__func__, __FILE__, __LINE__); - DBUG_RETURN((*hs_conn_p)->get_error_code()); - } - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - while (req_num > 1) - { - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - --req_num; - } - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_open_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_open_index( - handler_id, - db_name, - table_name, - index_name, - sql - ); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_select"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_exec_generic( - handler_id, - SPIDER_HS_STRING_REF(sql->ptr(), sql->length()), - keys->ptr(), (size_t) keys->size(), - limit, skip, - SPIDER_HS_STRING_REF(), - NULL, 0); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_exec_generic( - handler_id, - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_INSERT_STR, SPIDER_SQL_HS_INSERT_LEN), - upds->ptr(), (size_t) upds->size(), - 0, 0, - SPIDER_HS_STRING_REF(), NULL, 0); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_exec_generic( - handler_id, - SPIDER_HS_STRING_REF(sql->ptr(), sql->length()), - keys->ptr(), (size_t) keys->size(), - limit, skip, - increment ? - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_INCREMENT_STR, - SPIDER_SQL_HS_INCREMENT_LEN) : - decrement ? - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_DECREMENT_STR, - SPIDER_SQL_HS_DECREMENT_LEN) : - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_UPDATE_STR, - SPIDER_SQL_HS_UPDATE_LEN), - upds->ptr(), (size_t) upds->size() - ); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - int error_num; - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = append_request_key(request_key))) - DBUG_RETURN(error_num); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_buf_exec_generic( - handler_id, - SPIDER_HS_STRING_REF(sql->ptr(), sql->length()), - keys->ptr(), (size_t) keys->size(), - limit, skip, - SPIDER_HS_STRING_REF(SPIDER_SQL_HS_DELETE_STR, SPIDER_SQL_HS_DELETE_LEN), - NULL, 0); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - DBUG_RETURN(0); -} - -void spider_db_handlersocket::reset_request_queue() -{ - SPIDER_HS_CONN *hs_conn_p = &hs_conn; - DBUG_ENTER("spider_db_handlersocket::reset_request_queue"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider hs hs_conn=%p", hs_conn_p)); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - (*hs_conn_p)->request_reset(); - DBUG_PRINT("info",("spider hs num_req_bufd=%zu", - (*hs_conn_p)->get_num_req_bufd())); - DBUG_PRINT("info",("spider hs num_req_sent=%zu", - (*hs_conn_p)->get_num_req_sent())); - DBUG_PRINT("info",("spider hs num_req_rcvd=%zu", - (*hs_conn_p)->get_num_req_rcvd())); - DBUG_PRINT("info",("spider hs response_end_offset=%zu", - (*hs_conn_p)->get_response_end_offset())); - reset_request_key_req(); - DBUG_VOID_RETURN; -} - -size_t spider_db_handlersocket::escape_string( - char *to, - const char *from, - size_t from_length -) { - DBUG_ENTER("spider_db_handlersocket::escape_string"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - memcpy(to, from, from_length); - DBUG_RETURN(from_length); -} - -bool spider_db_handlersocket::have_lock_table_list() -{ - DBUG_ENTER("spider_db_handlersocket::have_lock_table_list"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(FALSE); -} - -int spider_db_handlersocket::append_lock_tables( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket::lock_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_db_handlersocket::append_unlock_tables( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket::append_unlock_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -uint spider_db_handlersocket::get_lock_table_hash_count() -{ - DBUG_ENTER("spider_db_handlersocket::get_lock_table_hash_count"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_db_handlersocket::reset_lock_table_hash() -{ - DBUG_ENTER("spider_db_handlersocket::reset_lock_table_hash"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -uint spider_db_handlersocket::get_opened_handler_count() -{ - DBUG_ENTER("spider_db_handlersocket::get_opened_handler_count"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(handler_open_array.elements); -} - -void spider_db_handlersocket::reset_opened_handler() -{ - ha_spider *tmp_spider; - int tmp_link_idx; - SPIDER_LINK_FOR_HASH **tmp_link_for_hash; - DBUG_ENTER("spider_db_handlersocket::reset_opened_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - while ((tmp_link_for_hash = - (SPIDER_LINK_FOR_HASH **) pop_dynamic(&handler_open_array))) - { - tmp_spider = (*tmp_link_for_hash)->spider; - tmp_link_idx = (*tmp_link_for_hash)->link_idx; - tmp_spider->clear_handler_opened(tmp_link_idx, conn->conn_kind); - } - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket::set_dup_key_idx( - ha_spider *spider, - int link_idx -) { - DBUG_ENTER("spider_db_handlersocket::set_dup_key_idx"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::append_request_key( - st_spider_db_request_key *request_key -) { - st_spider_db_request_key *tmp_request_key; - DBUG_ENTER("spider_db_handlersocket::append_request_key"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider request_key=%p", request_key)); - if (request_key) - { - DBUG_PRINT("info",("spider request_key->spider_thread_id=%llu", - request_key->spider_thread_id)); - DBUG_PRINT("info",("spider request_key->query_id=%llu", - request_key->query_id)); - DBUG_PRINT("info",("spider request_key->handler=%p", - request_key->handler)); - DBUG_PRINT("info",("spider request_key->request_id=%llu", - request_key->request_id)); - if (request_key_reuse_first) - { - tmp_request_key = request_key_reuse_first; - request_key_reuse_first = request_key_reuse_first->next; - if (!request_key_reuse_first) - request_key_reuse_last = NULL; - } else { - if (!(tmp_request_key = (st_spider_db_request_key *) - spider_malloc(spider_current_trx, SPD_MID_DB_HANDLERSOCKET_APPEND_REQUEST_KEY_1, sizeof(st_spider_db_request_key), - MYF(MY_WME))) - ) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - *tmp_request_key = *request_key; - tmp_request_key->next = NULL; - if (request_key_req_last) - request_key_req_last->next = tmp_request_key; - else - request_key_req_first = tmp_request_key; - request_key_req_last = tmp_request_key; - } - DBUG_RETURN(0); -} - -void spider_db_handlersocket::reset_request_key_req() -{ - DBUG_ENTER("spider_db_handlersocket::reset_request_key_req"); - DBUG_PRINT("info",("spider this=%p", this)); - if (request_key_req_first) - { - if (request_key_reuse_last) - request_key_reuse_last->next = request_key_req_first; - else - request_key_reuse_first = request_key_req_first; - request_key_reuse_last = request_key_req_last; - request_key_req_first = NULL; - request_key_req_last = NULL; - } - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket::reset_request_key_snd() -{ - DBUG_ENTER("spider_db_handlersocket::reset_request_key_snd"); - DBUG_PRINT("info",("spider this=%p", this)); - if (request_key_snd_first) - { - if (request_key_reuse_last) - request_key_reuse_last->next = request_key_snd_first; - else - request_key_reuse_first = request_key_snd_first; - request_key_reuse_last = request_key_snd_last; - request_key_snd_first = NULL; - request_key_snd_last = NULL; - } - DBUG_VOID_RETURN; -} - -void spider_db_handlersocket::move_request_key_to_snd() -{ - DBUG_ENTER("spider_db_handlersocket::move_request_key_to_snd"); - DBUG_PRINT("info",("spider this=%p", this)); - if (request_key_req_first) - { - if (request_key_snd_last) - request_key_snd_last->next = request_key_req_first; - else - request_key_snd_first = request_key_req_first; - request_key_snd_last = request_key_req_last; - request_key_req_first = NULL; - request_key_req_last = NULL; - } - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket::check_request_key( - st_spider_db_request_key *request_key -) { - st_spider_db_request_key *tmp_request_key; - DBUG_ENTER("spider_db_handlersocket::check_request_key"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider request_key=%p", request_key)); - DBUG_PRINT("info",("spider request_key_snd_first=%p", - request_key_snd_first)); - if (!request_key_snd_first) - { - DBUG_PRINT("info",("spider -1")); - DBUG_RETURN(-1); - } - tmp_request_key = request_key_snd_first; - request_key_snd_first = request_key_snd_first->next; - if (!request_key_snd_first) - request_key_snd_last = NULL; - tmp_request_key->next = NULL; - if (request_key_reuse_last) - request_key_reuse_last->next = tmp_request_key; - else - request_key_reuse_first = tmp_request_key; - request_key_reuse_last = tmp_request_key; - - DBUG_PRINT("info",("spider tmp_request_key->spider_thread_id=%llu", - tmp_request_key->spider_thread_id)); - DBUG_PRINT("info",("spider request_key->spider_thread_id=%llu", - request_key->spider_thread_id)); - DBUG_PRINT("info",("spider tmp_request_key->query_id=%llu", - tmp_request_key->query_id)); - DBUG_PRINT("info",("spider request_key->query_id=%llu", - request_key->query_id)); - DBUG_PRINT("info",("spider tmp_request_key->handler=%p", - tmp_request_key->handler)); - DBUG_PRINT("info",("spider request_key->handler=%p", - request_key->handler)); - DBUG_PRINT("info",("spider tmp_request_key->request_id=%llu", - tmp_request_key->request_id)); - DBUG_PRINT("info",("spider request_key->request_id=%llu", - request_key->request_id)); - if ( - tmp_request_key->spider_thread_id != request_key->spider_thread_id || - tmp_request_key->query_id != request_key->query_id || - tmp_request_key->handler != request_key->handler || - tmp_request_key->request_id != request_key->request_id - ) { - DBUG_PRINT("info",("spider 1")); - DBUG_RETURN(1); - } - DBUG_PRINT("info",("spider 0")); - DBUG_RETURN(0); -} - -bool spider_db_handlersocket::cmp_request_key_to_snd( - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_handlersocket::cmp_request_key_to_snd"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider request_key=%p", request_key)); - if ( - !request_key - ) { - DBUG_PRINT("info",("spider TRUE")); - DBUG_RETURN(TRUE); - } - DBUG_PRINT("info",("spider request_key_snd_first=%p", - request_key_snd_first)); - if ( - !request_key_snd_first - ) { - DBUG_PRINT("info",("spider FALSE")); - DBUG_RETURN(FALSE); - } - DBUG_PRINT("info",("spider request_key_snd_first->spider_thread_id=%llu", - request_key_snd_first->spider_thread_id)); - DBUG_PRINT("info",("spider request_key->spider_thread_id=%llu", - request_key->spider_thread_id)); - DBUG_PRINT("info",("spider request_key_snd_first->query_id=%llu", - request_key_snd_first->query_id)); - DBUG_PRINT("info",("spider request_key->query_id=%llu", - request_key->query_id)); - DBUG_PRINT("info",("spider request_key_snd_first->handler=%p", - request_key_snd_first->handler)); - DBUG_PRINT("info",("spider request_key->handler=%p", - request_key->handler)); - DBUG_PRINT("info",("spider request_key_snd_first->request_id=%llu", - request_key_snd_first->request_id)); - DBUG_PRINT("info",("spider request_key->request_id=%llu", - request_key->request_id)); - if ( - request_key_snd_first->spider_thread_id != request_key->spider_thread_id || - request_key_snd_first->query_id != request_key->query_id || - request_key_snd_first->handler != request_key->handler || - request_key_snd_first->request_id != request_key->request_id - ) { - DBUG_PRINT("info",("spider FALSE")); - DBUG_RETURN(FALSE); - } - DBUG_PRINT("info",("spider TRUE")); - DBUG_RETURN(TRUE); -} - -spider_db_handlersocket_util::spider_db_handlersocket_util() : spider_db_util() -{ - DBUG_ENTER("spider_db_handlersocket_util::spider_db_handlersocket_util"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -spider_db_handlersocket_util::~spider_db_handlersocket_util() -{ - DBUG_ENTER("spider_db_handlersocket_util::~spider_db_handlersocket_util"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_VOID_RETURN; -} - -int spider_db_handlersocket_util::append_name( - spider_string *str, - const char *name, - uint name_length -) { - DBUG_ENTER("spider_db_handlersocket_util::append_name"); - str->q_append(name, name_length); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_name_with_charset( - spider_string *str, - const char *name, - uint name_length, - CHARSET_INFO *name_charset -) { - DBUG_ENTER("spider_db_handlersocket_util::append_name_with_charset"); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - str->append(name, name_length, name_charset); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_escaped_name( - spider_string *str, - const char *name, - uint name_length -) { - int error_num; - DBUG_ENTER("spider_db_handlersocket_util::append_name"); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - if ((error_num = spider_db_append_name_with_quote_str_internal( - str, name, name_length, dbton_id))) - { - DBUG_RETURN(error_num); - } - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_escaped_name_with_charset( - spider_string *str, - const char *name, - uint name_length, - CHARSET_INFO *name_charset -) { - int error_num; - DBUG_ENTER("spider_db_handlersocket_util::append_name_with_charset"); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2 + name_length * 2)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - if ((error_num = spider_db_append_name_with_quote_str_internal( - str, name, name_length, name_charset, dbton_id))) - { - DBUG_RETURN(error_num); - } - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - DBUG_RETURN(0); -} - -bool spider_db_handlersocket_util::is_name_quote( - const char head_code -) { - DBUG_ENTER("spider_db_handlersocket_util::is_name_quote"); - DBUG_RETURN(head_code == *name_quote_str); -} - -int spider_db_handlersocket_util::append_escaped_name_quote( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_escaped_name_quote"); - if (str->reserve(SPIDER_SQL_NAME_QUOTE_LEN * 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - str->q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_column_value( - ha_spider *spider, - spider_string *str, - Field *field, - const uchar *new_ptr, - CHARSET_INFO *access_charset -) { - char buf[MAX_FIELD_WIDTH]; - spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin); - String *ptr; - uint length; - DBUG_ENTER("spider_db_handlersocket_util::append_column_value"); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_UTIL_APPEND_COLUMN_VALUE_1); - - if (new_ptr) - { - if ( - field->type() == MYSQL_TYPE_BLOB || - field->real_type() == MYSQL_TYPE_VARCHAR - ) { - length = uint2korr(new_ptr); - tmp_str.set_quick((char *) new_ptr + HA_KEY_BLOB_LENGTH, length, - &my_charset_bin); - ptr = tmp_str.get_str(); - } else if (field->type() == MYSQL_TYPE_GEOMETRY) - { -/* - uint mlength = SIZEOF_STORED_DOUBLE, lcnt; - uchar *dest = (uchar *) buf; - const uchar *source; - for (lcnt = 0; lcnt < 4; lcnt++) - { - mlength = SIZEOF_STORED_DOUBLE; - source = new_ptr + mlength + SIZEOF_STORED_DOUBLE * lcnt; - while (mlength--) - *dest++ = *--source; - } - tmp_str.length(SIZEOF_STORED_DOUBLE * lcnt); -*/ - double xmin, xmax, ymin, ymax; -/* - float8store(buf,xmin); - float8store(buf+8,xmax); - float8store(buf+16,ymin); - float8store(buf+24,ymax); - memcpy(&xmin,new_ptr,sizeof(xmin)); - memcpy(&xmax,new_ptr + 8,sizeof(xmax)); - memcpy(&ymin,new_ptr + 16,sizeof(ymin)); - memcpy(&ymax,new_ptr + 24,sizeof(ymax)); - float8get(xmin, buf); - float8get(xmax, buf + 8); - float8get(ymin, buf + 16); - float8get(ymax, buf + 24); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); - DBUG_PRINT("info", ("spider geo is %.14g %.14g %.14g %.14g", - xmin, xmax, ymin, ymax)); -*/ - float8get(xmin, new_ptr); - float8get(xmax, new_ptr + 8); - float8get(ymin, new_ptr + 16); - float8get(ymax, new_ptr + 24); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); -/* - float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 4); - float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 5); - float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 6); - float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 7); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); - float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 8); - float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 9); - float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 10); - float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 11); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); - float8get(xmin, new_ptr + SIZEOF_STORED_DOUBLE * 12); - float8get(xmax, new_ptr + SIZEOF_STORED_DOUBLE * 13); - float8get(ymin, new_ptr + SIZEOF_STORED_DOUBLE * 14); - float8get(ymax, new_ptr + SIZEOF_STORED_DOUBLE * 15); - DBUG_PRINT("info", ("spider geo is %f %f %f %f", - xmin, xmax, ymin, ymax)); -*/ -/* - tmp_str.set_quick((char *) new_ptr, SIZEOF_STORED_DOUBLE * 4, - &my_charset_bin); -*/ - tmp_str.length(0); - tmp_str.q_append((char *) SPIDER_SQL_LINESTRING_HEAD_STR, - SPIDER_SQL_LINESTRING_HEAD_LEN); - tmp_str.q_append((char *) new_ptr, SIZEOF_STORED_DOUBLE); - tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 2, - SIZEOF_STORED_DOUBLE); - tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE, - SIZEOF_STORED_DOUBLE); - tmp_str.q_append((char *) new_ptr + SIZEOF_STORED_DOUBLE * 3, - SIZEOF_STORED_DOUBLE); - ptr = tmp_str.get_str(); - } else { - ptr = field->val_str(tmp_str.get_str(), new_ptr); - tmp_str.mem_calc(); - } - } else { - ptr = field->val_str(tmp_str.get_str()); - tmp_str.mem_calc(); - } - DBUG_PRINT("info", ("spider field->type() is %d", field->type())); - DBUG_PRINT("info", ("spider ptr->length() is %d", ptr->length())); -/* - if ( - field->type() == MYSQL_TYPE_BIT || - (field->type() >= MYSQL_TYPE_TINY_BLOB && - field->type() <= MYSQL_TYPE_BLOB) - ) { - uchar *hex_ptr = (uchar *) ptr->ptr(), *end_ptr; - char *str_ptr; - DBUG_PRINT("info", ("spider HEX")); - if (str->reserve(SPIDER_SQL_HEX_LEN + ptr->length() * 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_HEX_STR, SPIDER_SQL_HEX_LEN); - str_ptr = (char *) str->ptr() + str->length(); - for (end_ptr = hex_ptr + ptr->length(); hex_ptr < end_ptr; hex_ptr++) - { - *str_ptr++ = spider_dig_upper[(*hex_ptr) >> 4]; - *str_ptr++ = spider_dig_upper[(*hex_ptr) & 0x0F]; - } - str->length(str->length() + ptr->length() * 2); - } else -*/ - spider_handlersocket_handler *hs_handler = (spider_handlersocket_handler *) - spider->dbton_handler[spider_dbton_handlersocket.dbton_id]; - spider_string *hs_str; - if (!(hs_str = hs_handler->hs_strs.add( - &hs_handler->hs_strs_pos, ptr->ptr(), ptr->length()))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - SPIDER_HS_STRING_REF ref = - SPIDER_HS_STRING_REF(hs_str->ptr(), hs_str->length()); - if (hs_handler->hs_adding_keys) - { - DBUG_PRINT("info", ("spider add to key:%s", hs_str->c_ptr_safe())); - hs_handler->hs_keys.push_back(ref); - } else { - DBUG_PRINT("info", ("spider add to upd:%s", hs_str->c_ptr_safe())); - hs_handler->hs_upds.push_back(ref); - } - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_trx_isolation( - spider_string *str, - int trx_isolation -) { - DBUG_ENTER("spider_db_handlersocket_util::append_trx_isolation"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_autocommit( - spider_string *str, - bool autocommit -) { - DBUG_ENTER("spider_db_handlersocket_util::append_autocommit"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_sql_log_off( - spider_string *str, - bool sql_log_off -) { - DBUG_ENTER("spider_db_handlersocket_util::append_sql_log_off"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_wait_timeout( - spider_string *str, - int wait_timeout -) { - DBUG_ENTER("spider_db_handlersocket_util::append_wait_timeout"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_sql_mode( - spider_string *str, - sql_mode_t sql_mode -) { - DBUG_ENTER("spider_db_handlersocket_util::append_sql_mode"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_time_zone( - spider_string *str, - Time_zone *time_zone -) { - DBUG_ENTER("spider_db_handlersocket_util::append_time_zone"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_start_transaction( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_start_transaction"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_xa_start( - spider_string *str, - XID *xid -) { - DBUG_ENTER("spider_db_handlersocket_util::append_xa_start"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_lock_table_head( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_lock_table_head"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_lock_table_body( - spider_string *str, - const char *db_name, - uint db_name_length, - CHARSET_INFO *db_name_charset, - const char *table_name, - uint table_name_length, - CHARSET_INFO *table_name_charset, - int lock_type -) { - DBUG_ENTER("spider_db_handlersocket_util::append_lock_table_body"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_lock_table_tail( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_lock_table_tail"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_unlock_table( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_unlock_table"); - DBUG_PRINT("info",("spider this=%p", this)); - /* nothing to do */ - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::open_item_func( - Item_func *item_func, - ha_spider *spider, - spider_string *str, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields -) { - uint dbton_id = spider_dbton_handlersocket.dbton_id; - int error_num; - Item *item, **item_list = item_func->arguments(); - uint roop_count, item_count = item_func->argument_count(), start_item = 0; - const char *func_name = SPIDER_SQL_NULL_CHAR_STR, - *separator_str = SPIDER_SQL_NULL_CHAR_STR, - *last_str = SPIDER_SQL_NULL_CHAR_STR; - int func_name_length = SPIDER_SQL_NULL_CHAR_LEN, - separator_str_length = SPIDER_SQL_NULL_CHAR_LEN, - last_str_length = SPIDER_SQL_NULL_CHAR_LEN; - int use_pushdown_udf; - bool merge_func = FALSE; - DBUG_ENTER("spider_db_handlersocket_util::open_item_func"); - if (str) - { - if (str->reserve(SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - DBUG_PRINT("info",("spider functype = %d", item_func->functype())); - switch (item_func->functype()) - { - case Item_func::ISNULL_FUNC: - last_str = SPIDER_SQL_IS_NULL_STR; - last_str_length = SPIDER_SQL_IS_NULL_LEN; - break; - case Item_func::ISNOTNULL_FUNC: - last_str = SPIDER_SQL_IS_NOT_NULL_STR; - last_str_length = SPIDER_SQL_IS_NOT_NULL_LEN; - break; - case Item_func::UNKNOWN_FUNC: - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - if (func_name_length == 1 && - ( - !strncasecmp("+", func_name, func_name_length) || - !strncasecmp("-", func_name, func_name_length) || - !strncasecmp("*", func_name, func_name_length) || - !strncasecmp("/", func_name, func_name_length) || - !strncasecmp("%", func_name, func_name_length) || - !strncasecmp("&", func_name, func_name_length) || - !strncasecmp("|", func_name, func_name_length) || - !strncasecmp("^", func_name, func_name_length) - ) - ) { - /* no action */ - break; - } else if (func_name_length == 2 && - ( - !strncasecmp("<<", func_name, func_name_length) || - !strncasecmp(">>", func_name, func_name_length) - ) - ) { - /* no action */ - break; - } else if (func_name_length == 3 && - !strncasecmp("div", func_name, func_name_length) - ) { - /* no action */ - break; - } else if (func_name_length == 4) - { - if ( - !strncasecmp("rand", func_name, func_name_length) && -#ifdef SPIDER_Item_args_arg_count_IS_PROTECTED - !item_func->argument_count() -#else - !item_func->arg_count -#endif - ) { - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - } else if ( - !strncasecmp("case", func_name, func_name_length) - ) { -#ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC - Item_func_case *item_func_case = (Item_func_case *) item_func; - if (str) - { - if (str->reserve(SPIDER_SQL_CASE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN); - } - if (item_func_case->first_expr_num != -1) - { - if ((error_num = spider_db_print_item_type( - item_list[item_func_case->first_expr_num], NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - for (roop_count = 0; roop_count < item_func_case->ncases; - roop_count += 2) - { - if (str) - { - if (str->reserve(SPIDER_SQL_WHEN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); - } - if ((error_num = spider_db_print_item_type( - item_list[roop_count], NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_THEN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); - } - if ((error_num = spider_db_print_item_type( - item_list[roop_count + 1], NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - if (item_func_case->else_expr_num != -1) - { - if (str) - { - if (str->reserve(SPIDER_SQL_ELSE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); - } - if ((error_num = spider_db_print_item_type( - item_list[item_func_case->else_expr_num], NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - if (str) - { - if (str->reserve(SPIDER_SQL_END_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_END_STR, SPIDER_SQL_END_LEN); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, - SPIDER_SQL_CLOSE_PAREN_LEN); - } - DBUG_RETURN(0); -#else - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); -#endif - } - } else if (func_name_length == 6 && - !strncasecmp("istrue", func_name, func_name_length) - ) { - last_str = SPIDER_SQL_IS_TRUE_STR; - last_str_length = SPIDER_SQL_IS_TRUE_LEN; - break; - } else if (func_name_length == 7) - { - if (!strncasecmp("isfalse", func_name, func_name_length)) - { - last_str = SPIDER_SQL_IS_FALSE_STR; - last_str_length = SPIDER_SQL_IS_FALSE_LEN; - break; - } else if ( - !strncasecmp("sysdate", func_name, func_name_length) || - !strncasecmp("curdate", func_name, func_name_length) || - !strncasecmp("curtime", func_name, func_name_length) - ) { - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - } else if ( - !strncasecmp("convert", func_name, func_name_length) - ) { - if (str) - { - if (str->reserve(func_name_length * 2 + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, - SPIDER_SQL_OPEN_PAREN_LEN); - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - } - break; - } - } else if (func_name_length == 8 && - ( - !strncasecmp("utc_date", func_name, func_name_length) || - !strncasecmp("utc_time", func_name, func_name_length) - ) - ) { - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - } else if (func_name_length == 9 && - !strncasecmp("isnottrue", func_name, func_name_length) - ) { - last_str = SPIDER_SQL_IS_NOT_TRUE_STR; - last_str_length = SPIDER_SQL_IS_NOT_TRUE_LEN; - break; - } else if (func_name_length == 10) - { - if (!strncasecmp("isnotfalse", func_name, func_name_length)) - { - last_str = SPIDER_SQL_IS_NOT_FALSE_STR; - last_str_length = SPIDER_SQL_IS_NOT_FALSE_LEN; - break; - } else if (!strncasecmp("column_get", func_name, func_name_length)) - { - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - break; - } - } else if (func_name_length == 12) - { - if (!strncasecmp("cast_as_date", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_DATE_STR; - last_str_length = SPIDER_SQL_AS_DATE_LEN; - break; - } else if (!strncasecmp("cast_as_time", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_TIME_STR; - last_str_length = SPIDER_SQL_AS_TIME_LEN; - break; - } - } else if (func_name_length == 13) - { - if (!strncasecmp("utc_timestamp", func_name, func_name_length)) - { - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - } else if (!strncasecmp("timestampdiff", func_name, func_name_length)) - { - Item_func_timestamp_diff *item_func_timestamp_diff = - (Item_func_timestamp_diff *) item_func; - if (str) - { - const char *interval_str; - uint interval_len; - switch (item_func_timestamp_diff->get_int_type()) - { - case INTERVAL_YEAR: - interval_str = SPIDER_SQL_YEAR_STR; - interval_len = SPIDER_SQL_YEAR_LEN; - break; - case INTERVAL_QUARTER: - interval_str = SPIDER_SQL_QUARTER_STR; - interval_len = SPIDER_SQL_QUARTER_LEN; - break; - case INTERVAL_MONTH: - interval_str = SPIDER_SQL_MONTH_STR; - interval_len = SPIDER_SQL_MONTH_LEN; - break; - case INTERVAL_WEEK: - interval_str = SPIDER_SQL_WEEK_STR; - interval_len = SPIDER_SQL_WEEK_LEN; - break; - case INTERVAL_DAY: - interval_str = SPIDER_SQL_DAY_STR; - interval_len = SPIDER_SQL_DAY_LEN; - break; - case INTERVAL_HOUR: - interval_str = SPIDER_SQL_HOUR_STR; - interval_len = SPIDER_SQL_HOUR_LEN; - break; - case INTERVAL_MINUTE: - interval_str = SPIDER_SQL_MINUTE_STR; - interval_len = SPIDER_SQL_MINUTE_LEN; - break; - case INTERVAL_SECOND: - interval_str = SPIDER_SQL_SECOND_STR; - interval_len = SPIDER_SQL_SECOND_LEN; - break; - case INTERVAL_MICROSECOND: - interval_str = SPIDER_SQL_MICROSECOND_STR; - interval_len = SPIDER_SQL_MICROSECOND_LEN; - break; - default: - interval_str = ""; - interval_len = 0; - break; - } - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN + - interval_len + SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - str->q_append(interval_str, interval_len); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, - SPIDER_SQL_CLOSE_PAREN_LEN); - } - DBUG_RETURN(0); - } - } else if (func_name_length == 14) - { - if (!strncasecmp("cast_as_binary", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; - spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_UTIL_OPEN_ITEM_FUNC_1); - tmp_str.length(0); - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); - tmp_str.mem_calc(); - if (tmp_str.reserve(1)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - tmp_ptr = tmp_str.c_ptr_quick(); - DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); - while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_BINARY_STR))) - tmp_ptr = tmp_ptr2 + 1; - last_str = tmp_ptr - 1; - last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; - } - break; - } else if (!strncasecmp("cast_as_signed", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_SIGNED_STR; - last_str_length = SPIDER_SQL_AS_SIGNED_LEN; - break; - } - } else if (func_name_length == 16) - { - if (!strncasecmp("cast_as_unsigned", func_name, func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_UNSIGNED_STR; - last_str_length = SPIDER_SQL_AS_UNSIGNED_LEN; - break; - } else if (!strncasecmp("decimal_typecast", func_name, - func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; - spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_UTIL_OPEN_ITEM_FUNC_2); - tmp_str.length(0); - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); - tmp_str.mem_calc(); - if (tmp_str.reserve(1)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - tmp_ptr = tmp_str.c_ptr_quick(); - DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); - while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_DECIMAL_STR))) - tmp_ptr = tmp_ptr2 + 1; - last_str = tmp_ptr - 1; - last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; - } - break; - } else if (!strncasecmp("cast_as_datetime", func_name, - func_name_length)) - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - } - last_str = SPIDER_SQL_AS_DATETIME_STR; - last_str_length = SPIDER_SQL_AS_DATETIME_LEN; - break; - } - } else if (func_name_length == 17) - { - if (!strncasecmp("date_add_interval", func_name, func_name_length)) - { - Item_date_add_interval *item_date_add_interval = - (Item_date_add_interval *) item_func; - func_name = spider_db_timefunc_interval_str[ - item_date_add_interval->int_type]; - func_name_length = strlen(func_name); - if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (item_date_add_interval->date_sub_interval) - { - if (str->reserve(SPIDER_SQL_NEGINTERVAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_NEGINTERVAL_STR, - SPIDER_SQL_NEGINTERVAL_LEN); - } else { - if (str->reserve(SPIDER_SQL_INTERVAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_INTERVAL_STR, SPIDER_SQL_INTERVAL_LEN); - } - } - if ((error_num = spider_db_print_item_type(item_list[1], NULL, spider, - str, alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(func_name_length + SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, - SPIDER_SQL_CLOSE_PAREN_LEN); - } - DBUG_RETURN(0); - } - } - if (str) - { - if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::NOW_FUNC: - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - case Item_func::CHAR_TYPECAST_FUNC: - DBUG_PRINT("info",("spider CHAR_TYPECAST_FUNC")); - { - item = item_list[0]; - if (item->type() == Item::FUNC_ITEM) - { - DBUG_PRINT("info",("spider child is FUNC_ITEM")); - Item_func *ifunc = (Item_func *) item; - if (ifunc->functype() == Item_func::UNKNOWN_FUNC) - { - const char *child_func_name; - int child_func_name_length; - DBUG_PRINT("info",("spider child is UNKNOWN_FUNC")); - child_func_name = (char*) ifunc->func_name(); - child_func_name_length = strlen(child_func_name); - DBUG_PRINT("info",("spider child func_name is %s", child_func_name)); - if ( - child_func_name_length == 10 && - !strncasecmp("column_get", child_func_name, child_func_name_length) - ) { - DBUG_PRINT("info",("spider this is merge func")); - merge_func = TRUE; - } - } - } - - if (str) - { - char tmp_buf[MAX_FIELD_WIDTH], *tmp_ptr, *tmp_ptr2; - spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset()); - tmp_str.init_calc_mem(SPD_MID_DB_HANDLERSOCKET_UTIL_OPEN_ITEM_FUNC_3); - tmp_str.length(0); - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (!merge_func) - { - if (str->reserve(SPIDER_SQL_CAST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); - } - item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); - tmp_str.mem_calc(); - if (tmp_str.reserve(1)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - tmp_ptr = tmp_str.c_ptr_quick(); - DBUG_PRINT("info",("spider tmp_ptr = %s", tmp_ptr)); - while ((tmp_ptr2 = strstr(tmp_ptr, SPIDER_SQL_AS_CHAR_STR))) - tmp_ptr = tmp_ptr2 + 1; - last_str = tmp_ptr - 1; - last_str_length = strlen(last_str) - SPIDER_SQL_CLOSE_PAREN_LEN; - } - } - break; - case Item_func::NOT_FUNC: - DBUG_PRINT("info",("spider NOT_FUNC")); - if (item_list[0]->type() == Item::COND_ITEM) - { - DBUG_PRINT("info",("spider item_list[0] is COND_ITEM")); - Item_cond *item_cond = (Item_cond *) item_list[0]; - if (item_cond->functype() == Item_func::COND_AND_FUNC) - { - DBUG_PRINT("info",("spider item_cond is COND_AND_FUNC")); - List_iterator_fast lif(*(item_cond->argument_list())); - bool has_expr_cache_item = FALSE; - bool has_isnotnull_func = FALSE; - bool has_other_item = FALSE; - while((item = lif++)) - { -#ifdef SPIDER_HAS_EXPR_CACHE_ITEM - if ( - item->type() == Item::EXPR_CACHE_ITEM - ) { - DBUG_PRINT("info",("spider EXPR_CACHE_ITEM")); - has_expr_cache_item = TRUE; - } else -#endif - if ( - item->type() == Item::FUNC_ITEM && - ((Item_func *) item)->functype() == Item_func::ISNOTNULL_FUNC - ) { - DBUG_PRINT("info",("spider ISNOTNULL_FUNC")); - has_isnotnull_func = TRUE; - } else { - DBUG_PRINT("info",("spider has other item")); - DBUG_PRINT("info",("spider COND type=%d", item->type())); - has_other_item = TRUE; - } - } - if (has_expr_cache_item && has_isnotnull_func && !has_other_item) - { - DBUG_PRINT("info",("spider NOT EXISTS skip")); - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - } - } - } - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - } - break; - case Item_func::NEG_FUNC: - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - } - break; - case Item_func::IN_FUNC: - if (((Item_func_opt_neg *) item_func)->negated) - { - func_name = SPIDER_SQL_NOT_IN_STR; - func_name_length = SPIDER_SQL_NOT_IN_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - } else { - func_name = SPIDER_SQL_IN_STR; - func_name_length = SPIDER_SQL_IN_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - } - break; - case Item_func::BETWEEN: - if (((Item_func_opt_neg *) item_func)->negated) - { - func_name = SPIDER_SQL_NOT_BETWEEN_STR; - func_name_length = SPIDER_SQL_NOT_BETWEEN_LEN; - separator_str = SPIDER_SQL_AND_STR; - separator_str_length = SPIDER_SQL_AND_LEN; - } else { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - separator_str = SPIDER_SQL_AND_STR; - separator_str_length = SPIDER_SQL_AND_LEN; - } - break; - case Item_func::UDF_FUNC: - use_pushdown_udf = spider_param_use_pushdown_udf(spider->trx->thd, - spider->share->use_pushdown_udf); - if (!use_pushdown_udf) - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::XOR_FUNC: - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - DBUG_RETURN( - spider_db_open_item_cond((Item_cond *) item_func, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - case Item_func::TRIG_COND_FUNC: - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - case Item_func::GUSERVAR_FUNC: - if (str) - str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); - if (item_func->result_type() == STRING_RESULT) - DBUG_RETURN(spider_db_open_item_string(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - else - DBUG_RETURN(spider_db_open_item_int(item_func, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields)); - case Item_func::FT_FUNC: - if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - start_item = 1; - if (str) - { - if (str->reserve(SPIDER_SQL_MATCH_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_MATCH_STR, SPIDER_SQL_MATCH_LEN); - } - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::SP_EQUALS_FUNC: - if (str) - { - func_name = SPIDER_SQL_MBR_EQUAL_STR; - func_name_length = SPIDER_SQL_MBR_EQUAL_LEN; - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - if (str->reserve(func_name_length)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::SP_DISJOINT_FUNC: - case Item_func::SP_INTERSECTS_FUNC: - case Item_func::SP_TOUCHES_FUNC: - case Item_func::SP_CROSSES_FUNC: - case Item_func::SP_WITHIN_FUNC: - case Item_func::SP_CONTAINS_FUNC: - case Item_func::SP_OVERLAPS_FUNC: - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - if (str->reserve( -#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR - SPIDER_SQL_MBR_LEN + -#endif - func_name_length + SPIDER_SQL_OPEN_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); -#ifndef SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR - str->q_append(SPIDER_SQL_MBR_STR, SPIDER_SQL_MBR_LEN); -#endif - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); - } - func_name = SPIDER_SQL_COMMA_STR; - func_name_length = SPIDER_SQL_COMMA_LEN; - separator_str = SPIDER_SQL_COMMA_STR; - separator_str_length = SPIDER_SQL_COMMA_LEN; - last_str = SPIDER_SQL_CLOSE_PAREN_STR; - last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; - break; - case Item_func::EQ_FUNC: - case Item_func::EQUAL_FUNC: - case Item_func::NE_FUNC: - case Item_func::LT_FUNC: - case Item_func::LE_FUNC: - case Item_func::GE_FUNC: - case Item_func::GT_FUNC: - case Item_func::LIKE_FUNC: - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - } - break; - default: - THD *thd = spider->trx->thd; - SPIDER_SHARE *share = spider->share; - if (spider_param_skip_default_condition(thd, - share->skip_default_condition)) - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - if (str) - { - func_name = (char*) item_func->func_name(); - func_name_length = strlen(func_name); - } - break; - } - DBUG_PRINT("info",("spider func_name = %s", func_name)); - DBUG_PRINT("info",("spider func_name_length = %d", func_name_length)); - DBUG_PRINT("info",("spider separator_str = %s", separator_str)); - DBUG_PRINT("info",("spider separator_str_length = %d", separator_str_length)); - DBUG_PRINT("info",("spider last_str = %s", last_str)); - DBUG_PRINT("info",("spider last_str_length = %d", last_str_length)); - if (item_count) - { - item_count--; - for (roop_count = start_item; roop_count < item_count; roop_count++) - { - item = item_list[roop_count]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (roop_count == 1) - { - func_name = separator_str; - func_name_length = separator_str_length; - } - if (str) - { - if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN * 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - str->q_append(func_name, func_name_length); - str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN); - } - } - item = item_list[roop_count]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - if (item_func->functype() == Item_func::FT_FUNC) - { - Item_func_match *item_func_match = (Item_func_match *)item_func; - if (str) - { - if (str->reserve(SPIDER_SQL_AGAINST_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_AGAINST_STR, SPIDER_SQL_AGAINST_LEN); - } - item = item_list[0]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve( - ((item_func_match->flags & FT_BOOL) ? - SPIDER_SQL_IN_BOOLEAN_MODE_LEN : 0) + - ((item_func_match->flags & FT_EXPAND) ? - SPIDER_SQL_WITH_QUERY_EXPANSION_LEN : 0) - )) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (item_func_match->flags & FT_BOOL) - str->q_append(SPIDER_SQL_IN_BOOLEAN_MODE_STR, - SPIDER_SQL_IN_BOOLEAN_MODE_LEN); - if (item_func_match->flags & FT_EXPAND) - str->q_append(SPIDER_SQL_WITH_QUERY_EXPANSION_STR, - SPIDER_SQL_WITH_QUERY_EXPANSION_LEN); - } - } else if (item_func->functype() == Item_func::UNKNOWN_FUNC) - { - if ( - func_name_length == 7 && - !strncasecmp("convert", func_name, func_name_length) - ) { - if (str) - { - Item_func_conv_charset *item_func_conv_charset = - (Item_func_conv_charset *)item_func; - CHARSET_INFO *conv_charset = - item_func_conv_charset->SPIDER_Item_func_conv_charset_conv_charset; - uint cset_length = strlen(conv_charset->csname); - if (str->reserve(SPIDER_SQL_USING_LEN + cset_length)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_USING_STR, SPIDER_SQL_USING_LEN); - str->q_append(conv_charset->csname, cset_length); - } - } - } - if (str) - { - if (merge_func) - str->length(str->length() - SPIDER_SQL_CLOSE_PAREN_LEN); - if (str->reserve(last_str_length + SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(last_str, last_str_length); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN); - } - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_AGGREGATE -int spider_db_handlersocket_util::open_item_sum_func( - Item_sum *item_sum, - ha_spider *spider, - spider_string *str, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields -) { - uint dbton_id = spider_dbton_handlersocket.dbton_id; - uint roop_count, item_count = item_sum->get_arg_count(); - int error_num; - DBUG_ENTER("spider_db_handlersocket_util::open_item_sum_func"); - DBUG_PRINT("info",("spider Sumfunctype = %d", item_sum->sum_func())); - switch (item_sum->sum_func()) - { - case Item_sum::COUNT_FUNC: - case Item_sum::SUM_FUNC: - case Item_sum::MIN_FUNC: - case Item_sum::MAX_FUNC: - { - const char *func_name = item_sum->func_name(); - uint func_name_length = strlen(func_name); - Item *item, **args = item_sum->get_args(); - if (str) - { - if (str->reserve(func_name_length)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(func_name, func_name_length); - } - if (item_count) - { - item_count--; - for (roop_count = 0; roop_count < item_count; roop_count++) - { - item = args[roop_count]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - if (str) - { - if (str->reserve(SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - } - item = args[roop_count]; - if ((error_num = spider_db_print_item_type(item, NULL, spider, str, - alias, alias_length, dbton_id, use_fields, fields))) - DBUG_RETURN(error_num); - } - if (str) - { - if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, - SPIDER_SQL_CLOSE_PAREN_LEN); - } - } - break; - case Item_sum::COUNT_DISTINCT_FUNC: - case Item_sum::SUM_DISTINCT_FUNC: - case Item_sum::AVG_FUNC: - case Item_sum::AVG_DISTINCT_FUNC: - case Item_sum::STD_FUNC: - case Item_sum::VARIANCE_FUNC: - case Item_sum::SUM_BIT_FUNC: - case Item_sum::UDF_SUM_FUNC: - case Item_sum::GROUP_CONCAT_FUNC: - default: - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - } - DBUG_RETURN(0); -} -#endif - -int spider_db_handlersocket_util::append_escaped_util( - spider_string *to, - String *from -) { - DBUG_ENTER("spider_db_handlersocket_util::append_escaped_util"); - DBUG_PRINT("info",("spider this=%p", this)); - to->append_escape_string(from->ptr(), from->length()); - DBUG_RETURN(0); -} - -#ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_db_handlersocket_util::append_from_and_tables( - ha_spider *spider, - spider_fields *fields, - spider_string *str, - TABLE_LIST *table_list, - uint table_count -) { - DBUG_ENTER("spider_db_handlersocket_util::append_from_and_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::reappend_tables( - spider_fields *fields, - SPIDER_LINK_IDX_CHAIN *link_idx_chain, - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::reappend_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_where( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_where"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_handlersocket_util::append_having( - spider_string *str -) { - DBUG_ENTER("spider_db_handlersocket_util::append_having"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -spider_handlersocket_share::spider_handlersocket_share( - st_spider_share *share -) : spider_db_share( - share, - spider_dbton_handlersocket.dbton_id -), - table_names_str(NULL), - db_names_str(NULL), - db_table_str(NULL), -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - db_table_str_hash_value(NULL), -#endif - table_nm_max_length(0), - db_nm_max_length(0), - column_name_str(NULL), - same_db_table_name(TRUE), - first_all_link_idx(-1) -{ - DBUG_ENTER("spider_handlersocket_share::spider_handlersocket_share"); - DBUG_PRINT("info",("spider this=%p", this)); - spider_alloc_calc_mem_init(mem_calc, SPD_MID_HANDLERSOCKET_SHARE_SPIDER_HANDLERSOCKET_SHARE_1); - spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); - DBUG_VOID_RETURN; -} - -spider_handlersocket_share::~spider_handlersocket_share() -{ - DBUG_ENTER("spider_handlersocket_share::~spider_handlersocket_share"); - DBUG_PRINT("info",("spider this=%p", this)); - free_column_name_str(); - free_table_names_str(); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - if (db_table_str_hash_value) - { - spider_free(spider_current_trx, db_table_str_hash_value, MYF(0)); - } -#endif - spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_share::init() -{ - int error_num; - DBUG_ENTER("spider_handlersocket_share::init"); - DBUG_PRINT("info",("spider this=%p", this)); -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - if (!(db_table_str_hash_value = (my_hash_value_type *) - spider_bulk_alloc_mem(spider_current_trx, SPD_MID_HANDLERSOCKET_SHARE_INIT_1, - __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), - &db_table_str_hash_value, - sizeof(my_hash_value_type) * spider_share->all_link_count, - NullS)) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } -#endif - - if ( - (error_num = create_table_names_str()) || - ( - spider_share->table_share && - (error_num = create_column_name_str()) - ) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_share::append_table_name( - spider_string *str, - int all_link_idx -) { - const char *db_nm = db_names_str[all_link_idx].ptr(); - uint db_nm_len = db_names_str[all_link_idx].length(); - const char *table_nm = table_names_str[all_link_idx].ptr(); - uint table_nm_len = table_names_str[all_link_idx].length(); - DBUG_ENTER("spider_handlersocket_share::append_table_name"); - DBUG_PRINT("info",("spider this=%p", this)); - if (str->reserve(db_nm_len + SPIDER_SQL_DOT_LEN + table_nm_len + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 4)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - spider_db_handlersocket_utility.append_name(str, db_nm, db_nm_len); - str->q_append(SPIDER_SQL_DOT_STR, SPIDER_SQL_DOT_LEN); - spider_db_handlersocket_utility.append_name(str, table_nm, table_nm_len); - DBUG_RETURN(0); -} - -int spider_handlersocket_share::create_table_names_str() -{ - int error_num, roop_count; - uint table_nm_len, db_nm_len; - spider_string *str, *first_tbl_nm_str, *first_db_nm_str, *first_db_tbl_str; - char *first_tbl_nm, *first_db_nm; - uint dbton_id = spider_dbton_handlersocket.dbton_id; - DBUG_ENTER("spider_handlersocket_share::create_table_names_str"); - table_names_str = NULL; - db_names_str = NULL; - db_table_str = NULL; - if ( - !(table_names_str = new spider_string[spider_share->all_link_count]) || - !(db_names_str = new spider_string[spider_share->all_link_count]) || - !(db_table_str = new spider_string[spider_share->all_link_count]) - ) { - error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - - same_db_table_name = TRUE; - first_tbl_nm = spider_share->tgt_table_names[0]; - first_db_nm = spider_share->tgt_dbs[0]; - table_nm_len = spider_share->tgt_table_names_lengths[0]; - db_nm_len = spider_share->tgt_dbs_lengths[0]; - first_tbl_nm_str = &table_names_str[0]; - first_db_nm_str = &db_names_str[0]; - first_db_tbl_str = &db_table_str[0]; - for (roop_count = 0; roop_count < (int) spider_share->all_link_count; - roop_count++) - { - table_names_str[roop_count].init_calc_mem(SPD_MID_HANDLERSOCKET_SHARE_CREATE_TABLE_NAMES_STR_1); - db_names_str[roop_count].init_calc_mem(SPD_MID_HANDLERSOCKET_SHARE_CREATE_TABLE_NAMES_STR_2); - db_table_str[roop_count].init_calc_mem(SPD_MID_HANDLERSOCKET_SHARE_CREATE_TABLE_NAMES_STR_3); - if (spider_share->sql_dbton_ids[roop_count] != dbton_id) - continue; - if (first_all_link_idx == -1) - first_all_link_idx = roop_count; - - str = &table_names_str[roop_count]; - if ( - roop_count != 0 && - same_db_table_name && - spider_share->tgt_table_names_lengths[roop_count] == table_nm_len && - !memcmp(first_tbl_nm, spider_share->tgt_table_names[roop_count], - table_nm_len) - ) { - if (str->copy(*first_tbl_nm_str)) - { - error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - } else { - str->set_charset(spider_share->access_charset); - if ((error_num = spider_db_append_name_with_quote_str(str, - spider_share->tgt_table_names[roop_count], dbton_id))) - goto error; - if (roop_count) - { - same_db_table_name = FALSE; - DBUG_PRINT("info", ("spider found different table name %s", - spider_share->tgt_table_names[roop_count])); - if (str->length() > table_nm_max_length) - table_nm_max_length = str->length(); - } else - table_nm_max_length = str->length(); - } - - str = &db_names_str[roop_count]; - if ( - roop_count != 0 && - same_db_table_name && - spider_share->tgt_dbs_lengths[roop_count] == db_nm_len && - !memcmp(first_db_nm, spider_share->tgt_dbs[roop_count], - db_nm_len) - ) { - if (str->copy(*first_db_nm_str)) - { - error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - } else { - str->set_charset(spider_share->access_charset); - if ((error_num = spider_db_append_name_with_quote_str(str, - spider_share->tgt_dbs[roop_count], dbton_id))) - goto error; - if (roop_count) - { - same_db_table_name = FALSE; - DBUG_PRINT("info", ("spider found different db name %s", - spider_share->tgt_dbs[roop_count])); - if (str->length() > db_nm_max_length) - db_nm_max_length = str->length(); - } else - db_nm_max_length = str->length(); - } - - str = &db_table_str[roop_count]; - if ( - roop_count != 0 && - same_db_table_name - ) { - if (str->copy(*first_db_tbl_str)) - { - error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - } else { - str->set_charset(spider_share->access_charset); - if ((error_num = append_table_name(str, roop_count))) - goto error; - } -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - db_table_str_hash_value[roop_count] = my_calc_hash( - &spider_open_connections, (uchar*) str->ptr(), str->length()); -#endif - } - DBUG_RETURN(0); - -error: - if (db_table_str) - { - delete [] db_table_str; - db_table_str = NULL; - } - if (db_names_str) - { - delete [] db_names_str; - db_names_str = NULL; - } - if (table_names_str) - { - delete [] table_names_str; - table_names_str = NULL; - } - DBUG_RETURN(error_num); -} - -void spider_handlersocket_share::free_table_names_str() -{ - DBUG_ENTER("spider_handlersocket_share::free_table_names_str"); - if (db_table_str) - { - delete [] db_table_str; - db_table_str = NULL; - } - if (db_names_str) - { - delete [] db_names_str; - db_names_str = NULL; - } - if (table_names_str) - { - delete [] table_names_str; - table_names_str = NULL; - } - DBUG_VOID_RETURN; -} - -int spider_handlersocket_share::create_column_name_str() -{ - spider_string *str; - int error_num; - Field **field; - TABLE_SHARE *table_share = spider_share->table_share; - uint dbton_id = spider_dbton_handlersocket.dbton_id; - DBUG_ENTER("spider_handlersocket_share::create_column_name_str"); - if ( - table_share->fields && - !(column_name_str = new spider_string[table_share->fields]) - ) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - for (field = table_share->field, str = column_name_str; - *field; field++, str++) - { - str->init_calc_mem(SPD_MID_HANDLERSOCKET_SHARE_CREATE_COLUMN_NAME_STR_1); - str->set_charset(spider_share->access_charset); - if ((error_num = spider_db_append_name_with_quote_str(str, - (*field)->field_name, dbton_id))) - goto error; - } - DBUG_RETURN(0); - -error: - if (column_name_str) - { - delete [] column_name_str; - column_name_str = NULL; - } - DBUG_RETURN(error_num); -} - -void spider_handlersocket_share::free_column_name_str() -{ - DBUG_ENTER("spider_handlersocket_share::free_column_name_str"); - if (column_name_str) - { - delete [] column_name_str; - column_name_str = NULL; - } - DBUG_VOID_RETURN; -} - -uint spider_handlersocket_share::get_column_name_length( - uint field_index -) { - DBUG_ENTER("spider_handlersocket_share::get_column_name_length"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(column_name_str[field_index].length()); -} - -int spider_handlersocket_share::append_column_name( - spider_string *str, - uint field_index -) { - int error_num; - DBUG_ENTER("spider_handlersocket_share::append_column_name"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = spider_db_handlersocket_utility.append_name(str, - column_name_str[field_index].ptr(), column_name_str[field_index].length()); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_share::append_column_name_with_alias( - spider_string *str, - uint field_index, - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_share::append_column_name_with_alias"); - DBUG_PRINT("info",("spider this=%p", this)); - if (str->reserve( - alias_length + - column_name_str[field_index].length() + - /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(alias, alias_length); - append_column_name(str, field_index); - DBUG_RETURN(0); -} - -bool spider_handlersocket_share::need_change_db_table_name() -{ - DBUG_ENTER("spider_handlersocket_share::need_change_db_table_name"); - DBUG_RETURN(!same_db_table_name); -} - -#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE -int spider_handlersocket_share::discover_table_structure( - SPIDER_TRX *trx, - SPIDER_SHARE *spider_share, - spider_string *str -) { - DBUG_ENTER("spider_handlersocket_share::discover_table_structure"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} -#endif - -spider_handlersocket_handler::spider_handlersocket_handler( - ha_spider *spider, - spider_handlersocket_share *db_share -) : spider_db_handler( - spider, - db_share -), - handlersocket_share(db_share), - link_for_hash(NULL) -{ - DBUG_ENTER("spider_handlersocket_handler::spider_handlersocket_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - spider_alloc_calc_mem_init(mem_calc, SPD_MID_HANDLERSOCKET_HANDLER_SPIDER_HANDLERSOCKET_HANDLER_1); - spider_alloc_calc_mem(spider_current_trx, mem_calc, sizeof(*this)); - DBUG_VOID_RETURN; -} - -spider_handlersocket_handler::~spider_handlersocket_handler() -{ - DBUG_ENTER("spider_handlersocket_handler::~spider_handlersocket_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - if (link_for_hash) - { - spider_free(spider_current_trx, link_for_hash, MYF(0)); - } - spider_free_mem_calc(spider_current_trx, mem_calc_id, sizeof(*this)); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::init() -{ - st_spider_share *share = spider->share; - TABLE *table = spider->get_table(); - DBUG_ENTER("spider_handlersocket_handler::init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *) - spider_bulk_alloc_mem(spider_current_trx, SPD_MID_HANDLERSOCKET_HANDLER_INIT_1, - __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL), - &link_for_hash, - sizeof(SPIDER_LINK_FOR_HASH) * share->link_count, - &minimum_select_bitmap, - table ? sizeof(uchar) * no_bytes_in_map(table->read_set) : 0, - NullS)) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - uint roop_count; - for (roop_count = 0; roop_count < share->link_count; roop_count++) - { - link_for_hash[roop_count].spider = spider; - link_for_hash[roop_count].link_idx = roop_count; - link_for_hash[roop_count].db_table_str = - &handlersocket_share->db_table_str[roop_count]; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - link_for_hash[roop_count].db_table_str_hash_value = - handlersocket_share->db_table_str_hash_value[roop_count]; -#endif - } - hs_sql.init_calc_mem(SPD_MID_HANDLERSOCKET_HANDLER_INIT_2); - hs_sql.set_charset(share->access_charset); - hs_keys.init(); - hs_upds.init(); - hs_strs.init(); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_index_hint( - spider_string *str, - int link_idx, - ulong sql_type - ) -{ - DBUG_ENTER("spider_handlersocket_handler::append_index_hint"); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_table_name_with_adjusting( - spider_string *str, - int link_idx, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_table_name_with_adjusting"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_tmp_table_and_sql_for_bka( - const key_range *start_key -) { - DBUG_ENTER("spider_handlersocket_handler::append_tmp_table_and_sql_for_bka"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reuse_tmp_table_and_sql_for_bka() -{ - DBUG_ENTER("spider_handlersocket_handler::reuse_tmp_table_and_sql_for_bka"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_table_and_sql_for_bka( - const key_range *start_key -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_table_and_sql_for_bka"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reuse_union_table_and_sql_for_bka() -{ - DBUG_ENTER("spider_handlersocket_handler::reuse_union_table_and_sql_for_bka"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_insert_for_recovery( - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_insert_for_recovery"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_update( - const TABLE *table, - my_ptrdiff_t ptr_diff -) { - DBUG_ENTER("spider_handlersocket_handler::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_update( - const TABLE *table, - my_ptrdiff_t ptr_diff, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_delete( - const TABLE *table, - my_ptrdiff_t ptr_diff -) { - DBUG_ENTER("spider_handlersocket_handler::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_delete( - const TABLE *table, - my_ptrdiff_t ptr_diff, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_insert_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_insert_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_update_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_update_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_delete_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_delete_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_handlersocket_handler::append_increment_update_set_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_increment_update_set_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::append_update_set_part() -{ - DBUG_ENTER("spider_handlersocket_handler::append_update_set_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_handlersocket_handler::append_direct_update_set_part() -{ - SPIDER_SHARE *share = spider->share; - DBUG_ENTER("spider_handlersocket_handler::append_direct_update_set_part"); - if ( - spider->do_direct_update && - (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) - ) { - DBUG_PRINT("info",("spider add set for DU SPIDER_SQL_KIND_HS")); - size_t roop_count; - Field *field; - hs_adding_keys = FALSE; - for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num; - roop_count++) - { - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - if (top_table_field->is_null()) - { - hs_upds.push_back(spider_null_string_ref); - } else { - if (spider_db_handlersocket_utility. - append_column_value(spider, NULL, top_table_field, NULL, - share->access_charset)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - } - } - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::append_minimum_select_without_quote( - spider_string *str -) { - TABLE *table = spider->get_table(); - Field **field; - int field_length; - bool appended = FALSE; - DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_without_quote"); - minimum_select_bitmap_create(); - for (field = table->field; *field; field++) - { - if (minimum_select_bit_is_set((*field)->field_index)) - { -/* - spider_set_bit(minimum_select_bitmap, (*field)->field_index); -*/ - field_length = - handlersocket_share->column_name_str[(*field)->field_index].length(); - if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append( - handlersocket_share->column_name_str[(*field)->field_index].ptr(), - handlersocket_share->column_name_str[(*field)->field_index].length()); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - appended = TRUE; - } - } - if (appended) - str->length(str->length() - SPIDER_SQL_COMMA_LEN); - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_handlersocket_handler::append_minimum_select_by_field_idx_list( - spider_string *str, - uint32 *field_idxs, - size_t field_idxs_num -) { - Field *field; - int roop_count, field_length; - bool appended = FALSE; - DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_by_field_idx_list"); - for (roop_count = 0; roop_count < (int) field_idxs_num; roop_count++) - { - field = spider->get_top_table_field(field_idxs[roop_count]); - if ((field = spider->field_exchange(field))) - { - field_length = - handlersocket_share->column_name_str[field->field_index].length(); - if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append( - handlersocket_share->column_name_str[field->field_index].ptr(), - handlersocket_share->column_name_str[field->field_index].length()); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - appended = TRUE; - } - } - if (appended) - str->length(str->length() - SPIDER_SQL_COMMA_LEN); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_dup_update_pushdown_part( - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_handler::append_dup_update_pushdown_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_update_columns_part( - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_handler::append_update_columns_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::check_update_columns_part() -{ - DBUG_ENTER("spider_handlersocket_handler::check_update_columns_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::append_select_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_table_select_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_table_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_select_part( - ulong sql_type, - uint idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_minimum_select_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_hint_after_table_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_hint_after_table_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_handlersocket_handler::set_where_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_where_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -void spider_handlersocket_handler::set_where_to_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_where_to_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::check_item_type( - Item *item -) { - DBUG_ENTER("spider_handlersocket_handler::check_item_type"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_values_connector_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_values_connector_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_values_terminator_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_values_terminator_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_table_connector_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_table_connector_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_table_terminator_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_table_terminator_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_column_values_part( - const key_range *start_key, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_column_values_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_column_values_with_name_part( - const key_range *start_key, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_column_values_with_name_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_where_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type -) { - int error_num; - spider_string *str; - bool set_order; - DBUG_ENTER("spider_handlersocket_handler::append_key_where_part"); - switch (sql_type) - { - case SPIDER_SQL_TYPE_SELECT_HS: - case SPIDER_SQL_TYPE_INSERT_HS: - case SPIDER_SQL_TYPE_UPDATE_HS: - case SPIDER_SQL_TYPE_DELETE_HS: - str = &hs_sql; - str->length(0); - hs_adding_keys = TRUE; - set_order = FALSE; - break; - default: - DBUG_RETURN(0); - } - error_num = append_key_where(str, NULL, NULL, start_key, end_key, - sql_type, set_order); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_key_where( - spider_string *str, - spider_string *str_part, - spider_string *str_part2, - const key_range *start_key, - const key_range *end_key, - ulong sql_type, - bool set_order -) { - int error_num; - DBUG_ENTER("spider_handlersocket_handler::append_key_where"); - error_num = spider_db_append_key_where_internal(str, str_part, str_part2, - start_key, end_key, spider, set_order, sql_type, - spider_dbton_handlersocket.dbton_id); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_is_null_part( - ulong sql_type, - KEY_PART_INFO *key_part, - const key_range *key, - const uchar **ptr, - bool key_eq, - bool tgt_final -) { - int error_num; - spider_string *str; - DBUG_ENTER("spider_handlersocket_handler::append_is_null_part"); - DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_SELECT_HS: - case SPIDER_SQL_TYPE_INSERT_HS: - case SPIDER_SQL_TYPE_UPDATE_HS: - case SPIDER_SQL_TYPE_DELETE_HS: - str = &hs_sql; - break; - default: - DBUG_RETURN(0); - } - error_num = append_is_null(sql_type, str, NULL, NULL, key_part, key, ptr, - key_eq, tgt_final); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_is_null( - ulong sql_type, - spider_string *str, - spider_string *str_part, - spider_string *str_part2, - KEY_PART_INFO *key_part, - const key_range *key, - const uchar **ptr, - bool key_eq, - bool tgt_final -) { - DBUG_ENTER("spider_handlersocket_handler::append_is_null"); - DBUG_PRINT("info",("spider this=%p", this)); - if (key_part->null_bit) - { - if (*(*ptr)++) - { - hs_keys.push_back(spider_null_string_ref); - DBUG_RETURN(-1); - } - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_where_terminator_part( - ulong sql_type, - bool set_order, - int key_count -) { - DBUG_ENTER("spider_handlersocket_handler::append_where_terminator_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_match_where_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_match_where_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_condition_part( - const char *alias, - uint alias_length, - ulong sql_type, - bool test_flg -) { - DBUG_ENTER("spider_handlersocket_handler::append_condition_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_match_select_part( - ulong sql_type, - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_handler::append_match_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -#ifdef HANDLER_HAS_DIRECT_AGGREGATE -int spider_handlersocket_handler::append_sum_select_part( - ulong sql_type, - const char *alias, - uint alias_length -) { - DBUG_ENTER("spider_handlersocket_handler::append_sum_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -void spider_handlersocket_handler::set_order_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_order_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -void spider_handlersocket_handler::set_order_to_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_order_to_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -#ifdef HANDLER_HAS_DIRECT_AGGREGATE -int spider_handlersocket_handler::append_group_by_part( - const char *alias, - uint alias_length, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_group_by_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::append_key_order_for_merge_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_order_for_merge_with_alias_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_order_for_direct_order_limit_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_order_for_direct_order_limit_with_alias_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_key_order_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_key_order_with_alias_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_limit_part( - longlong offset, - longlong limit, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_limit_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info", ("spider offset=%lld", offset)); - DBUG_PRINT("info", ("spider limit=%lld", limit)); - hs_skip = (int) offset; - hs_limit = (int) limit; - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reappend_limit_part( - longlong offset, - longlong limit, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reappend_limit_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_select_lock_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_select_lock_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_all_start_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_all_start_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_all_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_all_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_union_all_end_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_union_all_end_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_multi_range_cnt_part( - ulong sql_type, - uint multi_range_cnt, - bool with_comma -) { - DBUG_ENTER("spider_handlersocket_handler::append_multi_range_cnt_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_multi_range_cnt_with_name_part( - ulong sql_type, - uint multi_range_cnt -) { - DBUG_ENTER("spider_handlersocket_handler::append_multi_range_cnt_with_name_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_open_handler_part( - ulong sql_type, - uint handler_id, - SPIDER_CONN *conn, - int link_idx -) { - int error_num; - spider_string *str; - DBUG_ENTER("spider_handlersocket_handler::append_open_handler_part"); - DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_HS: - str = &hs_sql; - break; - default: - DBUG_RETURN(0); - } - error_num = append_open_handler(str, handler_id, conn, link_idx); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_open_handler( - spider_string *str, - uint handler_id, - SPIDER_CONN *conn, - int link_idx -) { - int error_num; - DBUG_ENTER("spider_handlersocket_handler::append_open_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - if ( - str->length() == 0 && -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - ( - ( - ( - spider->sql_command == SQLCOM_HS_INSERT || - spider->hs_pushed_ret_fields_num == MAX_FIELDS - ) && -#endif - (error_num = append_minimum_select_without_quote(str)) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - ) || - ( - ( - spider->sql_command != SQLCOM_HS_INSERT && - spider->hs_pushed_ret_fields_num < MAX_FIELDS - ) && - (error_num = append_minimum_select_by_field_idx_list(str, - spider->hs_pushed_ret_fields, spider->hs_pushed_ret_fields_num)) - ) - ) -#endif - ) { - DBUG_RETURN(error_num); - } - - TABLE *table = spider->get_table(); - SPIDER_SHARE *share = spider->share; - DBUG_PRINT("info",("spider field list=%s", str->c_ptr_safe())); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - conn->db_conn->append_open_handler( - handler_id, - share->tgt_dbs[spider->conn_link_idx[link_idx]], - share->tgt_table_names[spider->conn_link_idx[link_idx]], - spider->active_index < MAX_KEY ? - table->key_info[spider->active_index].name : - "0", - str->c_ptr_safe(), - &request_key - ); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_close_handler_part( - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_close_handler_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_insert_terminator_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_insert_terminator_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_insert_values_part( - ulong sql_type -) { - int error_num; - spider_string *str; - DBUG_ENTER("spider_mysql_handler::append_insert_values_part"); - DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_INSERT_HS: - str = &hs_sql; - break; - default: - DBUG_RETURN(0); - } - error_num = append_insert_values(str); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::append_insert_values( - spider_string *str -) { - SPIDER_SHARE *share = spider->share; - TABLE *table = spider->get_table(); - Field **field; - DBUG_ENTER("spider_mysql_handler::append_insert_values"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_adding_keys = FALSE; - for (field = table->field; *field; field++) - { - DBUG_PRINT("info",("spider field_index=%u", (*field)->field_index)); - if ( - bitmap_is_set(table->write_set, (*field)->field_index) || - bitmap_is_set(table->read_set, (*field)->field_index) - ) { -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = - dbug_tmp_use_all_columns(table, table->read_set); -#endif - DBUG_PRINT("info",("spider is_null()=%s", - (*field)->is_null() ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider table->next_number_field=%p", - table->next_number_field)); - DBUG_PRINT("info",("spider *field=%p", *field)); - DBUG_PRINT("info",("spider force_auto_increment=%s", - (table->next_number_field && spider->force_auto_increment) ? - "TRUE" : "FALSE")); - if ( - (*field)->is_null() || - ( - table->next_number_field == *field && - !table->auto_increment_field_not_null && - !spider->force_auto_increment - ) - ) { - hs_upds.push_back(spider_null_string_ref); - } else { - spider_db_handlersocket_utility. - append_column_value(spider, NULL, *field, NULL, - share->access_charset); - } -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - } - } - int error_num; - int roop_count2; - for ( - roop_count2 = spider_conn_link_idx_next(share->link_statuses, - spider->conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_count2 < (int) share->link_count; - roop_count2 = spider_conn_link_idx_next(share->link_statuses, - spider->conn_link_idx, roop_count2, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - if (spider->sql_kind[roop_count2] == SPIDER_SQL_KIND_HS) - { - SPIDER_CONN *conn = spider->hs_w_conns[roop_count2]; - if (conn->dbton_id == spider_dbton_handlersocket.dbton_id) - { - if ((error_num = request_buf_insert(roop_count2))) - DBUG_RETURN(error_num); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count2] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->trx, conn); - } -#endif - } - } - } - hs_upds.clear(); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_into_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_into_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_handlersocket_handler::set_insert_to_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_insert_to_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::append_from_part( - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_from_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_delete_all_rows_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_delete_all_rows_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_explain_select_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::append_explain_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::is_sole_projection_field( - uint16 field_index -) { - DBUG_ENTER("spider_handlersocket_handler::is_sole_projection_field"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -bool spider_handlersocket_handler::is_bulk_insert_exec_period( - bool bulk_end -) { - DBUG_ENTER("spider_handlersocket_handler::is_bulk_insert_exec_period"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!spider->bulk_insert || bulk_end) - DBUG_RETURN(TRUE); - DBUG_RETURN(FALSE); -} - -bool spider_handlersocket_handler::sql_is_filled_up( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::sql_is_filled_up"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -bool spider_handlersocket_handler::sql_is_empty( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::sql_is_empty"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -bool spider_handlersocket_handler::support_multi_split_read() -{ - DBUG_ENTER("spider_handlersocket_handler::support_multi_split_read"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -bool spider_handlersocket_handler::support_bulk_update() -{ - DBUG_ENTER("spider_handlersocket_handler::support_bulk_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -int spider_handlersocket_handler::bulk_tmp_table_insert() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_insert( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_end_bulk_insert() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_end_bulk_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_rnd_init() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_rnd_init"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_rnd_next() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_rnd_next"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::bulk_tmp_table_rnd_end() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_rnd_end"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -bool spider_handlersocket_handler::need_copy_for_update( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::need_copy_for_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(TRUE); -} - -bool spider_handlersocket_handler::bulk_tmp_table_created() -{ - DBUG_ENTER("spider_handlersocket_handler::bulk_tmp_table_created"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(FALSE); -} - -int spider_handlersocket_handler::mk_bulk_tmp_table_and_bulk_start() -{ - DBUG_ENTER("spider_handlersocket_handler::mk_bulk_tmp_table_and_bulk_start"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_handlersocket_handler::rm_bulk_tmp_table() -{ - DBUG_ENTER("spider_handlersocket_handler::rm_bulk_tmp_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::insert_lock_tables_list( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::insert_lock_tables_list"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_lock_tables_list( - SPIDER_CONN *conn, - int link_idx, - int *appended -) { - DBUG_ENTER("spider_handlersocket_handler::append_lock_tables_list"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::realloc_sql( - ulong *realloced -) { - THD *thd = spider->trx->thd; - st_spider_share *share = spider->share; - int init_sql_alloc_size = - spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); - DBUG_ENTER("spider_handlersocket_handler::realloc_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((int) hs_sql.alloced_length() > init_sql_alloc_size * 2) - { - hs_sql.free(); - if (hs_sql.real_alloc(init_sql_alloc_size)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - *realloced |= SPIDER_SQL_TYPE_FULL_HS; - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_sql( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_sql.length(0); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_keys( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_keys.clear(); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_upds( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_upds.clear(); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_strs( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_strs"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_strs.clear(); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_strs_pos( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_strs_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_FULL_HS) - { - hs_strs_pos = 0; - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::push_back_upds( - SPIDER_HS_STRING_REF &info -) { - int error_num; - DBUG_ENTER("spider_handlersocket_handler::push_back_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = hs_upds.push_back(info); - DBUG_RETURN(error_num); -} - -int spider_handlersocket_handler::request_buf_find( - int link_idx -) { - int error_num; - spider_string *hs_str; - SPIDER_CONN *conn; - uint handler_id; - DBUG_ENTER("spider_handlersocket_handler::request_buf_find"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(hs_str = hs_strs.add(&hs_strs_pos, hs_sql.ptr(), hs_sql.length()))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (spider->conn_kind[link_idx] == SPIDER_CONN_KIND_HS_READ) - { - conn = spider->hs_r_conns[link_idx]; - handler_id = spider->r_handler_id[link_idx]; - } else { - conn = spider->hs_w_conns[link_idx]; - handler_id = spider->w_handler_id[link_idx]; - } - if ((error_num = spider_db_conn_queue_action(conn))) - DBUG_RETURN(error_num); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - conn->db_conn->append_select( - handler_id, hs_str, &hs_keys, - hs_limit, hs_skip, &request_key); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::request_buf_insert( - int link_idx -) { - int error_num; - DBUG_ENTER("spider_handlersocket_handler::request_buf_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = spider_db_conn_queue_action(spider->hs_w_conns[link_idx]))) - DBUG_RETURN(error_num); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - spider->hs_w_conns[link_idx]->db_conn->append_insert( - spider->w_handler_id[link_idx], &hs_upds, &request_key); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::request_buf_update( - int link_idx -) { - int error_num; - spider_string *hs_str; - DBUG_ENTER("spider_handlersocket_handler::request_buf_update"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(hs_str = hs_strs.add(&hs_strs_pos, hs_sql.ptr(), hs_sql.length()))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if ((error_num = spider_db_conn_queue_action(spider->hs_w_conns[link_idx]))) - DBUG_RETURN(error_num); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - spider->hs_w_conns[link_idx]->db_conn->append_update( - spider->w_handler_id[link_idx], hs_str, &hs_keys, &hs_upds, - hs_limit, hs_skip, - spider->hs_increment, spider->hs_decrement, &request_key - ); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::request_buf_delete( - int link_idx -) { - int error_num; - spider_string *hs_str; - DBUG_ENTER("spider_handlersocket_handler::request_buf_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(hs_str = hs_strs.add(&hs_strs_pos, hs_sql.ptr(), hs_sql.length()))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if ((error_num = spider_db_conn_queue_action(spider->hs_w_conns[link_idx]))) - DBUG_RETURN(error_num); - if (!spider_bit_is_set(spider->db_request_phase, link_idx)) - { - spider_set_bit(spider->db_request_phase, link_idx); - ++spider->db_request_id[link_idx]; - } - st_spider_db_request_key request_key; - request_key.spider_thread_id = spider->trx->spider_thread_id; - request_key.query_id = spider->trx->thd->query_id; - request_key.handler = spider; - request_key.request_id = spider->db_request_id[link_idx]; - request_key.next = NULL; - spider->hs_w_conns[link_idx]->db_conn->append_delete( - spider->w_handler_id[link_idx], hs_str, &hs_keys, - hs_limit, hs_skip, &request_key); - DBUG_RETURN(0); -} - -bool spider_handlersocket_handler::need_lock_before_set_sql_for_exec( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::need_lock_before_set_sql_for_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(TRUE); -} - -#ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_handlersocket_handler::set_sql_for_exec( - ulong sql_type, - int link_idx, - SPIDER_LINK_IDX_CHAIN *link_idx_chain -) { - DBUG_ENTER("spider_handlersocket_handler::set_sql_for_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif - -int spider_handlersocket_handler::set_sql_for_exec( - ulong sql_type, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::set_sql_for_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - if (sql_type & SPIDER_SQL_TYPE_SELECT_HS) - { - DBUG_RETURN(request_buf_find(link_idx)); - } - if (sql_type & SPIDER_SQL_TYPE_INSERT_HS) - { - DBUG_RETURN(request_buf_insert(link_idx)); - } - if (sql_type & SPIDER_SQL_TYPE_UPDATE_HS) - { - DBUG_RETURN(request_buf_update(link_idx)); - } - if (sql_type & SPIDER_SQL_TYPE_DELETE_HS) - { - DBUG_RETURN(request_buf_delete(link_idx)); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::set_sql_for_exec( - spider_db_copy_table *tgt_ct, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::set_sql_for_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::execute_sql( - ulong sql_type, - SPIDER_CONN *conn, - int quick_mode, - int *need_mon -) { - DBUG_ENTER("spider_handlersocket_handler::execute_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!(sql_type & SPIDER_SQL_TYPE_FULL_HS)) - { - /* nothing to do */ - DBUG_RETURN(0); - } - DBUG_RETURN(spider_db_query( - conn, - NULL, - 0, - quick_mode, - need_mon - )); -} - -int spider_handlersocket_handler::reset() -{ - DBUG_ENTER("spider_handlersocket_handler::reset"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::sts_mode_exchange( - int sts_mode -) { - DBUG_ENTER("spider_handlersocket_handler::sts_mode_exchange"); - DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); - DBUG_RETURN(sts_mode); -} - -int spider_handlersocket_handler::show_table_status( - int link_idx, - int sts_mode, - uint flag -) { - spider_db_handlersocket_result res(NULL); - SPIDER_SHARE *share = spider->share; - ulonglong auto_increment_value = 0; - DBUG_ENTER("spider_handlersocket_show_table_status"); - res.fetch_table_status( - sts_mode, - share->stat - ); - if (auto_increment_value > share->lgtm_tblhnd_share->auto_increment_value) - { - share->lgtm_tblhnd_share->auto_increment_value = auto_increment_value; - DBUG_PRINT("info",("spider auto_increment_value=%llu", - share->lgtm_tblhnd_share->auto_increment_value)); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::crd_mode_exchange( - int crd_mode -) { - DBUG_ENTER("spider_handlersocket_handler::crd_mode_exchange"); - DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); - DBUG_RETURN(crd_mode); -} - -int spider_handlersocket_handler::show_index( - int link_idx, - int crd_mode -) { - DBUG_ENTER("spider_handlersocket_handler::show_index"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::show_records( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::show_records"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::show_last_insert_id( - int link_idx, - ulonglong &last_insert_id -) { - DBUG_ENTER("spider_handlersocket_handler::show_last_insert_id"); - last_insert_id = 0; - DBUG_RETURN(0); -} - -ha_rows spider_handlersocket_handler::explain_select( - key_range *start_key, - key_range *end_key, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::explain_select"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::lock_tables( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::lock_tables"); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::unlock_tables( - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::unlock_tables"); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::disable_keys( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::disable_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::enable_keys( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::enable_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::check_table( - SPIDER_CONN *conn, - int link_idx, - HA_CHECK_OPT* check_opt -) { - DBUG_ENTER("spider_handlersocket_handler::check_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::repair_table( - SPIDER_CONN *conn, - int link_idx, - HA_CHECK_OPT* check_opt -) { - DBUG_ENTER("spider_handlersocket_handler::repair_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::analyze_table( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::analyze_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::optimize_table( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::optimize_table"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::flush_tables( - SPIDER_CONN *conn, - int link_idx, - bool lock -) { - DBUG_ENTER("spider_handlersocket_handler::flush_tables"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::flush_logs( - SPIDER_CONN *conn, - int link_idx -) { - DBUG_ENTER("spider_handlersocket_handler::flush_logs"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::insert_opened_handler( - SPIDER_CONN *conn, - int link_idx -) { - spider_db_handlersocket *db_conn = (spider_db_handlersocket *) conn->db_conn; - SPIDER_LINK_FOR_HASH *tmp_link_for_hash = &link_for_hash[link_idx]; - DBUG_ASSERT(tmp_link_for_hash->spider == spider); - DBUG_ASSERT(tmp_link_for_hash->link_idx == link_idx); - uint old_elements = db_conn->handler_open_array.max_element; - DBUG_ENTER("spider_handlersocket_handler::insert_opened_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - if (insert_dynamic(&db_conn->handler_open_array, - (uchar*) &tmp_link_for_hash)) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - if (db_conn->handler_open_array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - db_conn->handler_open_array, - (db_conn->handler_open_array.max_element - old_elements) * - db_conn->handler_open_array.size_of_element); - } - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::delete_opened_handler( - SPIDER_CONN *conn, - int link_idx -) { - spider_db_handlersocket *db_conn = (spider_db_handlersocket *) conn->db_conn; - uint roop_count, elements = db_conn->handler_open_array.elements; - SPIDER_LINK_FOR_HASH *tmp_link_for_hash; - DBUG_ENTER("spider_handlersocket_handler::delete_opened_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - for (roop_count = 0; roop_count < elements; roop_count++) - { - get_dynamic(&db_conn->handler_open_array, (uchar *) &tmp_link_for_hash, - roop_count); - if (tmp_link_for_hash == &link_for_hash[link_idx]) - { - delete_dynamic_element(&db_conn->handler_open_array, roop_count); - break; - } - } - DBUG_ASSERT(roop_count < elements); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::sync_from_clone_source( - spider_db_handler *dbton_hdl -) { - spider_handlersocket_handler *hs_hdl = - (spider_handlersocket_handler *) dbton_hdl; - DBUG_ENTER("spider_handlersocket_handler::sync_from_clone_source"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_strs_pos = hs_hdl->hs_strs_pos; - DBUG_RETURN(0); -} - -bool spider_handlersocket_handler::support_use_handler( - int use_handler -) { - DBUG_ENTER("spider_handlersocket_handler::support_use_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(TRUE); -} - -void spider_handlersocket_handler::minimum_select_bitmap_create() -{ - TABLE *table = spider->get_table(); - Field **field_p; - DBUG_ENTER("spider_handlersocket_handler::minimum_select_bitmap_create"); - memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set)); - if ( - spider->use_index_merge || -#ifdef HA_CAN_BULK_ACCESS - (spider->is_clone && !spider->is_bulk_access_clone) -#else - spider->is_clone -#endif - ) { - /* need preparing for cmp_ref */ - TABLE_SHARE *table_share = table->s; - if ( - table_share->primary_key == MAX_KEY - ) { - /* need all columns */ - memset(minimum_select_bitmap, 0xFF, no_bytes_in_map(table->read_set)); - DBUG_VOID_RETURN; - } else { - /* need primary key columns */ - uint roop_count; - KEY *key_info; - KEY_PART_INFO *key_part; - Field *field; - key_info = &table_share->key_info[table_share->primary_key]; - key_part = key_info->key_part; - for (roop_count = 0; - roop_count < spider_user_defined_key_parts(key_info); - roop_count++) - { - field = key_part[roop_count].field; - spider_set_bit(minimum_select_bitmap, field->field_index); - } - } - } - for (field_p = table->field; *field_p; field_p++) - { - uint field_index = (*field_p)->field_index; - if ( - spider_bit_is_set(spider->searched_bitmap, field_index) || - bitmap_is_set(table->read_set, field_index) || - bitmap_is_set(table->write_set, field_index) - ) { - spider_set_bit(minimum_select_bitmap, field_index); - } - } - DBUG_VOID_RETURN; -} - -bool spider_handlersocket_handler::minimum_select_bit_is_set( - uint field_index -) { - DBUG_ENTER("spider_handlersocket_handler::minimum_select_bit_is_set"); - DBUG_PRINT("info",("spider field_index=%u", field_index)); - DBUG_PRINT("info",("spider minimum_select_bitmap=%s", - spider_bit_is_set(minimum_select_bitmap, field_index) ? - "TRUE" : "FALSE")); - DBUG_RETURN(spider_bit_is_set(minimum_select_bitmap, field_index)); -} - -void spider_handlersocket_handler::copy_minimum_select_bitmap( - uchar *bitmap -) { - int roop_count; - TABLE *table = spider->get_table(); - DBUG_ENTER("spider_handlersocket_handler::copy_minimum_select_bitmap"); - for (roop_count = 0; - roop_count < (int) ((table->s->fields + 7) / 8); - roop_count++) - { - bitmap[roop_count] = - minimum_select_bitmap[roop_count]; - DBUG_PRINT("info",("spider roop_count=%d", roop_count)); - DBUG_PRINT("info",("spider bitmap=%d", - bitmap[roop_count])); - } - DBUG_VOID_RETURN; -} - -int spider_handlersocket_handler::init_union_table_name_pos() -{ - DBUG_ENTER("spider_handlersocket_handler::init_union_table_name_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::set_union_table_name_pos() -{ - DBUG_ENTER("spider_handlersocket_handler::set_union_table_name_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reset_union_table_name( - spider_string *str, - int link_idx, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reset_union_table_name"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -#ifdef SPIDER_HAS_GROUP_BY_HANDLER -int spider_handlersocket_handler::append_list_item_select_part( - List *select, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_list_item_select_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_from_and_tables_part( - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_from_and_tables_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::reappend_tables_part( - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::reappend_tables_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_where_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_where_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_having_part( - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_having_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_item_type_part( - Item *item, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_item_type_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_group_by_part( - ORDER *order, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_group_by_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_handlersocket_handler::append_order_by_part( - ORDER *order, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type -) { - DBUG_ENTER("spider_handlersocket_handler::append_order_by_part"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} -#endif -#endif diff --git a/storage/spider/spd_db_handlersocket.h b/storage/spider/spd_db_handlersocket.h deleted file mode 100644 index f7a454b66af..00000000000 --- a/storage/spider/spd_db_handlersocket.h +++ /dev/null @@ -1,1091 +0,0 @@ -/* Copyright (C) 2012-2018 Kentoku Shiba - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ - -#define SPIDER_HS_CONN dena::hstcpcli_ptr -#define SPIDER_HS_CONN_CREATE dena::hstcpcli_i::create -#define SPIDER_HS_RESULT dena::hstresult -#define SPIDER_HS_SOCKARGS dena::socket_args - -class spider_db_handlersocket_util: public spider_db_util -{ -public: - spider_db_handlersocket_util(); - ~spider_db_handlersocket_util(); - int append_name( - spider_string *str, - const char *name, - uint name_length - ); - int append_name_with_charset( - spider_string *str, - const char *name, - uint name_length, - CHARSET_INFO *name_charset - ); - int append_escaped_name( - spider_string *str, - const char *name, - uint name_length - ); - int append_escaped_name_with_charset( - spider_string *str, - const char *name, - uint name_length, - CHARSET_INFO *name_charset - ); - bool is_name_quote( - const char head_code - ); - int append_escaped_name_quote( - spider_string *str - ); - int append_column_value( - ha_spider *spider, - spider_string *str, - Field *field, - const uchar *new_ptr, - CHARSET_INFO *access_charset - ); - int append_trx_isolation( - spider_string *str, - int trx_isolation - ); - int append_autocommit( - spider_string *str, - bool autocommit - ); - int append_sql_log_off( - spider_string *str, - bool sql_log_off - ); - int append_wait_timeout( - spider_string *str, - int wait_timeout - ); - int append_sql_mode( - spider_string *str, - sql_mode_t sql_mode - ); - int append_time_zone( - spider_string *str, - Time_zone *time_zone - ); - int append_start_transaction( - spider_string *str - ); - int append_xa_start( - spider_string *str, - XID *xid - ); - int append_lock_table_head( - spider_string *str - ); - int append_lock_table_body( - spider_string *str, - const char *db_name, - uint db_name_length, - CHARSET_INFO *db_name_charset, - const char *table_name, - uint table_name_length, - CHARSET_INFO *table_name_charset, - int lock_type - ); - int append_lock_table_tail( - spider_string *str - ); - int append_unlock_table( - spider_string *str - ); - int open_item_func( - Item_func *item_func, - ha_spider *spider, - spider_string *str, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields - ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE - int open_item_sum_func( - Item_sum *item_sum, - ha_spider *spider, - spider_string *str, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields - ); -#endif - int append_escaped_util( - spider_string *to, - String *from - ); - int append_escaped_util( - spider_string *to, - String *from - ); -#ifdef SPIDER_HAS_GROUP_BY_HANDLER - int append_from_and_tables( - ha_spider *spider, - spider_fields *fields, - spider_string *str, - TABLE_LIST *table_list, - uint table_count - ); - int reappend_tables( - spider_fields *fields, - SPIDER_LINK_IDX_CHAIN *link_idx_chain, - spider_string *str - ); - int append_where( - spider_string *str - ); - int append_having( - spider_string *str - ); -#endif -}; - -class spider_db_handlersocket_row: public spider_db_row -{ -public: - SPIDER_HS_STRING_REF *hs_row; - SPIDER_HS_STRING_REF *hs_row_first; - uint field_count; - uint row_size; - bool cloned; - spider_db_handlersocket_row(); - ~spider_db_handlersocket_row(); - int store_to_field( - Field *field, - CHARSET_INFO *access_charset - ); - int append_to_str( - spider_string *str - ); - int append_escaped_to_str( - spider_string *str, - uint dbton_id - ); - void first(); - void next(); - bool is_null(); - int val_int(); - double val_real(); - my_decimal *val_decimal( - my_decimal *decimal_value, - CHARSET_INFO *access_charset - ); - SPIDER_DB_ROW *clone(); - int store_to_tmp_table( - TABLE *tmp_table, - spider_string *str - ); - uint get_byte_size(); -}; - -class spider_db_handlersocket_result_buffer: public spider_db_result_buffer -{ -public: - SPIDER_HS_RESULT hs_result; - spider_db_handlersocket_result_buffer(); - ~spider_db_handlersocket_result_buffer(); - void clear(); - bool check_size( - longlong size - ); -}; - -class spider_db_handlersocket_result: public spider_db_result -{ -public: - SPIDER_HS_CONN *hs_conn_p; - spider_db_handlersocket_row row; - SPIDER_HS_STRING_REF hs_row; - uint field_count; - int store_error_num; - spider_db_handlersocket_result(SPIDER_DB_CONN *in_db_conn); - ~spider_db_handlersocket_result(); - bool has_result(); - void free_result(); - SPIDER_DB_ROW *current_row(); - SPIDER_DB_ROW *fetch_row(); - SPIDER_DB_ROW *fetch_row_from_result_buffer( - spider_db_result_buffer *spider_res_buf - ); - SPIDER_DB_ROW *fetch_row_from_tmp_table( - TABLE *tmp_table - ); - int fetch_table_status( - int mode, - ha_statistics &stat - ); - int fetch_table_records( - int mode, - ha_rows &records - ); - int fetch_table_cardinality( - int mode, - TABLE *table, - longlong *cardinality, - uchar *cardinality_upd, - int bitmap_size - ); - int fetch_table_mon_status( - int &status - ); - longlong num_rows(); - uint num_fields(); - void move_to_pos( - longlong pos - ); - int get_errno(); -#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE - int fetch_columns_for_discover_table_structure( - spider_string *str, - CHARSET_INFO *access_charset - ); - int fetch_index_for_discover_table_structure( - spider_string *str, - CHARSET_INFO *access_charset - ); - int fetch_table_for_discover_table_structure( - spider_string *str, - SPIDER_SHARE *spider_share, - CHARSET_INFO *access_charset - ); -#endif -}; - -class spider_db_handlersocket: public spider_db_conn -{ - SPIDER_HS_CONN hs_conn; - int stored_error; - uint field_count; -public: - DYNAMIC_ARRAY handler_open_array; - bool handler_open_array_inited; - uint handler_open_array_id; - const char *handler_open_array_func_name; - const char *handler_open_array_file_name; - ulong handler_open_array_line_no; - st_spider_db_request_key *request_key_req_first; - st_spider_db_request_key *request_key_req_last; - st_spider_db_request_key *request_key_snd_first; - st_spider_db_request_key *request_key_snd_last; - st_spider_db_request_key *request_key_reuse_first; - st_spider_db_request_key *request_key_reuse_last; - spider_db_handlersocket( - SPIDER_CONN *conn - ); - ~spider_db_handlersocket(); - int init(); - bool is_connected(); - void bg_connect(); - int connect( - char *tgt_host, - char *tgt_username, - char *tgt_password, - long tgt_port, - char *tgt_socket, - char *server_name, - int connect_retry_count, - longlong connect_retry_interval - ); - int ping(); - void bg_disconnect(); - void disconnect(); - int set_net_timeout(); - int exec_query( - const char *query, - uint length, - int quick_mode - ); - int get_errno(); - const char *get_error(); - bool is_server_gone_error( - int error_num - ); - bool is_dup_entry_error( - int error_num - ); - bool is_xa_nota_error( - int error_num - ); - spider_db_result *store_result( - spider_db_result_buffer **spider_res_buf, - st_spider_db_request_key *request_key, - int *error_num - ); - spider_db_result *use_result( - ha_spider *spider, - st_spider_db_request_key *request_key, - int *error_num - ); - int next_result(); - uint affected_rows(); - uint matched_rows(); - bool inserted_info( - spider_db_handler *handler, - spider_copy_info *copy_info - ); - ulonglong last_insert_id(); - int set_character_set( - const char *csname - ); - int select_db( - const char *dbname - ); - int consistent_snapshot( - int *need_mon - ); - bool trx_start_in_bulk_sql(); - int start_transaction( - int *need_mon - ); - int commit( - int *need_mon - ); - int rollback( - int *need_mon - ); - bool xa_start_in_bulk_sql(); - int xa_start( - XID *xid, - int *need_mon - ); - int xa_end( - XID *xid, - int *need_mon - ); - int xa_prepare( - XID *xid, - int *need_mon - ); - int xa_commit( - XID *xid, - int *need_mon - ); - int xa_rollback( - XID *xid, - int *need_mon - ); - bool set_trx_isolation_in_bulk_sql(); - int set_trx_isolation( - int trx_isolation, - int *need_mon - ); - bool set_autocommit_in_bulk_sql(); - int set_autocommit( - bool autocommit, - int *need_mon - ); - bool set_sql_log_off_in_bulk_sql(); - int set_sql_log_off( - bool sql_log_off, - int *need_mon - ); - bool set_wait_timeout_in_bulk_sql(); - int set_wait_timeout( - int wait_timeout, - int *need_mon - ); - bool set_sql_mode_in_bulk_sql(); - int set_sql_mode( - sql_mode_t sql_mode, - int *need_mon - ); - bool set_time_zone_in_bulk_sql(); - int set_time_zone( - Time_zone *time_zone, - int *need_mon - ); - int show_master_status( - SPIDER_TRX *trx, - SPIDER_SHARE *share, - int all_link_idx, - int *need_mon, - TABLE *table, - spider_string *str, - int mode, - SPIDER_DB_RESULT **res1, - SPIDER_DB_RESULT **res2 - ); - int append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key - ); - int append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key - ); - int append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - int append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key - ); - int append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key - ); - int append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - void reset_request_queue(); - size_t escape_string( - char *to, - const char *from, - size_t from_length - ); - bool have_lock_table_list(); - int append_lock_tables( - spider_string *str - ); - int append_unlock_tables( - spider_string *str - ); - uint get_lock_table_hash_count(); - void reset_lock_table_hash(); - uint get_opened_handler_count(); - void reset_opened_handler(); - void set_dup_key_idx( - ha_spider *spider, - int link_idx - ); - int append_request_key( - st_spider_db_request_key *request_key - ); - void reset_request_key_req(); - void reset_request_key_snd(); - void move_request_key_to_snd(); - int check_request_key( - st_spider_db_request_key *request_key - ); - bool cmp_request_key_to_snd( - st_spider_db_request_key *request_key - ); -}; - -class spider_handlersocket_share: public spider_db_share -{ -public: - spider_string *table_names_str; - spider_string *db_names_str; - spider_string *db_table_str; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - my_hash_value_type *db_table_str_hash_value; -#endif - uint table_nm_max_length; - uint db_nm_max_length; - spider_string *column_name_str; - bool same_db_table_name; - int first_all_link_idx; - spider_handlersocket_share( - st_spider_share *share - ); - ~spider_handlersocket_share(); - int init(); - int append_table_name( - spider_string *str, - int all_link_idx - ); - int create_table_names_str(); - void free_table_names_str(); - int create_column_name_str(); - void free_column_name_str(); - uint get_column_name_length( - uint field_index - ); - int append_column_name( - spider_string *str, - uint field_index - ); - int append_column_name_with_alias( - spider_string *str, - uint field_index, - const char *alias, - uint alias_length - ); - bool need_change_db_table_name(); -#ifdef SPIDER_HAS_DISCOVER_TABLE_STRUCTURE - int discover_table_structure( - SPIDER_TRX *trx, - SPIDER_SHARE *spider_share, - spider_string *str - ); -#endif -}; - -class spider_handlersocket_handler: public spider_db_handler -{ - spider_string hs_sql; -public: - bool hs_adding_keys; - SPIDER_DB_HS_STRING_REF_BUFFER hs_keys; - SPIDER_DB_HS_STRING_REF_BUFFER hs_upds; - SPIDER_DB_HS_STR_BUFFER hs_strs; - uint hs_strs_pos; - int hs_limit; - int hs_skip; - spider_handlersocket_share *handlersocket_share; - SPIDER_LINK_FOR_HASH *link_for_hash; - uchar *minimum_select_bitmap; - spider_handlersocket_handler( - ha_spider *spider, - spider_handlersocket_share *db_share - ); - ~spider_handlersocket_handler(); - int init(); - int append_index_hint( - spider_string *str, - int link_idx, - ulong sql_type - ); - int append_table_name_with_adjusting( - spider_string *str, - int link_idx, - ulong sql_type - ); - int append_tmp_table_and_sql_for_bka( - const key_range *start_key - ); - int reuse_tmp_table_and_sql_for_bka(); - int append_union_table_and_sql_for_bka( - const key_range *start_key - ); - int reuse_union_table_and_sql_for_bka(); - int append_insert_for_recovery( - ulong sql_type, - int link_idx - ); - int append_update( - const TABLE *table, - my_ptrdiff_t ptr_diff - ); - int append_update( - const TABLE *table, - my_ptrdiff_t ptr_diff, - int link_idx - ); - int append_delete( - const TABLE *table, - my_ptrdiff_t ptr_diff - ); - int append_delete( - const TABLE *table, - my_ptrdiff_t ptr_diff, - int link_idx - ); - int append_insert_part(); - int append_update_part(); - int append_delete_part(); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_increment_update_set_part(); -#endif - int append_update_set_part(); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_direct_update_set_part(); -#endif - int append_minimum_select_without_quote( - spider_string *str - ); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_minimum_select_by_field_idx_list( - spider_string *str, - uint32 *field_idxs, - size_t field_idxs_num - ); - int append_dup_update_pushdown_part( - const char *alias, - uint alias_length - ); - int append_update_columns_part( - const char *alias, - uint alias_length - ); - int check_update_columns_part(); - int append_select_part( - ulong sql_type - ); -#endif - int append_table_select_part( - ulong sql_type - ); - int append_key_select_part( - ulong sql_type, - uint idx - ); - int append_minimum_select_part( - ulong sql_type - ); - int append_hint_after_table_part( - ulong sql_type - ); - void set_where_pos( - ulong sql_type - ); - void set_where_to_pos( - ulong sql_type - ); - int check_item_type( - Item *item - ); - int append_values_connector_part( - ulong sql_type - ); - int append_values_terminator_part( - ulong sql_type - ); - int append_union_table_connector_part( - ulong sql_type - ); - int append_union_table_terminator_part( - ulong sql_type - ); - int append_key_column_values_part( - const key_range *start_key, - ulong sql_type - ); - int append_key_column_values_with_name_part( - const key_range *start_key, - ulong sql_type - ); - int append_key_where_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type - ); - int append_key_where( - spider_string *str, - spider_string *str_part, - spider_string *str_part2, - const key_range *start_key, - const key_range *end_key, - ulong sql_type, - bool set_order - ); - int append_is_null_part( - ulong sql_type, - KEY_PART_INFO *key_part, - const key_range *key, - const uchar **ptr, - bool key_eq, - bool tgt_final - ); - int append_is_null( - ulong sql_type, - spider_string *str, - spider_string *str_part, - spider_string *str_part2, - KEY_PART_INFO *key_part, - const key_range *key, - const uchar **ptr, - bool key_eq, - bool tgt_final - ); - int append_where_terminator_part( - ulong sql_type, - bool set_order, - int key_count - ); - int append_match_where_part( - ulong sql_type - ); - int append_condition_part( - const char *alias, - uint alias_length, - ulong sql_type, - bool test_flg - ); - int append_match_select_part( - ulong sql_type, - const char *alias, - uint alias_length - ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE - int append_sum_select_part( - ulong sql_type, - const char *alias, - uint alias_length - ); -#endif - void set_order_pos( - ulong sql_type - ); - void set_order_to_pos( - ulong sql_type - ); -#ifdef HANDLER_HAS_DIRECT_AGGREGATE - int append_group_by_part( - const char *alias, - uint alias_length, - ulong sql_type - ); -#endif - int append_key_order_for_merge_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type - ); - int append_key_order_for_direct_order_limit_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type - ); - int append_key_order_with_alias_part( - const char *alias, - uint alias_length, - ulong sql_type - ); - int append_limit_part( - longlong offset, - longlong limit, - ulong sql_type - ); - int reappend_limit_part( - longlong offset, - longlong limit, - ulong sql_type - ); - int append_select_lock_part( - ulong sql_type - ); - int append_union_all_start_part( - ulong sql_type - ); - int append_union_all_part( - ulong sql_type - ); - int append_union_all_end_part( - ulong sql_type - ); - int append_multi_range_cnt_part( - ulong sql_type, - uint multi_range_cnt, - bool with_comma - ); - int append_multi_range_cnt_with_name_part( - ulong sql_type, - uint multi_range_cnt - ); - int append_open_handler_part( - ulong sql_type, - uint handler_id, - SPIDER_CONN *conn, - int link_idx - ); - int append_open_handler( - spider_string *str, - uint handler_id, - SPIDER_CONN *conn, - int link_idx - ); - int append_close_handler_part( - ulong sql_type, - int link_idx - ); - int append_insert_terminator_part( - ulong sql_type - ); - int append_insert_values_part( - ulong sql_type - ); - int append_insert_values( - spider_string *str - ); - int append_into_part( - ulong sql_type - ); - void set_insert_to_pos( - ulong sql_type - ); - int append_from_part( - ulong sql_type, - int link_idx - ); - int append_delete_all_rows_part( - ulong sql_type - ); - int append_explain_select_part( - const key_range *start_key, - const key_range *end_key, - ulong sql_type, - int link_idx - ); - bool is_sole_projection_field( - uint16 field_index - ); - bool is_bulk_insert_exec_period( - bool bulk_end - ); - bool sql_is_filled_up( - ulong sql_type - ); - bool sql_is_empty( - ulong sql_type - ); - bool support_multi_split_read(); - bool support_bulk_update(); - int bulk_tmp_table_insert(); - int bulk_tmp_table_insert( - int link_idx - ); - int bulk_tmp_table_end_bulk_insert(); - int bulk_tmp_table_rnd_init(); - int bulk_tmp_table_rnd_next(); - int bulk_tmp_table_rnd_end(); - bool need_copy_for_update( - int link_idx - ); - bool bulk_tmp_table_created(); - int mk_bulk_tmp_table_and_bulk_start(); - void rm_bulk_tmp_table(); - int insert_lock_tables_list( - SPIDER_CONN *conn, - int link_idx - ); - int append_lock_tables_list( - SPIDER_CONN *conn, - int link_idx, - int *appended - ); - int realloc_sql( - ulong *realloced - ); - int reset_sql( - ulong sql_type - ); - int reset_keys( - ulong sql_type - ); - int reset_upds( - ulong sql_type - ); - int reset_strs( - ulong sql_type - ); - int reset_strs_pos( - ulong sql_type - ); - int push_back_upds( - SPIDER_HS_STRING_REF &info - ); - int request_buf_find( - int link_idx - ); - int request_buf_insert( - int link_idx - ); - int request_buf_update( - int link_idx - ); - int request_buf_delete( - int link_idx - ); - bool need_lock_before_set_sql_for_exec( - ulong sql_type - ); -#ifdef SPIDER_HAS_GROUP_BY_HANDLER - int set_sql_for_exec( - ulong sql_type, - int link_idx, - SPIDER_LINK_IDX_CHAIN *link_idx_chain - ); -#endif - int set_sql_for_exec( - ulong sql_type, - int link_idx - ); - int set_sql_for_exec( - spider_db_copy_table *tgt_ct, - ulong sql_type - ); - int execute_sql( - ulong sql_type, - SPIDER_CONN *conn, - int quick_mode, - int *need_mon - ); - int reset(); - int sts_mode_exchange( - int sts_mode - ); - int show_table_status( - int link_idx, - int sts_mode, - uint flag - ); - int crd_mode_exchange( - int crd_mode - ); - int show_index( - int link_idx, - int crd_mode - ); - int show_records( - int link_idx - ); - int show_last_insert_id( - int link_idx, - ulonglong &last_insert_id - ); - ha_rows explain_select( - const key_range *start_key, - const key_range *end_key, - int link_idx - ); - int lock_tables( - int link_idx - ); - int unlock_tables( - int link_idx - ); - int disable_keys( - SPIDER_CONN *conn, - int link_idx - ); - int enable_keys( - SPIDER_CONN *conn, - int link_idx - ); - int check_table( - SPIDER_CONN *conn, - int link_idx, - HA_CHECK_OPT* check_opt - ); - int repair_table( - SPIDER_CONN *conn, - int link_idx, - HA_CHECK_OPT* check_opt - ); - int analyze_table( - SPIDER_CONN *conn, - int link_idx - ); - int optimize_table( - SPIDER_CONN *conn, - int link_idx - ); - int flush_tables( - SPIDER_CONN *conn, - int link_idx, - bool lock - ); - int flush_logs( - SPIDER_CONN *conn, - int link_idx - ); - int insert_opened_handler( - SPIDER_CONN *conn, - int link_idx - ); - int delete_opened_handler( - SPIDER_CONN *conn, - int link_idx - ); - int sync_from_clone_source( - spider_db_handler *dbton_hdl - ); - bool support_use_handler( - int use_handler - ); - void minimum_select_bitmap_create(); - bool minimum_select_bit_is_set( - uint field_index - ); - void copy_minimum_select_bitmap( - uchar *bitmap - ); - int init_union_table_name_pos(); - int set_union_table_name_pos(); - int reset_union_table_name( - spider_string *str, - int link_idx, - ulong sql_type - ); -#ifdef SPIDER_HAS_GROUP_BY_HANDLER - int append_from_and_tables_part( - spider_fields *fields, - ulong sql_type - ); - int reappend_tables_part( - spider_fields *fields, - ulong sql_type - ); - int append_where_part( - ulong sql_type - ); - int append_having_part( - ulong sql_type - ); - int append_item_type_part( - Item *item, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type - ); - int append_list_item_select_part( - List *select, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type - ); - int append_group_by_part( - ORDER *order, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type - ); - int append_order_by_part( - ORDER *order, - const char *alias, - uint alias_length, - bool use_fields, - spider_fields *fields, - ulong sql_type - ); -#endif -}; diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 1a1179183ab..eef5ea0927a 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -15,9 +15,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "hs_compat.h" -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#include "hstcpcli.hpp" -#endif #define SPIDER_DBTON_SIZE 15 @@ -91,26 +88,6 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_TABLE_NAME_STR "`table_name`" #define SPIDER_SQL_TABLE_NAME_LEN sizeof(SPIDER_SQL_TABLE_NAME_STR) - 1 -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#define SPIDER_SQL_HS_EQUAL_STR "=" -#define SPIDER_SQL_HS_EQUAL_LEN (sizeof(SPIDER_SQL_HS_EQUAL_STR) - 1) -#define SPIDER_SQL_HS_GT_STR ">" -#define SPIDER_SQL_HS_GT_LEN (sizeof(SPIDER_SQL_HS_GT_STR) - 1) -#define SPIDER_SQL_HS_GTEQUAL_STR ">=" -#define SPIDER_SQL_HS_GTEQUAL_LEN (sizeof(SPIDER_SQL_HS_GTEQUAL_STR) - 1) -#define SPIDER_SQL_HS_LT_STR "<" -#define SPIDER_SQL_HS_LT_LEN (sizeof(SPIDER_SQL_HS_LT_STR) - 1) -#define SPIDER_SQL_HS_INSERT_STR "+" -#define SPIDER_SQL_HS_INSERT_LEN (sizeof(SPIDER_SQL_HS_INSERT_STR) - 1) -#define SPIDER_SQL_HS_UPDATE_STR "U" -#define SPIDER_SQL_HS_UPDATE_LEN (sizeof(SPIDER_SQL_HS_UPDATE_STR) - 1) -#define SPIDER_SQL_HS_DELETE_STR "D" -#define SPIDER_SQL_HS_DELETE_LEN (sizeof(SPIDER_SQL_HS_DELETE_STR) - 1) -#define SPIDER_SQL_HS_INCREMENT_STR "+" -#define SPIDER_SQL_HS_INCREMENT_LEN (sizeof(SPIDER_SQL_HS_INCREMENT_STR) - 1) -#define SPIDER_SQL_HS_DECREMENT_STR "-" -#define SPIDER_SQL_HS_DECREMENT_LEN (sizeof(SPIDER_SQL_HS_DECREMENT_STR) - 1) -#endif #define SPIDER_SQL_HS_LTEQUAL_STR "<=" #define SPIDER_SQL_HS_LTEQUAL_LEN (sizeof(SPIDER_SQL_HS_LTEQUAL_STR) - 1) @@ -202,16 +179,9 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_LOP_CHK_PRM_PRF_LEN (sizeof(SPIDER_SQL_LOP_CHK_PRM_PRF_STR) - 1) #define SPIDER_CONN_KIND_MYSQL (1 << 0) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#define SPIDER_CONN_KIND_HS_READ (1 << 2) -#define SPIDER_CONN_KIND_HS_WRITE (1 << 3) -#endif #define SPIDER_SQL_KIND_SQL (1 << 0) #define SPIDER_SQL_KIND_HANDLER (1 << 1) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#define SPIDER_SQL_KIND_HS (1 << 2) -#endif #define SPIDER_SQL_TYPE_SELECT_SQL (1 << 0) #define SPIDER_SQL_TYPE_INSERT_SQL (1 << 1) @@ -689,70 +659,6 @@ public: ); }; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#define SPIDER_HS_UINT32_INFO dena::uint32_info -#define SPIDER_HS_STRING_REF dena::string_ref -#ifndef HANDLERSOCKET_MYSQL_UTIL -#define SPIDER_HS_VECTOR std::vector -class spider_db_hs_string_ref_buffer -{ - SPIDER_HS_VECTOR hs_conds; -public: - spider_db_hs_string_ref_buffer(); - ~spider_db_hs_string_ref_buffer(); - int init(); - void clear(); - int push_back( - SPIDER_HS_STRING_REF &cond - ); - SPIDER_HS_STRING_REF *ptr(); - uint size(); -}; -#else -class spider_db_hs_string_ref_buffer -{ - bool hs_da_init; - DYNAMIC_ARRAY hs_conds; - uint hs_conds_id; - const char *hs_conds_func_name; - const char *hs_conds_file_name; - ulong hs_conds_line_no; -public: - spider_db_hs_string_ref_buffer(); - ~spider_db_hs_string_ref_buffer(); - int init(); - void clear(); - int push_back( - SPIDER_HS_STRING_REF &cond - ); - SPIDER_HS_STRING_REF *ptr(); - uint size(); -}; -#endif - -class spider_db_hs_str_buffer -{ - bool hs_da_init; - DYNAMIC_ARRAY hs_conds; - uint hs_conds_id; - const char *hs_conds_func_name; - const char *hs_conds_file_name; - ulong hs_conds_line_no; -public: - spider_db_hs_str_buffer(); - ~spider_db_hs_str_buffer(); - int init(); - void clear(); - spider_string *add( - uint *strs_pos, - const char *str, - uint str_len - ); -}; - -#define SPIDER_DB_HS_STRING_REF_BUFFER spider_db_hs_string_ref_buffer -#define SPIDER_DB_HS_STR_BUFFER spider_db_hs_str_buffer -#endif struct st_spider_db_request_key { @@ -1155,54 +1061,6 @@ public: SPIDER_DB_RESULT **res1, SPIDER_DB_RESULT **res2 ) = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - virtual int append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key - ) = 0; - virtual int append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ) = 0; - virtual void reset_request_queue() = 0; -#endif virtual size_t escape_string( char *to, const char *from, @@ -1336,11 +1194,6 @@ public: virtual int append_insert_part() = 0; virtual int append_update_part() = 0; virtual int append_delete_part() = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - virtual int append_increment_update_set_part() = 0; -#endif -#endif virtual int append_update_set_part() = 0; #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS virtual int append_direct_update_set_part() = 0; @@ -1579,23 +1432,6 @@ public: virtual int reset_sql( ulong sql_type ) = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - virtual int reset_keys( - ulong sql_type - ) = 0; - virtual int reset_upds( - ulong sql_type - ) = 0; - virtual int reset_strs( - ulong sql_type - ) = 0; - virtual int reset_strs_pos( - ulong sql_type - ) = 0; - virtual int push_back_upds( - SPIDER_HS_STRING_REF &info - ) = 0; -#endif #ifdef SPIDER_HAS_GROUP_BY_HANDLER virtual int set_sql_for_exec( ulong sql_type, @@ -1958,18 +1794,7 @@ typedef struct st_spider_result_list SPIDER_RESULT *current; KEY *key_info; int key_order; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ulonglong hs_upd_rows; - SPIDER_DB_RESULT *hs_result; - SPIDER_DB_RESULT_BUFFER *hs_result_buf; - bool hs_has_result; - SPIDER_DB_CONN *hs_conn; -#endif #ifdef HA_CAN_BULK_ACCESS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uchar *hs_r_bulk_open_index; - uchar *hs_w_bulk_open_index; -#endif #endif spider_string *sqls; int ha_read_kind; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 53fcda4c17c..847e9413f3b 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -3546,96 +3546,6 @@ int spider_db_mbase::select_binlog_gtid_pos( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_db_mbase::append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_open_handler"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_select"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_mbase::append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_mbase::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_db_mbase::reset_request_queue() -{ - DBUG_ENTER("spider_db_mbase::reset_request_queue"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} -#endif size_t spider_db_mbase::escape_string( char *to, @@ -8437,9 +8347,6 @@ int spider_mbase_handler::init() mysql_share->db_table_str_hash_value[roop_count]; #endif } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_upds.init(); -#endif DBUG_RETURN(0); } @@ -9350,66 +9257,6 @@ int spider_mbase_handler::append_delete( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_mbase_handler::append_increment_update_set_part() -{ - int error_num; - DBUG_ENTER("spider_mbase_handler::append_increment_update_set_part"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = append_increment_update_set(&update_sql); - DBUG_RETURN(error_num); -} - -int spider_mbase_handler::append_increment_update_set( - spider_string *str -) { - uint field_name_length; - uint roop_count; - Field *field; - DBUG_ENTER("spider_mbase_handler::append_increment_update_set"); - if (str->reserve(SPIDER_SQL_SET_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); - const SPIDER_HS_STRING_REF *value = hs_upds.ptr(); - for (roop_count = 0; roop_count < hs_upds.size(); - roop_count++) - { - if ( - value[roop_count].size() == 1 && - *(value[roop_count].begin()) == '0' - ) - continue; - - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - field_name_length = - mysql_share->column_name_str[field->field_index].length(); - - if (str->reserve(field_name_length * 2 + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 4 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_HS_INCREMENT_LEN + - SPIDER_SQL_COMMA_LEN + value[roop_count].size())) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - - mysql_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - mysql_share->append_column_name(str, field->field_index); - if (spider->hs_increment) - str->q_append(SPIDER_SQL_HS_INCREMENT_STR, - SPIDER_SQL_HS_INCREMENT_LEN); - else - str->q_append(SPIDER_SQL_HS_DECREMENT_STR, - SPIDER_SQL_HS_DECREMENT_LEN); - str->q_append(value[roop_count].begin(), value[roop_count].size()); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - str->length(str->length() - SPIDER_SQL_COMMA_LEN); - DBUG_RETURN(0); -} -#endif -#endif int spider_mbase_handler::append_update_set_part() { @@ -9490,13 +9337,6 @@ int spider_mbase_handler::append_direct_update_set_part() int spider_mbase_handler::append_direct_update_set( spider_string *str ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint field_name_length; - SPIDER_SHARE *share = spider->share; -#ifndef DBUG_OFF - TABLE *table = spider->get_table(); -#endif -#endif DBUG_ENTER("spider_mbase_handler::append_direct_update_set"); if ( spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && @@ -9512,61 +9352,7 @@ int spider_mbase_handler::append_direct_update_set( if ( (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - size_t roop_count; - Field *field; - if (str->reserve(SPIDER_SQL_SET_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); - for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num; - roop_count++) - { - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - field_name_length = - mysql_share->column_name_str[field->field_index].length(); - if (top_table_field->is_null()) - { - if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN + - SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - mysql_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); - } else { - if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 2 + SPIDER_SQL_EQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - mysql_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, - table->read_set); -#endif - if ( - spider_db_mbase_utility-> - append_column_value(spider, str, top_table_field, NULL, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN) - ) { -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - } - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - str->length(str->length() - SPIDER_SQL_COMMA_LEN); -#else DBUG_ASSERT(0); -#endif } DBUG_RETURN(0); } @@ -13549,53 +13335,6 @@ int spider_mbase_handler::reset_sql( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_mbase_handler::reset_keys( - ulong sql_type -) { - DBUG_ENTER("spider_mbase_handler::reset_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_mbase_handler::reset_upds( - ulong sql_type -) { - DBUG_ENTER("spider_mbase_handler::reset_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_upds.clear(); - DBUG_RETURN(0); -} - -int spider_mbase_handler::reset_strs( - ulong sql_type -) { - DBUG_ENTER("spider_mbase_handler::reset_strs"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_mbase_handler::reset_strs_pos( - ulong sql_type -) { - DBUG_ENTER("spider_mbase_handler::reset_strs_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_mbase_handler::push_back_upds( - SPIDER_HS_STRING_REF &info -) { - int error_num; - DBUG_ENTER("spider_mbase_handler::push_back_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = hs_upds.push_back(info); - DBUG_RETURN(error_num); -} -#endif #ifdef SPIDER_HAS_GROUP_BY_HANDLER int spider_mbase_handler::set_sql_for_exec( diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 9e4d0e8f261..846289f54e7 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -560,54 +560,6 @@ public: uint binlog_pos_length, SPIDER_DB_RESULT **res ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key - ); - int append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key - ); - int append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - int append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key - ); - int append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key - ); - int append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - void reset_request_queue(); -#endif size_t escape_string( char *to, const char *from, @@ -798,9 +750,6 @@ protected: spider_string *exec_ha_sql; bool reading_from_bulk_tmp_table; bool filled_up; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_DB_HS_STRING_REF_BUFFER hs_upds; -#endif SPIDER_INT_HLD *union_table_name_pos_first; SPIDER_INT_HLD *union_table_name_pos_current; public: @@ -907,14 +856,6 @@ public: int append_delete( spider_string *str ); - #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_increment_update_set_part(); - int append_increment_update_set( - spider_string *str - ); - #endif - #endif int append_update_set_part(); int append_update_set( spider_string *str @@ -1445,23 +1386,6 @@ public: int reset_sql( ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int reset_keys( - ulong sql_type - ); - int reset_upds( - ulong sql_type - ); - int reset_strs( - ulong sql_type - ); - int reset_strs_pos( - ulong sql_type - ); - int push_back_upds( - SPIDER_HS_STRING_REF &info - ); -#endif #ifdef SPIDER_HAS_GROUP_BY_HANDLER int set_sql_for_exec( ulong sql_type, diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 3f64423f042..a452cd2c8dc 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -2249,96 +2249,6 @@ int spider_db_oracle::show_master_status( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_db_oracle::append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_sql"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_select"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_insert"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_update"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_db_oracle::append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key -) { - DBUG_ENTER("spider_db_oracle::append_delete"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -void spider_db_oracle::reset_request_queue() -{ - DBUG_ENTER("spider_db_oracle::reset_request_queue"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_VOID_RETURN; -} -#endif size_t spider_db_oracle::escape_string( char *to, @@ -5593,9 +5503,6 @@ int spider_oracle_handler::init() oracle_share->db_table_str_hash_value[roop_count]; #endif } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_upds.init(); -#endif DBUG_RETURN(0); } @@ -6364,77 +6271,6 @@ int spider_oracle_handler::append_delete( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -int spider_oracle_handler::append_increment_update_set_part() -{ - int error_num; - DBUG_ENTER("spider_oracle_handler::append_increment_update_set_part"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = append_increment_update_set(&update_sql); - DBUG_RETURN(error_num); -} - -int spider_oracle_handler::append_increment_update_set( - spider_string *str -) { - uint field_name_length; - uint roop_count; - Field *field; - DBUG_ENTER("spider_oracle_handler::append_increment_update_set"); - if (str->reserve(SPIDER_SQL_SET_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); - const SPIDER_HS_STRING_REF *value = hs_upds.ptr(); - for (roop_count = 0; roop_count < hs_upds.size(); - roop_count++) - { - DBUG_PRINT("info",("spider value_size[%u]=%zu", roop_count, - value[roop_count].size())); -#ifndef DBUG_OFF - char print_buf[MAX_FIELD_WIDTH]; - if (value[roop_count].size() < MAX_FIELD_WIDTH) - { - memcpy(print_buf, value[roop_count].begin(), value[roop_count].size()); - print_buf[value[roop_count].size()] = '\0'; - DBUG_PRINT("info",("spider value[%u]=%s", roop_count, print_buf)); - } -#endif - if ( - value[roop_count].size() == 1 && - *(value[roop_count].begin()) == '0' - ) - continue; - - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - field_name_length = - oracle_share->column_name_str[field->field_index].length(); - - if (str->reserve(field_name_length * 2 + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 4 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_HS_INCREMENT_LEN + - SPIDER_SQL_COMMA_LEN + value[roop_count].size())) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - - oracle_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - oracle_share->append_column_name(str, field->field_index); - if (spider->hs_increment) - str->q_append(SPIDER_SQL_HS_INCREMENT_STR, - SPIDER_SQL_HS_INCREMENT_LEN); - else - str->q_append(SPIDER_SQL_HS_DECREMENT_STR, - SPIDER_SQL_HS_DECREMENT_LEN); - str->q_append(value[roop_count].begin(), value[roop_count].size()); - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - str->length(str->length() - SPIDER_SQL_COMMA_LEN); - DBUG_RETURN(0); -} -#endif -#endif int spider_oracle_handler::append_update_set_part() { @@ -6520,13 +6356,6 @@ int spider_oracle_handler::append_direct_update_set_part() int spider_oracle_handler::append_direct_update_set( spider_string *str ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint field_name_length; - SPIDER_SHARE *share = spider->share; -#ifndef DBUG_OFF - TABLE *table = spider->get_table(); -#endif -#endif DBUG_ENTER("spider_oracle_handler::append_direct_update_set"); if ( spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && @@ -6541,61 +6370,7 @@ int spider_oracle_handler::append_direct_update_set( if ( (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - size_t roop_count; - Field *field; - if (str->reserve(SPIDER_SQL_SET_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - str->q_append(SPIDER_SQL_SET_STR, SPIDER_SQL_SET_LEN); - for (roop_count = 0; roop_count < spider->hs_pushed_ret_fields_num; - roop_count++) - { - Field *top_table_field = - spider->get_top_table_field(spider->hs_pushed_ret_fields[roop_count]); - if (!(field = spider->field_exchange(top_table_field))) - continue; - field_name_length = - oracle_share->column_name_str[field->field_index].length(); - if (top_table_field->is_null()) - { - if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 2 + SPIDER_SQL_EQUAL_LEN + SPIDER_SQL_NULL_LEN + - SPIDER_SQL_COMMA_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - oracle_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); - str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN); - } else { - if (str->reserve(field_name_length + /* SPIDER_SQL_NAME_QUOTE_LEN */ - 2 + SPIDER_SQL_EQUAL_LEN)) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - oracle_share->append_column_name(str, field->field_index); - str->q_append(SPIDER_SQL_EQUAL_STR, SPIDER_SQL_EQUAL_LEN); -#ifndef DBUG_OFF - my_bitmap_map *tmp_map = dbug_tmp_use_all_columns(table, - table->read_set); -#endif - if ( - spider_db_oracle_utility. - append_column_value(spider, str, top_table_field, NULL, - share->access_charset) || - str->reserve(SPIDER_SQL_COMMA_LEN) - ) { -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } -#ifndef DBUG_OFF - dbug_tmp_restore_column_map(table->read_set, tmp_map); -#endif - } - str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - } - str->length(str->length() - SPIDER_SQL_COMMA_LEN); -#else DBUG_ASSERT(0); -#endif } DBUG_RETURN(0); } @@ -10727,53 +10502,6 @@ int spider_oracle_handler::reset_sql( DBUG_RETURN(0); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -int spider_oracle_handler::reset_keys( - ulong sql_type -) { - DBUG_ENTER("spider_oracle_handler::reset_keys"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_oracle_handler::reset_upds( - ulong sql_type -) { - DBUG_ENTER("spider_oracle_handler::reset_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - hs_upds.clear(); - DBUG_RETURN(0); -} - -int spider_oracle_handler::reset_strs( - ulong sql_type -) { - DBUG_ENTER("spider_oracle_handler::reset_strs"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_oracle_handler::reset_strs_pos( - ulong sql_type -) { - DBUG_ENTER("spider_oracle_handler::reset_strs_pos"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_ASSERT(0); - DBUG_RETURN(0); -} - -int spider_oracle_handler::push_back_upds( - SPIDER_HS_STRING_REF &info -) { - int error_num; - DBUG_ENTER("spider_oracle_handler::push_back_upds"); - DBUG_PRINT("info",("spider this=%p", this)); - error_num = hs_upds.push_back(info); - DBUG_RETURN(error_num); -} -#endif bool spider_oracle_handler::need_lock_before_set_sql_for_exec( ulong sql_type diff --git a/storage/spider/spd_db_oracle.h b/storage/spider/spd_db_oracle.h index c8c1522599f..357fee35c67 100644 --- a/storage/spider/spd_db_oracle.h +++ b/storage/spider/spd_db_oracle.h @@ -473,54 +473,6 @@ public: SPIDER_DB_RESULT **res1, SPIDER_DB_RESULT **res2 ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int append_sql( - char *sql, - ulong sql_length, - st_spider_db_request_key *request_key - ); - int append_open_handler( - uint handler_id, - const char *db_name, - const char *table_name, - const char *index_name, - const char *sql, - st_spider_db_request_key *request_key - ); - int append_select( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - int append_insert( - uint handler_id, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - st_spider_db_request_key *request_key - ); - int append_update( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - SPIDER_DB_HS_STRING_REF_BUFFER *upds, - int limit, - int skip, - bool increment, - bool decrement, - st_spider_db_request_key *request_key - ); - int append_delete( - uint handler_id, - spider_string *sql, - SPIDER_DB_HS_STRING_REF_BUFFER *keys, - int limit, - int skip, - st_spider_db_request_key *request_key - ); - void reset_request_queue(); -#endif size_t escape_string( char *to, const char *from, @@ -685,9 +637,6 @@ private: bool filled_up; bool select_rownum_appended; bool update_rownum_appended; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_DB_HS_STRING_REF_BUFFER hs_upds; -#endif SPIDER_INT_HLD *union_table_name_pos_first; SPIDER_INT_HLD *union_table_name_pos_current; public: @@ -792,14 +741,6 @@ public: int append_delete( spider_string *str ); - #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - int append_increment_update_set_part(); - int append_increment_update_set( - spider_string *str - ); - #endif - #endif int append_update_set_part(); int append_update_set( spider_string *str @@ -1330,23 +1271,6 @@ public: int reset_sql( ulong sql_type ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int reset_keys( - ulong sql_type - ); - int reset_upds( - ulong sql_type - ); - int reset_strs( - ulong sql_type - ); - int reset_strs_pos( - ulong sql_type - ); - int push_back_upds( - SPIDER_HS_STRING_REF &info - ); -#endif bool need_lock_before_set_sql_for_exec( ulong sql_type ); diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 524e8b7443a..15b777ea739 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -197,54 +197,23 @@ int spider_udf_direct_sql_create_conn_key( spider_dbton[roop_count2].wrapper && !strcmp(direct_sql->tgt_wrapper, spider_dbton[roop_count2].wrapper) ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif if (spider_dbton[roop_count2].db_access_type == SPIDER_DB_ACCESS_TYPE_SQL) { direct_sql->dbton_id = roop_count2; break; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (spider_dbton[roop_count2].db_access_type == - SPIDER_DB_ACCESS_TYPE_NOSQL) - { - direct_sql->dbton_id = roop_count2; - break; - } - } -#endif } } if (direct_sql->dbton_id == SPIDER_DBTON_SIZE) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif my_printf_error( ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM, ER_SPIDER_SQL_WRAPPER_IS_INVALID_STR, MYF(0), direct_sql->tgt_wrapper); DBUG_RETURN(ER_SPIDER_SQL_WRAPPER_IS_INVALID_NUM); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - my_printf_error( - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM, - ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_STR, - MYF(0), direct_sql->tgt_wrapper); - DBUG_RETURN(ER_SPIDER_NOSQL_WRAPPER_IS_INVALID_NUM); - } -#endif } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif tables_on_different_db_are_joinable = spider_dbton[direct_sql->dbton_id].db_util-> tables_on_different_db_are_joinable(); @@ -267,16 +236,6 @@ int spider_udf_direct_sql_create_conn_key( + direct_sql->tgt_default_file_length + 1 + direct_sql->tgt_default_group_length + 1 + direct_sql->tgt_dsn_length; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - direct_sql->conn_key_length - = 1 - + direct_sql->tgt_wrapper_length + 1 - + direct_sql->tgt_host_length + 1 - + 5 + 1 - + direct_sql->tgt_socket_length; - } -#endif if (!(direct_sql->conn_key = (char *) spider_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_KEY_1, direct_sql->conn_key_length + 1, MYF(MY_WME | MY_ZEROFILL))) @@ -299,20 +258,16 @@ int spider_udf_direct_sql_create_conn_key( tmp_name = strmov(tmp_name + 1, direct_sql->tgt_socket); } else tmp_name++; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) + if (!tables_on_different_db_are_joinable) { -#endif - if (!tables_on_different_db_are_joinable) + if (direct_sql->tgt_default_db_name) { - if (direct_sql->tgt_default_db_name) - { - DBUG_PRINT("info",("spider tgt_default_db_name=%s", - direct_sql->tgt_default_db_name)); - tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_db_name); - } else - tmp_name++; - } + DBUG_PRINT("info",("spider tgt_default_db_name=%s", + direct_sql->tgt_default_db_name)); + tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_db_name); + } else + tmp_name++; + } if (direct_sql->tgt_username) { DBUG_PRINT("info",("spider tgt_username=%s", direct_sql->tgt_username)); @@ -380,9 +335,6 @@ int spider_udf_direct_sql_create_conn_key( tmp_name = strmov(tmp_name + 1, direct_sql->tgt_dsn); } else tmp_name++; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif #ifdef SPIDER_HAS_HASH_VALUE_TYPE direct_sql->conn_key_hash_value = my_calc_hash(&spider_open_connections, (uchar*) direct_sql->conn_key, direct_sql->conn_key_length); @@ -428,10 +380,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( UTC = my_tz_find(current_thd, &tz_00_name); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif tables_on_different_db_are_joinable = spider_dbton[direct_sql->dbton_id].db_util-> tables_on_different_db_are_joinable(); @@ -464,24 +412,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( goto error_alloc_conn; } conn->default_database.init_calc_mem(SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_2); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - if (!(conn = (SPIDER_CONN *) - spider_bulk_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_3, MYF(MY_WME | MY_ZEROFILL), - &conn, (uint) (sizeof(*conn)), - &tmp_name, (uint) (direct_sql->conn_key_length + 1), - &tmp_host, (uint) (direct_sql->tgt_host_length + 1), - &tmp_socket, (uint) (direct_sql->tgt_socket_length + 1), - &tmp_wrapper, (uint) (direct_sql->tgt_wrapper_length + 1), - &need_mon, (uint) (sizeof(int)), - NullS)) - ) { - *error_num = HA_ERR_OUT_OF_MEM; - goto error_alloc_conn; - } - conn->default_database.init_calc_mem(SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_4); - } -#endif conn->conn_key_length = direct_sql->conn_key_length; conn->conn_key = tmp_name; @@ -493,10 +423,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( conn->tgt_host_length = direct_sql->tgt_host_length; conn->tgt_host = tmp_host; memcpy(conn->tgt_host, direct_sql->tgt_host, direct_sql->tgt_host_length); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif conn->tgt_port = direct_sql->tgt_port; spider_maybe_memcpy_string( &conn->tgt_socket, direct_sql->tgt_socket, tmp_socket, @@ -536,18 +462,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( &conn->tgt_dsn, direct_sql->tgt_dsn, tmp_dsn, &conn->tgt_dsn_length, direct_sql->tgt_dsn_length); conn->tgt_ssl_vsc = direct_sql->tgt_ssl_vsc; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - conn->hs_port = direct_sql->tgt_port; - if (direct_sql->tgt_socket) - { - conn->hs_sock_length = direct_sql->tgt_socket_length; - conn->hs_sock = tmp_socket; - memcpy(conn->hs_sock, direct_sql->tgt_socket, - direct_sql->tgt_socket_length); - } - } -#endif conn->dbton_id = direct_sql->dbton_id; conn->conn_need_mon = need_mon; conn->need_mon = need_mon; @@ -566,19 +480,7 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( conn->semi_trx_isolation = -2; conn->semi_trx_isolation_chk = FALSE; conn->semi_trx_chk = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif conn->conn_kind = SPIDER_CONN_KIND_MYSQL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (direct_sql->access_mode == 1) - { - conn->conn_kind = SPIDER_CONN_KIND_HS_READ; - } else { - conn->conn_kind = SPIDER_CONN_KIND_HS_WRITE; - } -#endif if (mysql_mutex_init(spd_key_mutex_mta_conn, &conn->mta_conn_mutex, MY_MUTEX_INIT_FAST)) @@ -665,82 +567,26 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( ) { SPIDER_CONN *conn = NULL; DBUG_ENTER("spider_udf_direct_sql_get_conn"); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - DBUG_PRINT("info",("spider direct_sql->access_mode=%d", - direct_sql->access_mode)); -#endif #ifdef SPIDER_HAS_HASH_VALUE_TYPE if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (direct_sql->access_mode == 0 && -#endif !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &trx->trx_conn_hash, direct_sql->conn_key_hash_value, (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (direct_sql->access_mode == 1 && - !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &trx->trx_direct_hs_r_conn_hash, direct_sql->conn_key_hash_value, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) - ) || - (direct_sql->access_mode == 2 && - !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &trx->trx_direct_hs_w_conn_hash, direct_sql->conn_key_hash_value, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) - ) -#endif ) #else if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (direct_sql->access_mode == 0 && -#endif !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_conn_hash, (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (direct_sql->access_mode == 1 && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_direct_hs_r_conn_hash, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) - ) || - (direct_sql->access_mode == 2 && - !(conn = (SPIDER_CONN*) my_hash_search(&trx->trx_direct_hs_w_conn_hash, - (uchar*) direct_sql->conn_key, direct_sql->conn_key_length)) - ) -#endif ) #endif { if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (direct_sql->access_mode == 0 && -#endif ( (spider_param_conn_recycle_mode(trx->thd) & 1) || spider_param_conn_recycle_strict(trx->thd) ) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (direct_sql->access_mode == 1 && - ( - (spider_param_hs_r_conn_recycle_mode(trx->thd) & 1) || - spider_param_hs_r_conn_recycle_strict(trx->thd) - ) - ) || - (direct_sql->access_mode == 2 && - ( - (spider_param_hs_w_conn_recycle_mode(trx->thd) & 1) || - spider_param_hs_w_conn_recycle_strict(trx->thd) - ) - ) -#endif ) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif pthread_mutex_lock(&spider_conn_mutex); #ifdef SPIDER_HAS_HASH_VALUE_TYPE if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( @@ -766,9 +612,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( pthread_mutex_unlock(&spider_conn_mutex); DBUG_PRINT("info",("spider get global conn")); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif } else { DBUG_PRINT("info",("spider create new conn")); /* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */ @@ -778,10 +621,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( conn->thd = trx->thd; conn->priority = direct_sql->priority; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 0) - { -#endif uint old_elements = trx->trx_conn_hash.array.max_element; #ifdef HASH_UPDATE_WITH_HASH_VALUE if (my_hash_insert_with_hash_value(&trx->trx_conn_hash, @@ -801,50 +640,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn( (trx->trx_conn_hash.array.max_element - old_elements) * trx->trx_conn_hash.array.size_of_element); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (direct_sql->access_mode == 1) - { - uint old_elements = trx->trx_direct_hs_r_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_direct_hs_r_conn_hash, - direct_sql->conn_key_hash_value, (uchar*) conn)) -#else - if (my_hash_insert(&trx->trx_direct_hs_r_conn_hash, (uchar*) conn)) -#endif - { - spider_free_conn(conn); - *error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - if (trx->trx_direct_hs_r_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - trx->trx_direct_hs_r_conn_hash, - (trx->trx_direct_hs_r_conn_hash.array.max_element - old_elements) * - trx->trx_direct_hs_r_conn_hash.array.size_of_element); - } - } else { - uint old_elements = trx->trx_direct_hs_w_conn_hash.array.max_element; -#ifdef HASH_UPDATE_WITH_HASH_VALUE - if (my_hash_insert_with_hash_value(&trx->trx_direct_hs_w_conn_hash, - direct_sql->conn_key_hash_value, (uchar*) conn)) -#else - if (my_hash_insert(&trx->trx_direct_hs_w_conn_hash, (uchar*) conn)) -#endif - { - spider_free_conn(conn); - *error_num = HA_ERR_OUT_OF_MEM; - goto error; - } - if (trx->trx_direct_hs_w_conn_hash.array.max_element > old_elements) - { - spider_alloc_calc_mem(spider_current_trx, - trx->trx_direct_hs_w_conn_hash, - (trx->trx_direct_hs_w_conn_hash.array.max_element - old_elements) * - trx->trx_direct_hs_w_conn_hash.array.size_of_element); - } - } -#endif } if (conn->queued_connect) @@ -1080,9 +875,6 @@ static void spider_minus_1(SPIDER_DIRECT_SQL *direct_sql) direct_sql->net_write_timeout = -1; direct_sql->bulk_insert_rows = -1; direct_sql->connection_channel = -1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - direct_sql->access_mode = -1; -#endif direct_sql->use_real_table = -1; direct_sql->error_rw_mode = -1; for (int i = 0; i < direct_sql->table_count; i++) @@ -1133,9 +925,6 @@ int spider_udf_parse_direct_sql_param( error_num= parse.fail(true); goto error; case 3: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_INT_WITH_MAX("acm", access_mode, 0, 2); -#endif SPIDER_PARAM_LONGLONG("bir", bulk_insert_rows, 0); SPIDER_PARAM_INT_WITH_MAX("cch", connection_channel, 0, 63); SPIDER_PARAM_INT("cto", connect_timeout, 0); @@ -1188,9 +977,6 @@ int spider_udf_parse_direct_sql_param( error_num= parse.fail(true); goto error; case 11: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_INT_WITH_MAX("access_mode", access_mode, 0, 2); -#endif error_num= parse.fail(true); goto error; case 12: @@ -1263,9 +1049,6 @@ int spider_udf_set_direct_sql_param_default( } if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - direct_sql->access_mode == 0 && -#endif !direct_sql->tgt_socket && (!direct_sql->tgt_host || !strcmp(direct_sql->tgt_host, my_localhost)) ) { @@ -1392,20 +1175,9 @@ int spider_udf_set_direct_sql_param_default( } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == -1) - direct_sql->access_mode = 0; -#endif if (direct_sql->tgt_port == -1) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (direct_sql->access_mode == 1) - direct_sql->tgt_port = 9998; - else if (direct_sql->access_mode == 2) - direct_sql->tgt_port = 9999; - else -#endif direct_sql->tgt_port = MYSQL_PORT; } else if (direct_sql->tgt_port < 0) @@ -1640,15 +1412,8 @@ long long spider_direct_sql_body( goto error; } } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (trx->trx_start && direct_sql->access_mode != 1) - { -#endif trx->updated_in_this_trx = TRUE; DBUG_PRINT("info",("spider trx->updated_in_this_trx=TRUE")); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } -#endif use_real_table = spider_param_udf_ds_use_real_table(thd, direct_sql->use_real_table); for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index d6525b7b730..09482b276e8 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -611,11 +611,6 @@ typedef struct st_spider_conn #endif int link_idx; spider_db_conn *db_conn; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - query_id_t hsc_query_id; - ulonglong hs_pre_age; - ulonglong hs_age; -#endif uint opened_handlers; ulonglong conn_id; ulonglong connection_id; @@ -687,10 +682,6 @@ typedef struct st_spider_conn char *tgt_dsn; long tgt_port; long tgt_ssl_vsc; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char *hs_sock; - long hs_port; -#endif uint tgt_host_length; uint tgt_username_length; @@ -706,9 +697,6 @@ typedef struct st_spider_conn uint tgt_default_file_length; uint tgt_default_group_length; uint tgt_dsn_length; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint hs_sock_length; -#endif uint dbton_id; #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -898,11 +886,6 @@ typedef struct st_spider_wide_handler uchar *rnd_write_bitmap; SPIDER_CONDITION *condition; void *owner; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uint32 *hs_pushed_ret_fields; -#endif -#endif #ifdef WITH_PARTITION_STORAGE_ENGINE SPIDER_PARTITION_HANDLER *partition_handler; #endif @@ -913,11 +896,6 @@ typedef struct st_spider_wide_handler TABLE_SHARE *top_share; enum thr_lock_type lock_type; uchar lock_table_type; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uint32 hs_pushed_strref_num; -#endif -#endif int lock_mode; int external_lock_type; int cond_check_error; @@ -930,13 +908,6 @@ typedef struct st_spider_wide_handler #endif #ifdef HA_CAN_BULK_ACCESS ulonglong external_lock_cnt; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - size_t hs_pushed_ret_fields_num; - size_t hs_pushed_ret_fields_size; - size_t hs_pushed_lcl_fields_num; -#endif #endif bool between_flg; bool idx_bitmap_is_set; @@ -954,12 +925,6 @@ typedef struct st_spider_wide_handler bool write_can_replace; bool insert_with_update; bool cond_check; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - bool hs_increment; - bool hs_decrement; -#endif -#endif bool semi_table_lock; } SPIDER_WIDE_HANDLER; @@ -995,30 +960,6 @@ typedef struct st_spider_transaction const char *trx_another_conn_hash_func_name; const char *trx_another_conn_hash_file_name; ulong trx_another_conn_hash_line_no; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - HASH trx_hs_r_conn_hash; - uint trx_hs_r_conn_hash_id; - const char *trx_hs_r_conn_hash_func_name; - const char *trx_hs_r_conn_hash_file_name; - ulong trx_hs_r_conn_hash_line_no; - HASH trx_hs_w_conn_hash; - uint trx_hs_w_conn_hash_id; - const char *trx_hs_w_conn_hash_func_name; - const char *trx_hs_w_conn_hash_file_name; - ulong trx_hs_w_conn_hash_line_no; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - HASH trx_direct_hs_r_conn_hash; - uint trx_direct_hs_r_conn_hash_id; - const char *trx_direct_hs_r_conn_hash_func_name; - const char *trx_direct_hs_r_conn_hash_file_name; - ulong trx_direct_hs_r_conn_hash_line_no; - HASH trx_direct_hs_w_conn_hash; - uint trx_direct_hs_w_conn_hash_id; - const char *trx_direct_hs_w_conn_hash_func_name; - const char *trx_direct_hs_w_conn_hash_file_name; - ulong trx_direct_hs_w_conn_hash_line_no; -#endif HASH trx_alter_table_hash; uint trx_alter_table_hash_id; const char *trx_alter_table_hash_func_name; @@ -1034,10 +975,6 @@ typedef struct st_spider_transaction SPIDER_CONN *join_trx_top; ulonglong spider_thread_id; ulonglong trx_conn_adjustment; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ulonglong trx_hs_r_conn_adjustment; - ulonglong trx_hs_w_conn_adjustment; -#endif uint locked_connections; ulonglong direct_update_count; @@ -1045,9 +982,6 @@ typedef struct st_spider_transaction ulonglong direct_order_limit_count; ulonglong direct_aggregate_count; ulonglong parallel_search_count; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ulonglong hs_result_free_count; -#endif #ifdef HA_CAN_BULK_ACCESS SPIDER_CONN *bulk_access_conn_first; @@ -1263,9 +1197,6 @@ typedef struct st_spider_share int error_read_mode; int error_write_mode; int active_link_count; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - longlong hs_result_free_size; -#endif #ifdef HA_CAN_BULK_ACCESS int bulk_access_free; #endif @@ -1284,10 +1215,6 @@ typedef struct st_spider_share #ifdef SPIDER_HAS_HASH_VALUE_TYPE my_hash_value_type *conn_keys_hash_value; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - my_hash_value_type *hs_read_conn_keys_hash_value; - my_hash_value_type *hs_write_conn_keys_hash_value; -#endif #endif char **server_names; char **tgt_table_names; @@ -1309,12 +1236,6 @@ typedef struct st_spider_share char **tgt_pk_names; char **tgt_sequence_names; char **conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_read_socks; - char **hs_write_socks; - char **hs_read_conn_keys; - char **hs_write_conn_keys; -#endif long *tgt_ports; long *tgt_ssl_vscs; long *link_statuses; @@ -1330,13 +1251,6 @@ typedef struct st_spider_share #endif longlong *monitoring_limit; longlong *monitoring_sid; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - long *use_hs_reads; - long *use_hs_writes; - long *hs_read_ports; - long *hs_write_ports; - long *hs_write_to_reads; -#endif long *use_handlers; long *connect_timeouts; long *net_read_timeouts; @@ -1365,17 +1279,8 @@ typedef struct st_spider_share uint *tgt_pk_names_lengths; uint *tgt_sequence_names_lengths; uint *conn_keys_lengths; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint *hs_read_socks_lengths; - uint *hs_write_socks_lengths; - uint *hs_read_conn_keys_lengths; - uint *hs_write_conn_keys_lengths; -#endif /* The index in `spider_dbton' of each data node link. */ uint *sql_dbton_ids; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint *hs_dbton_ids; -#endif uint server_names_charlen; uint tgt_table_names_charlen; @@ -1397,12 +1302,6 @@ typedef struct st_spider_share uint tgt_pk_names_charlen; uint tgt_sequence_names_charlen; uint conn_keys_charlen; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint hs_read_socks_charlen; - uint hs_write_socks_charlen; - uint hs_read_conn_keys_charlen; - uint hs_write_conn_keys_charlen; -#endif uint server_names_length; uint tgt_table_names_length; @@ -1424,12 +1323,6 @@ typedef struct st_spider_share uint tgt_pk_names_length; uint tgt_sequence_names_length; uint conn_keys_length; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint hs_read_socks_length; - uint hs_write_socks_length; - uint hs_read_conn_keys_length; - uint hs_write_conn_keys_length; -#endif uint tgt_ports_length; uint tgt_ssl_vscs_length; uint link_statuses_length; @@ -1445,13 +1338,6 @@ typedef struct st_spider_share #endif uint monitoring_limit_length; uint monitoring_sid_length; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint use_hs_reads_length; - uint use_hs_writes_length; - uint hs_read_ports_length; - uint hs_write_ports_length; - uint hs_write_to_reads_length; -#endif uint use_handlers_length; uint connect_timeouts_length; uint net_read_timeouts_length; @@ -1475,14 +1361,6 @@ typedef struct st_spider_share uint use_sql_dbton_ids[SPIDER_DBTON_SIZE]; /* Inverse map of `use_sql_dbton_ids'. */ uint sql_dbton_id_to_seq[SPIDER_DBTON_SIZE]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint use_hs_dbton_count; - /* Actual size is `use_hs_dbton_count'. Values are the indices of - item in `spider_dbton'. */ - uint use_hs_dbton_ids[SPIDER_DBTON_SIZE]; - /* Inverse map of `use_hs_dbton_ids'. */ - uint hs_dbton_id_to_seq[SPIDER_DBTON_SIZE]; -#endif SPIDER_ALTER_TABLE alter_table; SPIDER_WIDE_SHARE *wide_share; @@ -1538,9 +1416,6 @@ typedef struct st_spider_direct_sql int net_write_timeout; longlong bulk_insert_rows; int connection_channel; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - int access_mode; -#endif int use_real_table; int error_rw_mode; diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index db3c958c955..12080cc2a27 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -171,19 +171,6 @@ static int spider_parallel_search(THD *thd, SHOW_VAR *var, void *, DBUG_RETURN(error_num); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -static int spider_hs_result_free(THD *thd, SHOW_VAR *var, void *, - system_status_var *, enum_var_type) -{ - int error_num = 0; - SPIDER_TRX *trx; - DBUG_ENTER("spider_hs_result_free"); - var->type = SHOW_LONGLONG; - if ((trx = spider_get_trx(thd, TRUE, &error_num))) - var->value = (char *) &trx->hs_result_free_count; - DBUG_RETURN(error_num); -} -#endif struct st_mysql_show_var spider_status_variables[] = { @@ -214,13 +201,6 @@ struct st_mysql_show_var spider_status_variables[] = (char *) &spider_direct_aggregate, SHOW_FUNC}, {"Spider_parallel_search", (char *) &spider_parallel_search, SHOW_FUNC}, -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC - {"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_SIMPLE_FUNC}, -#else - {"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_FUNC}, -#endif #endif {NullS, NullS, SHOW_LONG} }; @@ -582,25 +562,6 @@ static MYSQL_THDVAR_INT( SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, reset_sql_alloc) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -/* - -1 :fallback to default - 0-:result free size for handlersocket - */ -static MYSQL_THDVAR_LONGLONG( - hs_result_free_size, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Result free size for handlersocket", /* comment */ - NULL, /* check */ - NULL, /* update */ - 1048576, /* def */ - -1, /* min */ - 9223372036854775807LL, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_OVERRIDE_VALUE_FUN(longlong, hs_result_free_size) -#endif /* -1 :fallback to default @@ -1536,25 +1497,6 @@ static MYSQL_THDVAR_INT( SPIDER_THDVAR_VALUE_FUNC(double, ping_interval_at_trx_start) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -/* - 0 :always ping - 1-:interval - */ -static MYSQL_THDVAR_INT( - hs_ping_interval, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Ping interval for handlersocket", /* comment */ - NULL, /* check */ - NULL, /* update */ - 30, /* def */ - 0, /* min */ - 2147483647, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(double, hs_ping_interval) -#endif /* -1 :fallback to default @@ -1960,119 +1902,6 @@ static MYSQL_SYSVAR_LONGLONG( SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(longlong, udf_ct_bulk_insert_rows) -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -/* - 0: no recycle - 1: recycle in instance - 2: recycle in thread - */ -static MYSQL_THDVAR_UINT( - hs_r_conn_recycle_mode, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Handlersocket connection recycle mode", /* comment */ - NULL, /* check */ - NULL, /* update */ - 2, /* def */ - 0, /* min */ - 2, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(uint, hs_r_conn_recycle_mode) - -/* - 0: weak - 1: strict - */ -static MYSQL_THDVAR_UINT( - hs_r_conn_recycle_strict, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Strict handlersocket connection recycle", /* comment */ - NULL, /* check */ - NULL, /* update */ - 0, /* def */ - 0, /* min */ - 1, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(uint, hs_r_conn_recycle_strict) - -/* - 0: no recycle - 1: recycle in instance - 2: recycle in thread - */ -static MYSQL_THDVAR_UINT( - hs_w_conn_recycle_mode, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Handlersocket connection recycle mode", /* comment */ - NULL, /* check */ - NULL, /* update */ - 2, /* def */ - 0, /* min */ - 2, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(uint, hs_w_conn_recycle_mode) - -/* - 0: weak - 1: strict - */ -static MYSQL_THDVAR_UINT( - hs_w_conn_recycle_strict, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Strict handlersocket connection recycle", /* comment */ - NULL, /* check */ - NULL, /* update */ - 0, /* def */ - 0, /* min */ - 1, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_VALUE_FUNC(uint, hs_w_conn_recycle_strict) - -/* - -1 :fallback to default - 0 :not use - 1 :use handlersocket - */ -static MYSQL_THDVAR_INT( - use_hs_read, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Use handlersocket for reading", /* comment */ - NULL, /* check */ - NULL, /* update */ - 0, /* def */ - -1, /* min */ - 1, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_OVERRIDE_VALUE_FUN(int, use_hs_read) - -/* - -1 :fallback to default - 0 :not use - 1 :use handlersocket - */ -static MYSQL_THDVAR_INT( - use_hs_write, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ - "Use handlersocket for writing", /* comment */ - NULL, /* check */ - NULL, /* update */ - 0, /* def */ - -1, /* min */ - 1, /* max */ - 0 /* blk */ -); - -SPIDER_THDVAR_OVERRIDE_VALUE_FUN(int, use_hs_write) -#endif /* -1 :fallback to default @@ -2744,9 +2573,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(semi_split_read_limit), MYSQL_SYSVAR(init_sql_alloc_size), MYSQL_SYSVAR(reset_sql_alloc), -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - MYSQL_SYSVAR(hs_result_free_size), -#endif MYSQL_SYSVAR(multi_split_read), MYSQL_SYSVAR(max_order), MYSQL_SYSVAR(semi_trx_isolation), @@ -2807,9 +2633,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(sts_bg_mode), #endif MYSQL_SYSVAR(ping_interval_at_trx_start), -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - MYSQL_SYSVAR(hs_ping_interval), -#endif MYSQL_SYSVAR(auto_increment_mode), MYSQL_SYSVAR(same_server_link), MYSQL_SYSVAR(local_lock_table), @@ -2832,14 +2655,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(bka_mode), MYSQL_SYSVAR(udf_ct_bulk_insert_interval), MYSQL_SYSVAR(udf_ct_bulk_insert_rows), -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - MYSQL_SYSVAR(hs_r_conn_recycle_mode), - MYSQL_SYSVAR(hs_r_conn_recycle_strict), - MYSQL_SYSVAR(hs_w_conn_recycle_mode), - MYSQL_SYSVAR(hs_w_conn_recycle_strict), - MYSQL_SYSVAR(use_hs_read), - MYSQL_SYSVAR(use_hs_write), -#endif MYSQL_SYSVAR(use_handler), MYSQL_SYSVAR(error_read_mode), MYSQL_SYSVAR(error_write_mode), diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h index e4ea26c610f..d7d35b17df5 100644 --- a/storage/spider/spd_param.h +++ b/storage/spider/spd_param.h @@ -73,12 +73,6 @@ int spider_param_reset_sql_alloc( THD *thd, int reset_sql_alloc ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -longlong spider_param_hs_result_free_size( - THD *thd, - longlong hs_result_free_size -); -#endif int spider_param_multi_split_read( THD *thd, int multi_split_read @@ -261,11 +255,6 @@ int spider_param_sts_bg_mode( double spider_param_ping_interval_at_trx_start( THD *thd ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -double spider_param_hs_ping_interval( - THD *thd -); -#endif int spider_param_auto_increment_mode( THD *thd, int auto_increment_mode @@ -320,28 +309,6 @@ int spider_param_udf_ct_bulk_insert_interval( longlong spider_param_udf_ct_bulk_insert_rows( longlong udf_ct_bulk_insert_rows ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -uint spider_param_hs_r_conn_recycle_mode( - THD *thd -); -uint spider_param_hs_r_conn_recycle_strict( - THD *thd -); -uint spider_param_hs_w_conn_recycle_mode( - THD *thd -); -uint spider_param_hs_w_conn_recycle_strict( - THD *thd -); -int spider_param_use_hs_read( - THD *thd, - int use_hs_read -); -int spider_param_use_hs_write( - THD *thd, - int use_hs_write -); -#endif int spider_param_use_handler( THD *thd, int use_handler diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 9a2f41ca658..5c1c0d27820 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -129,9 +129,6 @@ handlerton *spider_hton_ptr; SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; extern SPIDER_DBTON spider_dbton_mysql; extern SPIDER_DBTON spider_dbton_mariadb; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -extern SPIDER_DBTON spider_dbton_handlersocket; -#endif #ifdef HAVE_ORACLE_OCI extern SPIDER_DBTON spider_dbton_oracle; #endif @@ -153,10 +150,6 @@ PSI_mutex_key spd_key_mutex_wide_share; #endif PSI_mutex_key spd_key_mutex_lgtm_tblhnd_share; PSI_mutex_key spd_key_mutex_conn; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -PSI_mutex_key spd_key_mutex_hs_r_conn; -PSI_mutex_key spd_key_mutex_hs_w_conn; -#endif PSI_mutex_key spd_key_mutex_open_conn; PSI_mutex_key spd_key_mutex_allocated_thds; PSI_mutex_key spd_key_mutex_mon_table_cache; @@ -203,10 +196,6 @@ static PSI_mutex_info all_spider_mutexes[]= #endif { &spd_key_mutex_lgtm_tblhnd_share, "lgtm_tblhnd_share", PSI_FLAG_GLOBAL}, { &spd_key_mutex_conn, "conn", PSI_FLAG_GLOBAL}, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - { &spd_key_mutex_hs_r_conn, "hs_r_conn", PSI_FLAG_GLOBAL}, - { &spd_key_mutex_hs_w_conn, "hs_w_conn", PSI_FLAG_GLOBAL}, -#endif { &spd_key_mutex_open_conn, "open_conn", PSI_FLAG_GLOBAL}, { &spd_key_mutex_allocated_thds, "allocated_thds", PSI_FLAG_GLOBAL}, { &spd_key_mutex_mon_table_cache, "mon_table_cache", PSI_FLAG_GLOBAL}, @@ -315,20 +304,6 @@ extern const char *spider_open_connections_func_name; extern const char *spider_open_connections_file_name; extern ulong spider_open_connections_line_no; extern pthread_mutex_t spider_conn_mutex; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -extern HASH spider_hs_r_conn_hash; -extern uint spider_hs_r_conn_hash_id; -extern const char *spider_hs_r_conn_hash_func_name; -extern const char *spider_hs_r_conn_hash_file_name; -extern ulong spider_hs_r_conn_hash_line_no; -extern pthread_mutex_t spider_hs_r_conn_mutex; -extern HASH spider_hs_w_conn_hash; -extern uint spider_hs_w_conn_hash_id; -extern const char *spider_hs_w_conn_hash_func_name; -extern const char *spider_hs_w_conn_hash_file_name; -extern ulong spider_hs_w_conn_hash_line_no; -extern pthread_mutex_t spider_hs_w_conn_mutex; -#endif extern HASH *spider_udf_table_mon_list_hash; extern uint spider_udf_table_mon_list_hash_id; extern const char *spider_udf_table_mon_list_hash_func_name; @@ -826,30 +801,6 @@ int spider_free_share_alloc( } spider_free(spider_current_trx, share->static_link_ids, MYF(0)); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->hs_read_socks) - { - for (roop_count = 0; roop_count < (int) share->hs_read_socks_length; - roop_count++) - { - if (share->hs_read_socks[roop_count]) - spider_free(spider_current_trx, share->hs_read_socks[roop_count], - MYF(0)); - } - spider_free(spider_current_trx, share->hs_read_socks, MYF(0)); - } - if (share->hs_write_socks) - { - for (roop_count = 0; roop_count < (int) share->hs_write_socks_length; - roop_count++) - { - if (share->hs_write_socks[roop_count]) - spider_free(spider_current_trx, share->hs_write_socks[roop_count], - MYF(0)); - } - spider_free(spider_current_trx, share->hs_write_socks, MYF(0)); - } -#endif if (share->bka_engine) spider_free(spider_current_trx, share->bka_engine, MYF(0)); if (share->conn_keys) @@ -872,18 +823,6 @@ int spider_free_share_alloc( spider_free(spider_current_trx, share->monitoring_flag, MYF(0)); if (share->monitoring_kind) spider_free(spider_current_trx, share->monitoring_kind, MYF(0)); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->use_hs_reads) - spider_free(spider_current_trx, share->use_hs_reads, MYF(0)); - if (share->use_hs_writes) - spider_free(spider_current_trx, share->use_hs_writes, MYF(0)); - if (share->hs_read_ports) - spider_free(spider_current_trx, share->hs_read_ports, MYF(0)); - if (share->hs_write_ports) - spider_free(spider_current_trx, share->hs_write_ports, MYF(0)); - if (share->hs_write_to_reads) - spider_free(spider_current_trx, share->hs_write_to_reads, MYF(0)); -#endif if (share->use_handlers) spider_free(spider_current_trx, share->use_handlers, MYF(0)); if (share->connect_timeouts) @@ -1018,18 +957,6 @@ void spider_free_tmp_share_alloc( spider_free(spider_current_trx, share->static_link_ids[0], MYF(0)); share->static_link_ids[0] = NULL; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->hs_read_socks && share->hs_read_socks[0]) - { - spider_free(spider_current_trx, share->hs_read_socks[0], MYF(0)); - share->hs_read_socks[0] = NULL; - } - if (share->hs_write_socks && share->hs_write_socks[0]) - { - spider_free(spider_current_trx, share->hs_write_socks[0], MYF(0)); - share->hs_write_socks[0] = NULL; - } -#endif if (share->bka_engine) { spider_free(spider_current_trx, share->bka_engine, MYF(0)); @@ -1913,9 +1840,6 @@ static void spider_minus_1(SPIDER_SHARE *share, TABLE_SHARE *table_share) share->error_read_mode = -1; share->error_write_mode = -1; share->active_link_count = -1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->hs_result_free_size = -1; -#endif #ifdef HA_CAN_BULK_ACCESS share->bulk_access_free = -1; #endif @@ -2286,17 +2210,6 @@ int spider_parse_connect_info( SPIDER_PARAM_INT_WITH_MAX("fbu", force_bulk_update, 0, 1); #endif SPIDER_PARAM_LONGLONG("frd", first_read, 0); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONGLONG("hrf", hs_result_free_size, 0); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hrp", hs_read_ports, 0, 65535); - SPIDER_PARAM_STR_LIST("hrs", hs_read_socks); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hwp", hs_write_ports, 0, 65535); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hwr", hs_write_to_reads, 0, 1); - SPIDER_PARAM_STR_LIST("hws", hs_write_socks); -#endif SPIDER_PARAM_INT("isa", init_sql_alloc_size, 0); SPIDER_PARAM_LONGLONG("ilm", internal_limit, 0); SPIDER_PARAM_LONGLONG("ios", internal_offset, 0); @@ -2371,12 +2284,6 @@ int spider_parse_connect_info( SPIDER_PARAM_STR_LIST("tbl", tgt_table_names); SPIDER_PARAM_INT_WITH_MAX("tcm", table_count_mode, 0, 3); SPIDER_PARAM_LONG_LIST_WITH_MAX("uhd", use_handlers, 0, 3); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "uhr", use_hs_reads, 0, 1); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "uhw", use_hs_writes, 0, 1); -#endif SPIDER_PARAM_INT_WITH_MAX("upu", use_pushdown_udf, 0, 1); SPIDER_PARAM_INT_WITH_MAX("utc", use_table_charset, 0, 1); error_num = parse.fail(true); @@ -2452,9 +2359,6 @@ int spider_parse_connect_info( #endif SPIDER_PARAM_LONG_LIST_WITH_MAX("link_status", link_statuses, 0, 3); SPIDER_PARAM_LONG_LIST_WITH_MAX("use_handler", use_handlers, 0, 3); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX("use_hs_read", use_hs_reads, 0, 1); -#endif SPIDER_PARAM_INT_WITH_MAX("casual_read", casual_read, 0, 63); SPIDER_PARAM_INT("buffer_size", buffer_size, 0); error_num = parse.fail(true); @@ -2464,20 +2368,10 @@ int spider_parse_connect_info( SPIDER_PARAM_DOUBLE("crd_interval", crd_interval, 0); SPIDER_PARAM_INT_WITH_MAX("low_mem_read", low_mem_read, 0, 1); SPIDER_PARAM_STR_LIST("default_file", tgt_default_files); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "use_hs_write", use_hs_writes, 0, 1); - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hs_read_port", hs_read_ports, 0, 65535); -#endif error_num = parse.fail(true); goto error; case 13: SPIDER_PARAM_STR_LIST("default_group", tgt_default_groups); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hs_write_port", hs_write_ports, 0, 65535); -#endif SPIDER_PARAM_STR_LIST("sequence_name", tgt_sequence_names); error_num = parse.fail(true); goto error; @@ -2485,10 +2379,6 @@ int spider_parse_connect_info( SPIDER_PARAM_LONGLONG("internal_limit", internal_limit, 0); #ifndef WITHOUT_SPIDER_BG_SEARCH SPIDER_PARAM_LONGLONG("bgs_first_read", bgs_first_read, 0); -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_STR_LIST( - "hs_read_socket", hs_read_socks); #endif SPIDER_PARAM_INT_WITH_MAX("read_only_mode", read_only_mode, 0, 1); SPIDER_PARAM_LONG_LIST_WITH_MAX("access_balance", access_balances, 0, @@ -2510,10 +2400,6 @@ int spider_parse_connect_info( SPIDER_PARAM_LONG_LIST_WITH_MAX("monitoring_flag", monitoring_flag, 0, 1); SPIDER_PARAM_LONG_LIST_WITH_MAX("monitoring_kind", monitoring_kind, 0, 3); SPIDER_PARAM_DOUBLE("semi_split_read", semi_split_read, 0); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_STR_LIST( - "hs_write_socket", hs_write_socks); -#endif SPIDER_PARAM_LONG_LIST_WITH_MAX("connect_timeout", connect_timeouts, 0, 2147483647); SPIDER_PARAM_LONG_LIST_WITH_MAX("strict_group_by", @@ -2537,10 +2423,6 @@ int spider_parse_connect_info( SPIDER_PARAM_INT("bulk_update_size", bulk_update_size, 0); SPIDER_PARAM_LONG_LIST_WITH_MAX("net_read_timeout", net_read_timeouts, 0, 2147483647); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONG_LIST_WITH_MAX( - "hs_write_to_read", hs_write_to_reads, 0, 1); -#endif SPIDER_PARAM_INT_WITH_MAX( "error_write_mode", error_write_mode, 0, 1); #ifdef HA_CAN_BULK_ACCESS @@ -2588,9 +2470,6 @@ int spider_parse_connect_info( SPIDER_PARAM_INT("init_sql_alloc_size", init_sql_alloc_size, 0); SPIDER_PARAM_INT_WITH_MAX( "auto_increment_mode", auto_increment_mode, 0, 3); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - SPIDER_PARAM_LONGLONG("hs_result_free_size", hs_result_free_size, 0); -#endif SPIDER_PARAM_LONG_LIST_WITH_MAX("bka_table_name_type", bka_table_name_types, 0, 1); SPIDER_PARAM_INT_WITH_MAX( @@ -2720,22 +2599,6 @@ int spider_parse_connect_info( share->all_link_count = share->monitoring_bg_kind_length; if (share->all_link_count < share->monitoring_bg_interval_length) share->all_link_count = share->monitoring_bg_interval_length; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->all_link_count < share->use_hs_reads_length) - share->all_link_count = share->use_hs_reads_length; - if (share->all_link_count < share->use_hs_writes_length) - share->all_link_count = share->use_hs_writes_length; - if (share->all_link_count < share->hs_read_ports_length) - share->all_link_count = share->hs_read_ports_length; - if (share->all_link_count < share->hs_write_ports_length) - share->all_link_count = share->hs_write_ports_length; - if (share->all_link_count < share->hs_read_socks_length) - share->all_link_count = share->hs_read_socks_length; - if (share->all_link_count < share->hs_write_socks_length) - share->all_link_count = share->hs_write_socks_length; - if (share->all_link_count < share->hs_write_to_reads_length) - share->all_link_count = share->hs_write_to_reads_length; #endif if (share->all_link_count < share->use_handlers_length) share->all_link_count = share->use_handlers_length; @@ -2943,47 +2806,6 @@ int spider_parse_connect_info( &share->monitoring_sid_length, share->all_link_count))) goto error; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ((error_num = spider_increase_long_list( - &share->use_hs_reads, - &share->use_hs_reads_length, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_long_list( - &share->use_hs_writes, - &share->use_hs_writes_length, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_long_list( - &share->hs_read_ports, - &share->hs_read_ports_length, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_long_list( - &share->hs_write_ports, - &share->hs_write_ports_length, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_string_list( - &share->hs_read_socks, - &share->hs_read_socks_lengths, - &share->hs_read_socks_length, - &share->hs_read_socks_charlen, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_string_list( - &share->hs_write_socks, - &share->hs_write_socks_lengths, - &share->hs_write_socks_length, - &share->hs_write_socks_charlen, - share->all_link_count))) - goto error; - if ((error_num = spider_increase_long_list( - &share->hs_write_to_reads, - &share->hs_write_to_reads_length, - share->all_link_count))) - goto error; -#endif if ((error_num = spider_increase_long_list( &share->use_handlers, &share->use_handlers_length, @@ -3817,38 +3639,6 @@ int spider_set_connect_info_default( if (share->monitoring_sid[roop_count] == -1) share->monitoring_sid[roop_count] = global_system_variables.server_id; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->hs_read_ports[roop_count] == -1) - { - share->hs_read_ports[roop_count] = 9998; - } else if (share->hs_read_ports[roop_count] < 0) - { - share->hs_read_ports[roop_count] = 0; - } else if (share->hs_read_ports[roop_count] > 65535) - { - share->hs_read_ports[roop_count] = 65535; - } - if (share->hs_write_ports[roop_count] == -1) - { - share->hs_write_ports[roop_count] = 9999; - } else if (share->hs_write_ports[roop_count] < 0) - { - share->hs_write_ports[roop_count] = 0; - } else if (share->hs_write_ports[roop_count] > 65535) - { - share->hs_write_ports[roop_count] = 65535; - } - if (share->hs_write_to_reads[roop_count] == -1) - { - share->hs_write_to_reads[roop_count] = 1; - } else if (share->hs_write_to_reads[roop_count] < 0) - { - share->hs_write_to_reads[roop_count] = 0; - } else if (share->hs_write_to_reads[roop_count] > 1) - { - share->hs_write_to_reads[roop_count] = 1; - } -#endif if (share->access_balances[roop_count] == -1) share->access_balances[roop_count] = 100; } @@ -4035,23 +3825,12 @@ int spider_create_conn_keys( ) { int roop_count, roop_count2; char *tmp_name, port_str[6]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char *tmp_hs_r_name, *tmp_hs_w_name; -#endif uint length_base = sizeof(uint) * share->all_link_count; uint *conn_keys_lengths; uint *sql_dbton_ids; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - uint *hs_dbton_ids; - uint *hs_r_conn_keys_lengths; - uint *hs_w_conn_keys_lengths; -#endif DBUG_ENTER("spider_create_conn_keys"); char *ptr; uint length = length_base * 2; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - length += length_base * 3; -#endif ptr = (char *) my_alloca(length); if (!ptr) { @@ -4060,26 +3839,11 @@ int spider_create_conn_keys( conn_keys_lengths = (uint *) ptr; ptr += length_base; sql_dbton_ids = (uint *) ptr; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ptr += length_base; - hs_dbton_ids = (uint *) ptr; - ptr += length_base; - hs_r_conn_keys_lengths = (uint *) ptr; - ptr += length_base; - hs_w_conn_keys_lengths = (uint *) ptr; -#endif share->conn_keys_charlen = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->hs_read_conn_keys_charlen = 0; - share->hs_write_conn_keys_charlen = 0; -#endif for (roop_count = 0; roop_count < (int) share->all_link_count; roop_count++) { bool get_sql_id = FALSE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - bool get_nosql_id = FALSE; -#endif for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++) { DBUG_PRINT("info",("spider share->tgt_wrappers[%d]=%s", roop_count, @@ -4099,35 +3863,12 @@ int spider_create_conn_keys( ) { sql_dbton_ids[roop_count] = roop_count2; get_sql_id = TRUE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (get_nosql_id) -#endif - break; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - else - continue; -#endif - } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - !get_nosql_id && - spider_dbton[roop_count2].db_access_type == - SPIDER_DB_ACCESS_TYPE_NOSQL - ) { - hs_dbton_ids[roop_count] = roop_count2; - get_nosql_id = TRUE; - if (get_sql_id) break; } -#endif } } if (!get_sql_id) sql_dbton_ids[roop_count] = SPIDER_DBTON_SIZE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!get_nosql_id) - hs_dbton_ids[roop_count] = SPIDER_DBTON_SIZE; -#endif bool tables_on_different_db_are_joinable; if (get_sql_id) @@ -4158,24 +3899,6 @@ int spider_create_conn_keys( + share->tgt_default_groups_lengths[roop_count] + 1 + share->tgt_dsns_lengths[roop_count]; share->conn_keys_charlen += conn_keys_lengths[roop_count] + 2; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - hs_r_conn_keys_lengths[roop_count] - = 1 - + share->tgt_wrappers_lengths[roop_count] + 1 - + share->tgt_hosts_lengths[roop_count] + 1 - + 5 + 1 - + share->hs_read_socks_lengths[roop_count]; - share->hs_read_conn_keys_charlen += - hs_r_conn_keys_lengths[roop_count] + 2; - hs_w_conn_keys_lengths[roop_count] - = 1 - + share->tgt_wrappers_lengths[roop_count] + 1 - + share->tgt_hosts_lengths[roop_count] + 1 - + 5 + 1 - + share->hs_write_socks_lengths[roop_count]; - share->hs_write_conn_keys_charlen += - hs_w_conn_keys_lengths[roop_count] + 2; -#endif } if (!(share->conn_keys = (char **) spider_bulk_alloc_mem(spider_current_trx, SPD_MID_CREATE_CONN_KEYS_1, @@ -4187,26 +3910,7 @@ int spider_create_conn_keys( sizeof(my_hash_value_type) * share->all_link_count, #endif &tmp_name, sizeof(char) * share->conn_keys_charlen, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &share->hs_read_conn_keys, sizeof(char *) * share->all_link_count, - &share->hs_read_conn_keys_lengths, length_base, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - &share->hs_read_conn_keys_hash_value, - sizeof(my_hash_value_type) * share->all_link_count, -#endif - &tmp_hs_r_name, sizeof(char) * share->hs_read_conn_keys_charlen, - &share->hs_write_conn_keys, sizeof(char *) * share->all_link_count, - &share->hs_write_conn_keys_lengths, length_base, -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - &share->hs_write_conn_keys_hash_value, - sizeof(my_hash_value_type) * share->all_link_count, -#endif - &tmp_hs_w_name, sizeof(char) * share->hs_write_conn_keys_charlen, -#endif &share->sql_dbton_ids, length_base, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &share->hs_dbton_ids, length_base, -#endif NullS)) ) { my_afree(conn_keys_lengths); @@ -4216,15 +3920,6 @@ int spider_create_conn_keys( memcpy(share->conn_keys_lengths, conn_keys_lengths, length_base); memcpy(share->sql_dbton_ids, sql_dbton_ids, length_base); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->hs_read_conn_keys_length = share->all_link_count; - share->hs_write_conn_keys_length = share->all_link_count; - memcpy(share->hs_read_conn_keys_lengths, hs_r_conn_keys_lengths, - length_base); - memcpy(share->hs_write_conn_keys_lengths, hs_w_conn_keys_lengths, - length_base); - memcpy(share->hs_dbton_ids, hs_dbton_ids, length_base); -#endif my_afree(conn_keys_lengths); @@ -4346,83 +4041,15 @@ int spider_create_conn_keys( share->conn_keys_hash_value[roop_count] = my_calc_hash( &spider_open_connections, (uchar*) share->conn_keys[roop_count], share->conn_keys_lengths[roop_count]); -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->hs_read_conn_keys[roop_count] = tmp_hs_r_name; - *tmp_hs_r_name = '0'; - DBUG_PRINT("info",("spider tgt_wrappers[%d]=%s", roop_count, - share->tgt_wrappers[roop_count])); - tmp_hs_r_name = strmov(tmp_hs_r_name + 1, share->tgt_wrappers[roop_count]); - DBUG_PRINT("info",("spider tgt_hosts[%d]=%s", roop_count, - share->tgt_hosts[roop_count])); - tmp_hs_r_name = strmov(tmp_hs_r_name + 1, share->tgt_hosts[roop_count]); - my_sprintf(port_str, (port_str, "%05ld", - share->hs_read_ports[roop_count])); - DBUG_PRINT("info",("spider port_str=%s", port_str)); - tmp_hs_r_name = strmov(tmp_hs_r_name + 1, port_str); - if (share->hs_read_socks[roop_count]) - { - DBUG_PRINT("info",("spider hs_read_socks[%d]=%s", roop_count, - share->hs_read_socks[roop_count])); - tmp_hs_r_name = strmov(tmp_hs_r_name + 1, - share->hs_read_socks[roop_count]); - } else - tmp_hs_r_name++; - tmp_hs_r_name++; - tmp_hs_r_name++; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - share->hs_read_conn_keys_hash_value[roop_count] = my_calc_hash( - &spider_open_connections, (uchar*) share->hs_read_conn_keys[roop_count], - share->hs_read_conn_keys_lengths[roop_count]); -#endif - share->hs_write_conn_keys[roop_count] = tmp_hs_w_name; - *tmp_hs_w_name = '0'; - DBUG_PRINT("info",("spider tgt_wrappers[%d]=%s", roop_count, - share->tgt_wrappers[roop_count])); - tmp_hs_w_name = strmov(tmp_hs_w_name + 1, share->tgt_wrappers[roop_count]); - DBUG_PRINT("info",("spider tgt_hosts[%d]=%s", roop_count, - share->tgt_hosts[roop_count])); - tmp_hs_w_name = strmov(tmp_hs_w_name + 1, share->tgt_hosts[roop_count]); - my_sprintf(port_str, (port_str, "%05ld", - share->hs_write_ports[roop_count])); - DBUG_PRINT("info",("spider port_str=%s", port_str)); - tmp_hs_w_name = strmov(tmp_hs_w_name + 1, port_str); - if (share->hs_write_socks[roop_count]) - { - DBUG_PRINT("info",("spider hs_write_socks[%d]=%s", roop_count, - share->hs_write_socks[roop_count])); - tmp_hs_w_name = strmov(tmp_hs_w_name + 1, - share->hs_write_socks[roop_count]); - } else - tmp_hs_w_name++; - tmp_hs_w_name++; - tmp_hs_w_name++; -#ifdef SPIDER_HAS_HASH_VALUE_TYPE - share->hs_write_conn_keys_hash_value[roop_count] = my_calc_hash( - &spider_open_connections, (uchar*) share->hs_write_conn_keys[roop_count], - share->hs_write_conn_keys_lengths[roop_count]); -#endif #endif } for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++) { if (spider_bit_is_set(share->dbton_bitmap, roop_count2)) { -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (spider_dbton[roop_count2].db_access_type == - SPIDER_DB_ACCESS_TYPE_SQL) - { -#endif share->use_sql_dbton_ids[share->use_dbton_count] = roop_count2; share->sql_dbton_id_to_seq[roop_count2] = share->use_dbton_count; share->use_sql_dbton_count++; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else { - share->use_hs_dbton_ids[share->use_hs_dbton_count] = roop_count2; - share->hs_dbton_id_to_seq[roop_count2] = share->use_hs_dbton_count; - share->use_hs_dbton_count++; - } -#endif share->use_dbton_ids[share->use_dbton_count] = roop_count2; share->dbton_id_to_seq[roop_count2] = share->use_dbton_count; share->use_dbton_count++; @@ -4479,9 +4106,6 @@ SPIDER_SHARE *spider_create_share( SPD_INIT_ALLOC_ROOT(&share->mem_root, 4096, 0, MYF(MY_WME)); share->use_count = 0; share->use_dbton_count = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - share->use_hs_dbton_count = 0; -#endif share->table_name_length = length; share->table_name = tmp_name; strmov(share->table_name, table_name); @@ -4662,12 +4286,6 @@ SPIDER_SHARE *spider_get_share( SPIDER_RESULT_LIST *result_list = &spider->result_list; uint length, tmp_conn_link_idx = 0, buf_sz; char *tmp_name, *tmp_cid; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char *tmp_hs_r_name, *tmp_hs_w_name; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - uint32 *tmp_hs_r_ret_fields, *tmp_hs_w_ret_fields; -#endif -#endif int roop_count; double sts_interval; int sts_mode; @@ -4992,16 +4610,6 @@ SPIDER_SHARE *spider_get_share( &spider->conns, sizeof(SPIDER_CONN *) * share->link_count, &spider->conn_link_idx, sizeof(uint) * share->link_count, &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &spider->hs_r_conn_keys, sizeof(char *) * share->link_count, - &tmp_hs_r_name, sizeof(char) * share->hs_read_conn_keys_charlen, - &spider->hs_r_conns, sizeof(SPIDER_CONN *) * share->link_count, - &spider->hs_r_conn_ages, sizeof(ulonglong) * share->link_count, - &spider->hs_w_conn_keys, sizeof(char *) * share->link_count, - &tmp_hs_w_name, sizeof(char) * share->hs_write_conn_keys_charlen, - &spider->hs_w_conns, sizeof(SPIDER_CONN *) * share->link_count, - &spider->hs_w_conn_ages, sizeof(ulonglong) * share->link_count, -#endif &spider->sql_kind, sizeof(uint) * share->link_count, &spider->connection_ids, sizeof(ulonglong) * share->link_count, &spider->conn_kind, sizeof(uint) * share->link_count, @@ -5010,26 +4618,6 @@ SPIDER_SHARE *spider_get_share( &spider->m_handler_opened, sizeof(uchar) * share->link_bitmap_size, &spider->m_handler_id, sizeof(uint) * share->link_count, &spider->m_handler_cid, sizeof(char *) * share->link_count, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &spider->r_handler_opened, sizeof(uchar) * share->link_bitmap_size, - &spider->r_handler_id, sizeof(uint) * share->link_count, - &spider->r_handler_index, sizeof(uint) * share->link_count, - &spider->w_handler_opened, sizeof(uchar) * share->link_bitmap_size, - &spider->w_handler_id, sizeof(uint) * share->link_count, - &spider->w_handler_index, sizeof(uint) * share->link_count, -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - &spider->do_hs_direct_update, sizeof(uchar) * share->link_bitmap_size, - &spider->hs_r_ret_fields, sizeof(uint32 *) * share->link_count, - &spider->hs_w_ret_fields, sizeof(uint32 *) * share->link_count, - &spider->hs_r_ret_fields_num, sizeof(size_t) * share->link_count, - &spider->hs_w_ret_fields_num, sizeof(size_t) * share->link_count, - &tmp_hs_r_ret_fields, - sizeof(uint32) * share->link_count * table_share->fields, - &tmp_hs_w_ret_fields, - sizeof(uint32) * share->link_count * table_share->fields, - &spider->tmp_column_bitmap, sizeof(uchar) * share->bitmap_size, -#endif -#endif &tmp_cid, sizeof(char) * (SPIDER_SQL_HANDLER_CID_LEN + 1) * share->link_count, &spider->need_mons, sizeof(int) * share->link_count, @@ -5042,12 +4630,6 @@ SPIDER_SHARE *spider_get_share( &result_list->tmp_table_created, sizeof(uchar) * share->link_bitmap_size, #ifdef HA_CAN_BULK_ACCESS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &result_list->hs_r_bulk_open_index, - sizeof(uchar) * share->link_bitmap_size, - &result_list->hs_w_bulk_open_index, - sizeof(uchar) * share->link_bitmap_size, -#endif #endif &result_list->sql_kind_backup, sizeof(uint) * share->link_count, &result_list->casual_read, sizeof(int) * share->link_count, @@ -5062,12 +4644,6 @@ SPIDER_SHARE *spider_get_share( goto error_but_no_delete; } memcpy(tmp_name, share->conn_keys[0], share->conn_keys_charlen); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - memcpy(tmp_hs_r_name, share->hs_read_conn_keys[0], - share->hs_read_conn_keys_charlen); - memcpy(tmp_hs_w_name, share->hs_write_conn_keys[0], - share->hs_write_conn_keys_charlen); -#endif spider->conn_keys_first_ptr = tmp_name; for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) @@ -5075,18 +4651,6 @@ SPIDER_SHARE *spider_get_share( spider->conn_keys[roop_count] = tmp_name; *tmp_name = first_byte; tmp_name += share->conn_keys_lengths[roop_count] + 1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->hs_r_conn_keys[roop_count] = tmp_hs_r_name; - tmp_hs_r_name += share->hs_read_conn_keys_lengths[roop_count] + 1; - spider->hs_w_conn_keys[roop_count] = tmp_hs_w_name; - tmp_hs_w_name += share->hs_write_conn_keys_lengths[roop_count] + 1; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - spider->hs_r_ret_fields[roop_count] = tmp_hs_r_ret_fields; - tmp_hs_r_ret_fields += table_share->fields; - spider->hs_w_ret_fields[roop_count] = tmp_hs_w_ret_fields; - tmp_hs_w_ret_fields += table_share->fields; -#endif -#endif spider->m_handler_cid[roop_count] = tmp_cid; tmp_cid += SPIDER_SQL_HANDLER_CID_LEN + 1; result_list->upd_tmp_tbl_prms[roop_count].init(); @@ -5534,16 +5098,6 @@ SPIDER_SHARE *spider_get_share( &spider->conns, sizeof(SPIDER_CONN *) * share->link_count, &spider->conn_link_idx, sizeof(uint) * share->link_count, &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &spider->hs_r_conn_keys, sizeof(char *) * share->link_count, - &tmp_hs_r_name, sizeof(char) * share->hs_read_conn_keys_charlen, - &spider->hs_r_conns, sizeof(SPIDER_CONN *) * share->link_count, - &spider->hs_r_conn_ages, sizeof(ulonglong) * share->link_count, - &spider->hs_w_conn_keys, sizeof(char *) * share->link_count, - &tmp_hs_w_name, sizeof(char) * share->hs_write_conn_keys_charlen, - &spider->hs_w_conns, sizeof(SPIDER_CONN *) * share->link_count, - &spider->hs_w_conn_ages, sizeof(ulonglong) * share->link_count, -#endif &spider->sql_kind, sizeof(uint) * share->link_count, &spider->connection_ids, sizeof(ulonglong) * share->link_count, &spider->conn_kind, sizeof(uint) * share->link_count, @@ -5552,26 +5106,6 @@ SPIDER_SHARE *spider_get_share( &spider->m_handler_opened, sizeof(uchar) * share->link_bitmap_size, &spider->m_handler_id, sizeof(uint) * share->link_count, &spider->m_handler_cid, sizeof(char *) * share->link_count, -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &spider->r_handler_opened, sizeof(uchar) * share->link_bitmap_size, - &spider->r_handler_id, sizeof(uint) * share->link_count, - &spider->r_handler_index, sizeof(uint) * share->link_count, - &spider->w_handler_opened, sizeof(uchar) * share->link_bitmap_size, - &spider->w_handler_id, sizeof(uint) * share->link_count, - &spider->w_handler_index, sizeof(uint) * share->link_count, -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - &spider->do_hs_direct_update, sizeof(uchar) * share->link_bitmap_size, - &spider->hs_r_ret_fields, sizeof(uint32 *) * share->link_count, - &spider->hs_w_ret_fields, sizeof(uint32 *) * share->link_count, - &spider->hs_r_ret_fields_num, sizeof(size_t) * share->link_count, - &spider->hs_w_ret_fields_num, sizeof(size_t) * share->link_count, - &tmp_hs_r_ret_fields, - sizeof(uint32) * share->link_count * table_share->fields, - &tmp_hs_w_ret_fields, - sizeof(uint32) * share->link_count * table_share->fields, - &spider->tmp_column_bitmap, sizeof(uchar) * share->bitmap_size, -#endif -#endif &tmp_cid, sizeof(char) * (SPIDER_SQL_HANDLER_CID_LEN + 1) * share->link_count, &spider->need_mons, sizeof(int) * share->link_count, @@ -5584,12 +5118,6 @@ SPIDER_SHARE *spider_get_share( &result_list->tmp_table_created, sizeof(uchar) * share->link_bitmap_size, #ifdef HA_CAN_BULK_ACCESS -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - &result_list->hs_r_bulk_open_index, - sizeof(uchar) * share->link_bitmap_size, - &result_list->hs_w_bulk_open_index, - sizeof(uchar) * share->link_bitmap_size, -#endif #endif &result_list->sql_kind_backup, sizeof(uint) * share->link_count, &result_list->casual_read, sizeof(int) * share->link_count, @@ -5601,12 +5129,6 @@ SPIDER_SHARE *spider_get_share( goto error_but_no_delete; } memcpy(tmp_name, share->conn_keys[0], share->conn_keys_charlen); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - memcpy(tmp_hs_r_name, share->hs_read_conn_keys[0], - share->hs_read_conn_keys_charlen); - memcpy(tmp_hs_w_name, share->hs_write_conn_keys[0], - share->hs_write_conn_keys_charlen); -#endif spider->conn_keys_first_ptr = tmp_name; for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) @@ -5614,18 +5136,6 @@ SPIDER_SHARE *spider_get_share( spider->conn_keys[roop_count] = tmp_name; *tmp_name = first_byte; tmp_name += share->conn_keys_lengths[roop_count] + 1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->hs_r_conn_keys[roop_count] = tmp_hs_r_name; - tmp_hs_r_name += share->hs_read_conn_keys_lengths[roop_count] + 1; - spider->hs_w_conn_keys[roop_count] = tmp_hs_w_name; - tmp_hs_w_name += share->hs_write_conn_keys_lengths[roop_count] + 1; -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - spider->hs_r_ret_fields[roop_count] = tmp_hs_r_ret_fields; - tmp_hs_r_ret_fields += table_share->fields; - spider->hs_w_ret_fields[roop_count] = tmp_hs_w_ret_fields; - tmp_hs_w_ret_fields += table_share->fields; -#endif -#endif spider->m_handler_cid[roop_count] = tmp_cid; tmp_cid += SPIDER_SQL_HANDLER_CID_LEN + 1; result_list->upd_tmp_tbl_prms[roop_count].init(); @@ -6715,32 +6225,6 @@ int spider_db_done( } pthread_mutex_unlock(&spider_allocated_thds_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - pthread_mutex_lock(&spider_hs_w_conn_mutex); - while ((conn = (SPIDER_CONN*) my_hash_element(&spider_hs_w_conn_hash, 0))) - { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_hs_w_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&spider_hs_w_conn_hash, (uchar*) conn); -#endif - spider_free_conn(conn); - } - pthread_mutex_unlock(&spider_hs_w_conn_mutex); - pthread_mutex_lock(&spider_hs_r_conn_mutex); - while ((conn = (SPIDER_CONN*) my_hash_element(&spider_hs_r_conn_hash, 0))) - { -#ifdef HASH_UPDATE_WITH_HASH_VALUE - my_hash_delete_with_hash_value(&spider_hs_r_conn_hash, - conn->conn_key_hash_value, (uchar*) conn); -#else - my_hash_delete(&spider_hs_r_conn_hash, (uchar*) conn); -#endif - spider_free_conn(conn); - } - pthread_mutex_unlock(&spider_hs_r_conn_mutex); -#endif pthread_mutex_lock(&spider_conn_mutex); while ((conn = (SPIDER_CONN*) my_hash_element(&spider_open_connections, 0))) { @@ -6770,18 +6254,6 @@ int spider_db_done( spider_allocated_thds.array.max_element * spider_allocated_thds.array.size_of_element); my_hash_free(&spider_allocated_thds); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc(spider_current_trx, - spider_hs_w_conn_hash_id, - spider_hs_w_conn_hash.array.max_element * - spider_hs_w_conn_hash.array.size_of_element); - my_hash_free(&spider_hs_w_conn_hash); - spider_free_mem_calc(spider_current_trx, - spider_hs_r_conn_hash_id, - spider_hs_r_conn_hash.array.max_element * - spider_hs_r_conn_hash.array.size_of_element); - my_hash_free(&spider_hs_r_conn_hash); -#endif spider_free_mem_calc(spider_current_trx, spider_open_connections_id, spider_open_connections.array.max_element * @@ -6829,10 +6301,6 @@ int spider_db_done( pthread_mutex_destroy(&spider_mon_table_cache_mutex); pthread_mutex_destroy(&spider_allocated_thds_mutex); pthread_mutex_destroy(&spider_open_conn_mutex); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - pthread_mutex_destroy(&spider_hs_w_conn_mutex); - pthread_mutex_destroy(&spider_hs_r_conn_mutex); -#endif pthread_mutex_destroy(&spider_conn_mutex); pthread_mutex_destroy(&spider_lgtm_tblhnd_share_mutex); #ifdef WITH_PARTITION_STORAGE_ENGINE @@ -7056,16 +6524,6 @@ int spider_db_init( &spider_open_conn_mutex, MY_MUTEX_INIT_FAST)) goto error_open_conn_mutex_init; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (mysql_mutex_init(spd_key_mutex_hs_r_conn, - &spider_hs_r_conn_mutex, MY_MUTEX_INIT_FAST)) - goto error_hs_r_conn_mutex_init; - - if (mysql_mutex_init(spd_key_mutex_hs_w_conn, - &spider_hs_w_conn_mutex, MY_MUTEX_INIT_FAST)) - goto error_hs_w_conn_mutex_init; - -#endif if (mysql_mutex_init(spd_key_mutex_allocated_thds, &spider_allocated_thds_mutex, MY_MUTEX_INIT_FAST)) goto error_allocated_thds_mutex_init; @@ -7133,26 +6591,6 @@ int spider_db_init( spider_open_connections, spider_open_connections.array.max_element * spider_open_connections.array.size_of_element); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (my_hash_init(PSI_INSTRUMENT_ME, &spider_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0)) - goto error_hs_r_conn_hash_init; - - spider_alloc_calc_mem_init(spider_hs_r_conn_hash, SPD_MID_DB_INIT_6); - spider_alloc_calc_mem(NULL, - spider_hs_r_conn_hash, - spider_hs_r_conn_hash.array.max_element * - spider_hs_r_conn_hash.array.size_of_element); - if (my_hash_init(PSI_INSTRUMENT_ME, &spider_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0)) - goto error_hs_w_conn_hash_init; - - spider_alloc_calc_mem_init(spider_hs_w_conn_hash, SPD_MID_DB_INIT_7); - spider_alloc_calc_mem(NULL, - spider_hs_w_conn_hash, - spider_hs_w_conn_hash.array.max_element * - spider_hs_w_conn_hash.array.size_of_element); -#endif if (my_hash_init(PSI_INSTRUMENT_ME, &spider_allocated_thds, spd_charset_utf8mb3_bin, 32, 0, 0, (my_hash_get_key) spider_allocated_thds_get_key, 0, 0)) goto error_allocated_thds_hash_init; @@ -7261,12 +6699,6 @@ int spider_db_init( spider_dbton_mariadb.db_util->dbton_id = dbton_id; spider_dbton[dbton_id] = spider_dbton_mariadb; ++dbton_id; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_dbton_handlersocket.dbton_id = dbton_id; - spider_dbton_handlersocket.db_util->dbton_id = dbton_id; - spider_dbton[dbton_id] = spider_dbton_handlersocket; - ++dbton_id; -#endif #ifdef HAVE_ORACLE_OCI spider_dbton_oracle.dbton_id = dbton_id; spider_dbton_oracle.db_util->dbton_id = dbton_id; @@ -7344,20 +6776,6 @@ error_mon_table_cache_array_init: error_allocated_thds_hash_init: my_hash_free(&spider_ipport_conns); error_ipport_conn__hash_init: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc(NULL, - spider_hs_w_conn_hash_id, - spider_hs_w_conn_hash.array.max_element * - spider_hs_w_conn_hash.array.size_of_element); - my_hash_free(&spider_hs_w_conn_hash); -error_hs_w_conn_hash_init: - spider_free_mem_calc(NULL, - spider_hs_r_conn_hash_id, - spider_hs_r_conn_hash.array.max_element * - spider_hs_r_conn_hash.array.size_of_element); - my_hash_free(&spider_hs_r_conn_hash); -error_hs_r_conn_hash_init: -#endif spider_free_mem_calc(NULL, spider_open_connections_id, spider_open_connections.array.max_element * @@ -7396,12 +6814,6 @@ error_mem_calc_mutex_init: error_mon_table_cache_mutex_init: pthread_mutex_destroy(&spider_allocated_thds_mutex); error_allocated_thds_mutex_init: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - pthread_mutex_destroy(&spider_hs_w_conn_mutex); -error_hs_w_conn_mutex_init: - pthread_mutex_destroy(&spider_hs_r_conn_mutex); -error_hs_r_conn_mutex_init: -#endif pthread_mutex_destroy(&spider_open_conn_mutex); error_open_conn_mutex_init: pthread_mutex_destroy(&spider_conn_mutex); @@ -7980,112 +7392,6 @@ bool spider_check_pk_update( DBUG_RETURN(FALSE); } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -bool spider_check_hs_pk_update( - ha_spider *spider, - key_range *key -) { - uint roop_count, field_index, set_count = 0; - TABLE *table = spider->get_table(); - TABLE_SHARE *table_share = table->s; - SPIDER_SHARE *share = spider->share; - KEY *key_info; - KEY_PART_INFO *key_part; - char buf[MAX_FIELD_WIDTH], buf2[MAX_FIELD_WIDTH]; - spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin), - tmp_str2(buf2, MAX_FIELD_WIDTH, &my_charset_bin); - String *str, *str2; - DBUG_ENTER("spider_check_hs_pk_update"); - tmp_str.init_calc_mem(SPD_MID_CHECK_HS_PK_UPDATE_1); - - if (table_share->primary_key == MAX_KEY) - DBUG_RETURN(FALSE); - memset(spider->tmp_column_bitmap, 0, sizeof(uchar) * share->bitmap_size); - key_info = &table->key_info[table_share->primary_key]; - key_part = key_info->key_part; - for (roop_count = 0; roop_count < spider_user_defined_key_parts(key_info); - roop_count++) - { - field_index = key_part[roop_count].field->field_index; - if (bitmap_is_set(table->write_set, field_index)) - { - DBUG_PRINT("info", ("spider set key_part=%u field_index=%u", - roop_count, field_index)); - spider_set_bit(spider->tmp_column_bitmap, field_index); - set_count++; - } - } - DBUG_PRINT("info", ("spider set_count=%u", set_count)); - - Field *field; - uint store_length, length, var_len; - const uchar *ptr; - bool key_eq; - key_part_map tgt_key_part_map = key->keypart_map; - key_info = &table->key_info[spider->active_index]; - for ( - key_part = key_info->key_part, - length = 0; - tgt_key_part_map; - length += store_length, - tgt_key_part_map >>= 1, - key_part++ - ) { - store_length = key_part->store_length; - field = key_part->field; - field_index = field->field_index; - if (spider_bit_is_set(spider->tmp_column_bitmap, field_index)) - { - ptr = key->key + length; - key_eq = (tgt_key_part_map > 1); - if (key_part->null_bit && *ptr++) - { - if (key->flag != HA_READ_KEY_EXACT || !field->is_null()) - { - DBUG_PRINT("info", ("spider flag=%u is_null=%s", - key->flag, field->is_null() ? "TRUE" : "FALSE")); - DBUG_RETURN(TRUE); - } - } else { - if ( - field->type() == MYSQL_TYPE_BLOB || - field->real_type() == MYSQL_TYPE_VARCHAR || - field->type() == MYSQL_TYPE_GEOMETRY - ) { - var_len = uint2korr(ptr); - tmp_str.set_quick((char *) ptr + HA_KEY_BLOB_LENGTH, var_len, - &my_charset_bin); - str = tmp_str.get_str(); - } else { - str = field->val_str(tmp_str.get_str(), ptr); - tmp_str.mem_calc(); - } - str2 = field->val_str(tmp_str2.get_str()); - tmp_str2.mem_calc(); - if ( - str->length() != str2->length() || - memcmp(str->ptr(), str2->ptr(), str->length()) - ) { - DBUG_PRINT("info", ("spider length=%u %u", - str->length(), str2->length())); - DBUG_PRINT("info", ("spider length=%s %s", - str->c_ptr_safe(), str2->c_ptr_safe())); - DBUG_RETURN(TRUE); - } - } - set_count--; - } - } - DBUG_PRINT("info", ("spider set_count=%u", set_count)); - if (set_count) - { - DBUG_RETURN(TRUE); - } - DBUG_RETURN(FALSE); -} -#endif -#endif void spider_set_tmp_share_pointer( SPIDER_SHARE *tmp_share, @@ -8116,10 +7422,6 @@ void spider_set_tmp_share_pointer( tmp_share->tgt_pk_names = &tmp_connect_info[16]; tmp_share->tgt_sequence_names = &tmp_connect_info[17]; tmp_share->static_link_ids = &tmp_connect_info[18]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->hs_read_socks = &tmp_connect_info[19]; - tmp_share->hs_write_socks = &tmp_connect_info[20]; -#endif tmp_share->tgt_ports = &tmp_long[0]; tmp_share->tgt_ssl_vscs = &tmp_long[1]; tmp_share->link_statuses = &tmp_long[2]; @@ -8129,13 +7431,6 @@ void spider_set_tmp_share_pointer( #ifndef WITHOUT_SPIDER_BG_SEARCH tmp_share->monitoring_bg_flag = &tmp_long[6]; tmp_share->monitoring_bg_kind = &tmp_long[7]; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->use_hs_reads = &tmp_long[8]; - tmp_share->use_hs_writes = &tmp_long[9]; - tmp_share->hs_read_ports = &tmp_long[10]; - tmp_share->hs_write_ports = &tmp_long[11]; - tmp_share->hs_write_to_reads = &tmp_long[12]; #endif tmp_share->use_handlers = &tmp_long[13]; tmp_share->connect_timeouts = &tmp_long[14]; @@ -8171,10 +7466,6 @@ void spider_set_tmp_share_pointer( tmp_share->tgt_pk_names_lengths = &tmp_connect_info_length[16]; tmp_share->tgt_sequence_names_lengths = &tmp_connect_info_length[17]; tmp_share->static_link_ids_lengths = &tmp_connect_info_length[18]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->hs_read_socks_lengths = &tmp_connect_info_length[19]; - tmp_share->hs_write_socks_lengths = &tmp_connect_info_length[20]; -#endif tmp_share->server_names_length = 1; tmp_share->tgt_table_names_length = 1; tmp_share->tgt_dbs_length = 1; @@ -8208,15 +7499,6 @@ void spider_set_tmp_share_pointer( tmp_share->monitoring_sid_length = 1; #ifndef WITHOUT_SPIDER_BG_SEARCH tmp_share->monitoring_bg_interval_length = 1; -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->hs_read_socks_length = 1; - tmp_share->hs_write_socks_length = 1; - tmp_share->use_hs_reads_length = 1; - tmp_share->use_hs_writes_length = 1; - tmp_share->hs_read_ports_length = 1; - tmp_share->hs_write_ports_length = 1; - tmp_share->hs_write_to_reads_length = 1; #endif tmp_share->use_handlers_length = 1; tmp_share->connect_timeouts_length = 1; @@ -8240,9 +7522,6 @@ void spider_set_tmp_share_pointer( tmp_share->monitoring_sid[0] = -1; tmp_share->bka_engine = NULL; tmp_share->use_dbton_count = 0; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - tmp_share->use_hs_dbton_count = 0; -#endif DBUG_VOID_RETURN; } @@ -8425,26 +7704,17 @@ longlong spider_split_read_param( #ifdef SPIDER_HAS_GROUP_BY_HANDLER bool inserting = ( -#ifdef HS_HAS_SQLCOM - spider->wide_handler->sql_command == SQLCOM_HS_INSERT || -#endif spider->wide_handler->sql_command == SQLCOM_INSERT || spider->wide_handler->sql_command == SQLCOM_INSERT_SELECT ); #endif bool updating = ( -#ifdef HS_HAS_SQLCOM - spider->wide_handler->sql_command == SQLCOM_HS_UPDATE || -#endif spider->wide_handler->sql_command == SQLCOM_UPDATE || spider->wide_handler->sql_command == SQLCOM_UPDATE_MULTI ); bool deleting = ( -#ifdef HS_HAS_SQLCOM - spider->wide_handler->sql_command == SQLCOM_HS_DELETE || -#endif spider->wide_handler->sql_command == SQLCOM_DELETE || spider->wide_handler->sql_command == SQLCOM_DELETE_MULTI ); @@ -9512,10 +8782,6 @@ int spider_create_spider_object_for_share( uint *conn_link_idx; uchar *conn_can_fo; char **conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - char **hs_r_conn_keys; - char **hs_w_conn_keys; -#endif spider_db_handler **dbton_hdl; SPIDER_WIDE_HANDLER *wide_handler; DBUG_ENTER("spider_create_spider_object_for_share"); @@ -9536,21 +8802,6 @@ int spider_create_spider_object_for_share( goto error_spider_alloc; } DBUG_PRINT("info",("spider spider=%p", (*spider))); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!(need_mons = (int *) - spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_SPIDER_OBJECT_FOR_SHARE_1, MYF(MY_WME | MY_ZEROFILL), - &need_mons, (uint) (sizeof(int) * share->link_count), - &conns, (uint) (sizeof(SPIDER_CONN *) * share->link_count), - &conn_link_idx, (uint) (sizeof(uint) * share->link_count), - &conn_can_fo, (uint) (sizeof(uchar) * share->link_bitmap_size), - &conn_keys, (uint) (sizeof(char *) * share->link_count), - &hs_r_conn_keys, (uint) (sizeof(char *) * share->link_count), - &hs_w_conn_keys, (uint) (sizeof(char *) * share->link_count), - &dbton_hdl, (uint) (sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE), - &wide_handler, (uint) sizeof(SPIDER_WIDE_HANDLER), - NullS)) - ) -#else if (!(need_mons = (int *) spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_SPIDER_OBJECT_FOR_SHARE_2, MYF(MY_WME | MY_ZEROFILL), &need_mons, (uint) (sizeof(int) * share->link_count), @@ -9562,7 +8813,6 @@ int spider_create_spider_object_for_share( &wide_handler, (uint) sizeof(SPIDER_WIDE_HANDLER), NullS)) ) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_need_mons_alloc; @@ -9578,10 +8828,6 @@ int spider_create_spider_object_for_share( (*spider)->need_mons = need_mons; (*spider)->conn_keys_first_ptr = share->conn_keys[0]; (*spider)->conn_keys = conn_keys; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (*spider)->hs_r_conn_keys = hs_r_conn_keys; - (*spider)->hs_w_conn_keys = hs_w_conn_keys; -#endif (*spider)->dbton_handler = dbton_hdl; (*spider)->search_link_idx = -1; for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++) diff --git a/storage/spider/spd_table.h b/storage/spider/spd_table.h index c87f91ac08b..8ab00212091 100644 --- a/storage/spider/spd_table.h +++ b/storage/spider/spd_table.h @@ -372,14 +372,6 @@ bool spider_check_pk_update( TABLE *table ); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -bool spider_check_hs_pk_update( - ha_spider *spider, - key_range *key -); -#endif -#endif void spider_set_tmp_share_pointer( SPIDER_SHARE *tmp_share, diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index d96567e426c..65bd6fc2120 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -1078,30 +1078,6 @@ int spider_free_trx_alloc( trx->trx_another_conn_hash.array.max_element * trx->trx_another_conn_hash.array.size_of_element); my_hash_free(&trx->trx_another_conn_hash); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc(spider_current_trx, - trx->trx_direct_hs_r_conn_hash_id, - trx->trx_direct_hs_r_conn_hash.array.max_element * - trx->trx_direct_hs_r_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_direct_hs_r_conn_hash); - spider_free_mem_calc(spider_current_trx, - trx->trx_direct_hs_w_conn_hash_id, - trx->trx_direct_hs_w_conn_hash.array.max_element * - trx->trx_direct_hs_w_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_direct_hs_w_conn_hash); -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc(spider_current_trx, - trx->trx_hs_r_conn_hash_id, - trx->trx_hs_r_conn_hash.array.max_element * - trx->trx_hs_r_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_hs_r_conn_hash); - spider_free_mem_calc(spider_current_trx, - trx->trx_hs_w_conn_hash_id, - trx->trx_hs_w_conn_hash.array.max_element * - trx->trx_hs_w_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_hs_w_conn_hash); -#endif spider_free_mem_calc(spider_current_trx, trx->trx_ha_hash_id, trx->trx_ha_hash.array.max_element * @@ -1183,57 +1159,7 @@ SPIDER_TRX *spider_get_trx( trx->trx_another_conn_hash.array.max_element * trx->trx_another_conn_hash.array.size_of_element); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - my_hash_init(&trx->trx_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0) - ) - goto error_hs_r_init_hash; - spider_alloc_calc_mem_init(trx->trx_hs_r_conn_hash, SPD_MID_GET_TRX_4); - spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_hs_r_conn_hash, - trx->trx_hs_r_conn_hash.array.max_element * - trx->trx_hs_r_conn_hash.array.size_of_element); - if ( - my_hash_init(&trx->trx_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32, 0, 0, - (my_hash_get_key) spider_conn_get_key, 0, 0) - ) - goto error_hs_w_init_hash; - spider_alloc_calc_mem_init(trx->trx_hs_w_conn_hash, SPD_MID_GET_TRX_5); - spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_hs_w_conn_hash, - trx->trx_hs_w_conn_hash.array.max_element * - trx->trx_hs_w_conn_hash.array.size_of_element); -#endif - -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - my_hash_init(&trx->trx_direct_hs_r_conn_hash, spd_charset_utf8mb3_bin, 32, - 0, 0, (my_hash_get_key) spider_conn_get_key, 0, 0) - ) - goto error_direct_hs_r_init_hash; - spider_alloc_calc_mem_init(trx->trx_direct_hs_r_conn_hash, SPD_MID_GET_TRX_6); - spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_direct_hs_r_conn_hash, - trx->trx_direct_hs_r_conn_hash.array.max_element * - trx->trx_direct_hs_r_conn_hash.array.size_of_element); - - if ( - my_hash_init(&trx->trx_direct_hs_w_conn_hash, spd_charset_utf8mb3_bin, 32, - 0, 0, (my_hash_get_key) spider_conn_get_key, 0, 0) - ) - goto error_direct_hs_w_init_hash; - spider_alloc_calc_mem_init(trx->trx_direct_hs_w_conn_hash, SPD_MID_GET_TRX_7); - spider_alloc_calc_mem( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_direct_hs_w_conn_hash, - trx->trx_direct_hs_w_conn_hash.array.max_element * - trx->trx_direct_hs_w_conn_hash.array.size_of_element); -#endif if ( my_hash_init(PSI_INSTRUMENT_ME, &trx->trx_alter_table_hash, @@ -1274,10 +1200,6 @@ SPIDER_TRX *spider_get_trx( ++spider_thread_id; pthread_mutex_unlock(&spider_thread_id_mutex); trx->trx_conn_adjustment = 1; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - trx->trx_hs_r_conn_adjustment = 1; - trx->trx_hs_w_conn_adjustment = 1; -#endif if (thd) { @@ -1431,38 +1353,6 @@ error_init_trx_ha_hash: trx->trx_alter_table_hash.array.size_of_element); my_hash_free(&trx->trx_alter_table_hash); error_init_alter_hash: -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_direct_hs_w_conn_hash_id, - trx->trx_direct_hs_w_conn_hash.array.max_element * - trx->trx_direct_hs_w_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_direct_hs_w_conn_hash); -error_direct_hs_w_init_hash: - spider_free_mem_calc( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_direct_hs_r_conn_hash_id, - trx->trx_direct_hs_r_conn_hash.array.max_element * - trx->trx_direct_hs_r_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_direct_hs_r_conn_hash); -error_direct_hs_r_init_hash: -#endif -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider_free_mem_calc( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_hs_w_conn_hash_id, - trx->trx_hs_w_conn_hash.array.max_element * - trx->trx_hs_w_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_hs_w_conn_hash); -error_hs_w_init_hash: - spider_free_mem_calc( - thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, - trx->trx_hs_r_conn_hash_id, - trx->trx_hs_r_conn_hash.array.max_element * - trx->trx_hs_r_conn_hash.array.size_of_element); - my_hash_free(&trx->trx_hs_r_conn_hash); -error_hs_r_init_hash: -#endif spider_free_mem_calc( thd ? ((SPIDER_TRX *) thd_get_ha_data(thd, spider_hton_ptr)) : NULL, trx->trx_another_conn_hash_id, @@ -3618,24 +3508,6 @@ int spider_check_trx_and_get_conn( if (!trx_ha || trx_ha->wait_for_reusing) spider_trx_set_link_idx_for_all(spider); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if (use_conn_kind) - { - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - if ( - share->hs_dbton_ids[spider->conn_link_idx[roop_count]] == - SPIDER_DBTON_SIZE - ) { - /* can't use hs interface */ - spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; - spider_clear_bit(spider->do_hs_direct_update, roop_count); - } - } - } -#endif -#endif if (semi_table_lock_conn) first_byte = '0' + @@ -3652,14 +3524,6 @@ int spider_check_trx_and_get_conn( trx_ha->wait_for_reusing || trx->spider_thread_id != spider->spider_thread_id || trx->trx_conn_adjustment != spider->trx_conn_adjustment || -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - (use_conn_kind && - ( - trx->trx_hs_r_conn_adjustment != spider->trx_hs_r_conn_adjustment || - trx->trx_hs_w_conn_adjustment != spider->trx_hs_w_conn_adjustment - ) - ) || -#endif first_byte != *spider->conn_keys[0] || share->link_statuses[spider->conn_link_idx[spider->search_link_idx]] == SPIDER_LINK_STATUS_NG @@ -3669,13 +3533,6 @@ int spider_check_trx_and_get_conn( "spider change thd" : "spider next trx")); spider->wide_handler->trx = trx; spider->trx_conn_adjustment = trx->trx_conn_adjustment; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (use_conn_kind) - { - spider->trx_hs_r_conn_adjustment = trx->trx_hs_r_conn_adjustment; - spider->trx_hs_w_conn_adjustment = trx->trx_hs_w_conn_adjustment; - } -#endif if ( spider->spider_thread_id != trx->spider_thread_id || spider->search_link_query_id != thd->query_id @@ -3720,12 +3577,6 @@ int spider_check_trx_and_get_conn( { if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_MYSQL)) spider->conns[roop_count] = NULL; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_READ)) - spider->hs_r_conns[roop_count] = NULL; - if (!spider->handler_opened(roop_count, SPIDER_CONN_KIND_HS_WRITE)) - spider->hs_w_conns[roop_count] = NULL; -#endif } bool search_link_idx_is_checked = FALSE; for ( @@ -3742,18 +3593,8 @@ int spider_check_trx_and_get_conn( if (roop_count == spider->search_link_idx) search_link_idx_is_checked = TRUE; if ( -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ( -#endif tgt_conn_kind == SPIDER_CONN_KIND_MYSQL && !spider->conns[roop_count] -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - ) || - (tgt_conn_kind == SPIDER_CONN_KIND_HS_READ && - !spider->hs_r_conns[roop_count]) || - (tgt_conn_kind == SPIDER_CONN_KIND_HS_WRITE && - !spider->hs_w_conns[roop_count]) -#endif ) { *spider->conn_keys[roop_count] = first_byte; if ( @@ -3793,51 +3634,6 @@ int spider_check_trx_and_get_conn( } conn->error_mode &= spider->error_mode; } -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->do_direct_update && - spider_bit_is_set(spider->do_hs_direct_update, roop_count) && - !spider->hs_w_conns[roop_count] - ) { - if ( - !(conn = - spider_get_conn(share, roop_count, - spider->conn_keys[roop_count], trx, - spider, FALSE, TRUE, - SPIDER_CONN_KIND_HS_WRITE, - &error_num)) - ) { - if ( - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_PRINT("info",("spider get conn error")); - *spider->conn_keys[0] = first_byte_bak; - spider->spider_thread_id = 0; - DBUG_RETURN(error_num); - } - conn->error_mode &= spider->error_mode; - } -#endif -#endif } if (!search_link_idx_is_checked) { @@ -3876,21 +3672,7 @@ int spider_check_trx_and_get_conn( ) { if (roop_count == spider->search_link_idx) search_link_idx_is_checked = TRUE; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if ( - !use_conn_kind || - spider->conn_kind[roop_count] == SPIDER_CONN_KIND_MYSQL - ) { -#endif - conn = spider->conns[roop_count]; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - } else if (spider->conn_kind[roop_count] == SPIDER_CONN_KIND_HS_READ) - { - conn = spider->hs_r_conns[roop_count]; - } else { - conn = spider->hs_w_conns[roop_count]; - } -#endif + conn = spider->conns[roop_count]; if (!conn) { @@ -3930,53 +3712,6 @@ int spider_check_trx_and_get_conn( } } conn->error_mode &= spider->error_mode; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if ( - spider->do_direct_update && - spider_bit_is_set(spider->do_hs_direct_update, roop_count) - ) { - conn = spider->hs_w_conns[roop_count]; - if (!conn) - { - DBUG_PRINT("info",("spider get hs_w_conn %d", roop_count)); - if ( - !(conn = - spider_get_conn(share, roop_count, - spider->conn_keys[roop_count], trx, - spider, FALSE, TRUE, - SPIDER_CONN_KIND_HS_WRITE, - &error_num)) - ) { - if ( - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - trx, - trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_PRINT("info",("spider get conn error")); - DBUG_RETURN(error_num); - } - } - } - conn->error_mode &= spider->error_mode; -#endif -#endif } if (!search_link_idx_is_checked) { @@ -4217,20 +3952,6 @@ void spider_trx_set_link_idx_for_all( share->conn_keys[0]), char*); DBUG_PRINT("info",("spider conn_keys[%d]=%s", roop_count, spider->conn_keys[roop_count])); -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - spider->hs_r_conn_keys[roop_count] = - ADD_TO_PTR(spider->conn_keys_first_ptr, - PTR_BYTE_DIFF(share->hs_read_conn_keys[conn_link_idx[roop_count]], - share->conn_keys[0]), char*); - DBUG_PRINT("info",("spider hs_r_conn_keys[%d]=%s", - roop_count, spider->hs_r_conn_keys[roop_count])); - spider->hs_w_conn_keys[roop_count] = - ADD_TO_PTR(spider->conn_keys_first_ptr, - PTR_BYTE_DIFF(share->hs_write_conn_keys[conn_link_idx[roop_count]], - share->conn_keys[0]), char*); - DBUG_PRINT("info",("spider hs_w_conn_keys[%d]=%s", - roop_count, spider->hs_w_conn_keys[roop_count])); -#endif } DBUG_VOID_RETURN; } From 6d0c9872d9579cd6315418275508974f5bbaabf7 Mon Sep 17 00:00:00 2001 From: Nayuta Yanagisawa Date: Fri, 27 May 2022 08:55:42 +0900 Subject: [PATCH 2/3] MDEV-28522 Delete constant SPIDER_SQL_TYPE_*_HS The HandlerSocket support of Spider has been deleted by MDEV-26858. Thus, the constants, SPIDER_SQL_TYPE_*_HS, are no longer necessary. --- storage/spider/spd_db_include.h | 5 -- storage/spider/spd_db_mysql.cc | 138 +++++++++----------------------- storage/spider/spd_db_mysql.h | 38 ++------- 3 files changed, 44 insertions(+), 137 deletions(-) diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index eef5ea0927a..4f25b0a2fe1 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -192,11 +192,6 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_TYPE_DROP_TMP_TABLE_SQL (1 << 6) #define SPIDER_SQL_TYPE_OTHER_SQL (1 << 7) #define SPIDER_SQL_TYPE_HANDLER (1 << 8) -#define SPIDER_SQL_TYPE_SELECT_HS (1 << 9) -#define SPIDER_SQL_TYPE_INSERT_HS (1 << 10) -#define SPIDER_SQL_TYPE_UPDATE_HS (1 << 11) -#define SPIDER_SQL_TYPE_DELETE_HS (1 << 12) -#define SPIDER_SQL_TYPE_OTHER_HS (1 << 13) enum spider_bulk_upd_start { SPD_BU_NOT_START, diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 847e9413f3b..d5f693c2cde 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -12407,23 +12407,14 @@ int spider_mbase_handler::append_from( DBUG_RETURN(0); } -int spider_mbase_handler::append_flush_tables_part( - ulong sql_type, - int link_idx, - bool lock -) { +int spider_mbase_handler::append_flush_tables_part(int link_idx, bool lock) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_flush_tables_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_flush_tables(str, link_idx, lock); DBUG_RETURN(error_num); } @@ -12451,22 +12442,14 @@ int spider_mbase_handler::append_flush_tables( DBUG_RETURN(0); } -int spider_mbase_handler::append_optimize_table_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_optimize_table_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_optimize_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_optimize_table(str, link_idx); DBUG_RETURN(error_num); } @@ -12497,22 +12480,14 @@ int spider_mbase_handler::append_optimize_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_analyze_table_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_analyze_table_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_analyze_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_analyze_table(str, link_idx); DBUG_RETURN(error_num); } @@ -12543,23 +12518,15 @@ int spider_mbase_handler::append_analyze_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_repair_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt -) { +int spider_mbase_handler::append_repair_table_part(int link_idx, + HA_CHECK_OPT *check_opt) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_repair_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_repair_table(str, link_idx, check_opt); DBUG_RETURN(error_num); } @@ -12609,23 +12576,15 @@ int spider_mbase_handler::append_repair_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_check_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt -) { +int spider_mbase_handler::append_check_table_part(int link_idx, + HA_CHECK_OPT *check_opt) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_check_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_check_table(str, link_idx, check_opt); DBUG_RETURN(error_num); } @@ -12674,22 +12633,14 @@ int spider_mbase_handler::append_check_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_enable_keys_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_enable_keys_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_enable_keys_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_enable_keys(str, link_idx); DBUG_RETURN(error_num); } @@ -12715,22 +12666,14 @@ int spider_mbase_handler::append_enable_keys( DBUG_RETURN(0); } -int spider_mbase_handler::append_disable_keys_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_disable_keys_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_disable_keys_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_disable_keys(str, link_idx); DBUG_RETURN(error_num); } @@ -14806,8 +14749,7 @@ int spider_mbase_handler::disable_keys( DBUG_ENTER("spider_mbase_handler::disable_keys"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_disable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_disable_keys_part(link_idx))) { DBUG_RETURN(error_num); } @@ -14865,8 +14807,7 @@ int spider_mbase_handler::enable_keys( DBUG_ENTER("spider_mbase_handler::enable_keys"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_enable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_enable_keys_part(link_idx))) { DBUG_RETURN(error_num); } @@ -14925,8 +14866,7 @@ int spider_mbase_handler::check_table( DBUG_ENTER("spider_mbase_handler::check_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_check_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx, check_opt))) + if ((error_num= append_check_table_part(link_idx, check_opt))) { DBUG_RETURN(error_num); } @@ -14985,8 +14925,7 @@ int spider_mbase_handler::repair_table( DBUG_ENTER("spider_mbase_handler::repair_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_repair_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx, check_opt))) + if ((error_num= append_repair_table_part(link_idx, check_opt))) { DBUG_RETURN(error_num); } @@ -15044,8 +14983,7 @@ int spider_mbase_handler::analyze_table( DBUG_ENTER("spider_mbase_handler::analyze_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_analyze_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_analyze_table_part(link_idx))) { DBUG_RETURN(error_num); } @@ -15103,8 +15041,7 @@ int spider_mbase_handler::optimize_table( DBUG_ENTER("spider_mbase_handler::optimize_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_optimize_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_optimize_table_part(link_idx))) { DBUG_RETURN(error_num); } @@ -15163,8 +15100,7 @@ int spider_mbase_handler::flush_tables( DBUG_ENTER("spider_mbase_handler::flush_tables"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_flush_tables_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx, lock))) + if ((error_num= append_flush_tables_part(link_idx, lock))) { DBUG_RETURN(error_num); } diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 846289f54e7..231e7374b81 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -1248,64 +1248,40 @@ public: ulong sql_type, int link_idx ); - int append_flush_tables_part( - ulong sql_type, - int link_idx, - bool lock - ); + int append_flush_tables_part(int link_idx, bool lock); int append_flush_tables( spider_string *str, int link_idx, bool lock ); - int append_optimize_table_part( - ulong sql_type, - int link_idx - ); + int append_optimize_table_part(int link_idx); int append_optimize_table( spider_string *str, int link_idx ); - int append_analyze_table_part( - ulong sql_type, - int link_idx - ); + int append_analyze_table_part(int link_idx); int append_analyze_table( spider_string *str, int link_idx ); - int append_repair_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt - ); + int append_repair_table_part(int link_idx, HA_CHECK_OPT *check_opt); int append_repair_table( spider_string *str, int link_idx, HA_CHECK_OPT* check_opt ); - int append_check_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt - ); + int append_check_table_part(int link_idx, HA_CHECK_OPT *check_opt); int append_check_table( spider_string *str, int link_idx, HA_CHECK_OPT* check_opt ); - int append_enable_keys_part( - ulong sql_type, - int link_idx - ); + int append_enable_keys_part(int link_idx); int append_enable_keys( spider_string *str, int link_idx ); - int append_disable_keys_part( - ulong sql_type, - int link_idx - ); + int append_disable_keys_part(int link_idx); int append_disable_keys( spider_string *str, int link_idx From 25476ba1ae18728bec2956f6ff274f38a925d56d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 9 May 2024 11:08:14 +1000 Subject: [PATCH 3/3] MDEV-29027 ASAN errors in spider_db_free_result after partition DDL Spider calls ha_spider::close() at least twice on ALTER TABLE ... ADD PARTITION. The first call frees wide_handler and the second call accesses wide_handler->trx->thd (heap-use-after-free). In general, there seems to be no problem with using THD obtained by the macro current_thd() except in background threads. Thus, we simply replace wide_handler->trx->thd with current_thd(). Original author: Nayuta Yanagasawa --- .../spider/bugfix/r/mdev_29027.result | 24 ++++++++++++++++ .../bugfix/r/mdev_29027_original.result | 15 ++++++++++ .../mysql-test/spider/bugfix/t/mdev_29027.cnf | 3 ++ .../spider/bugfix/t/mdev_29027.test | 28 +++++++++++++++++++ .../spider/bugfix/t/mdev_29027_original.test | 22 +++++++++++++++ storage/spider/spd_db_conn.cc | 8 +++--- 6 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_29027.result create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_29027_original.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_29027.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_29027.test create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_29027_original.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29027.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29027.result new file mode 100644 index 00000000000..1d9bc01fdb2 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29027.result @@ -0,0 +1,24 @@ +# +# MDEV-29027 ASAN errors in spider_db_free_result after partition DDL +# +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +CREATE DATABASE auto_test_local; +USE auto_test_local; +CREATE TABLE tbl_a ( +c INT +) ENGINE=Spider DEFAULT CHARSET=utf8 PARTITION BY HASH(c) ( +PARTITION pt1 +); +ALTER TABLE tbl_a ADD PARTITION (PARTITION pt2); +DROP DATABASE auto_test_local; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29027_original.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29027_original.result new file mode 100644 index 00000000000..56391bd5212 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29027_original.result @@ -0,0 +1,15 @@ +for master_1 +for child2 +for child3 +set spider_same_server_link= 1; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +CREATE TABLE t1 (a INT); +CREATE TABLE t_spider (a INT) ENGINE=SPIDER PARTITION BY HASH(a) (PARTITION p1 COMMENT = "wrapper 'mysql', srv 'srv', table 't1'"); +CREATE TABLE t2 (a INT); +ALTER TABLE t_spider ADD PARTITION (PARTITION p2 COMMENT = "wrapper 'mysql', srv 'srv', table 't2'"); +DROP TABLE t_spider, t1, t2; +drop server srv; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.cnf new file mode 100644 index 00000000000..05dfd8a0bce --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.cnf @@ -0,0 +1,3 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.test new file mode 100644 index 00000000000..f18154a1d28 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027.test @@ -0,0 +1,28 @@ +--echo # +--echo # MDEV-29027 ASAN errors in spider_db_free_result after partition DDL +--echo # + +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +CREATE DATABASE auto_test_local; +USE auto_test_local; + +eval CREATE TABLE tbl_a ( + c INT +) $MASTER_1_ENGINE $MASTER_1_CHARSET PARTITION BY HASH(c) ( + PARTITION pt1 +); + +ALTER TABLE tbl_a ADD PARTITION (PARTITION pt2); + +DROP DATABASE auto_test_local; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29027_original.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027_original.test new file mode 100644 index 00000000000..3a52c11c834 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29027_original.test @@ -0,0 +1,22 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log +--source include/have_partition.inc +set spider_same_server_link= 1; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); + +CREATE TABLE t1 (a INT); +CREATE TABLE t_spider (a INT) ENGINE=SPIDER PARTITION BY HASH(a) (PARTITION p1 COMMENT = "wrapper 'mysql', srv 'srv', table 't1'"); +CREATE TABLE t2 (a INT); +ALTER TABLE t_spider ADD PARTITION (PARTITION p2 COMMENT = "wrapper 'mysql', srv 'srv', table 't2'"); + +DROP TABLE t_spider, t1, t2; +drop server srv; +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 2498804ac06..22989bf88b9 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -3406,7 +3406,7 @@ int spider_db_free_result( SPIDER_RESULT *result; SPIDER_RESULT *prev; SPIDER_SHARE *share = spider->share; - SPIDER_TRX *trx = spider->wide_handler->trx; + THD *thd= current_thd; SPIDER_POSITION *position; int roop_count, error_num; DBUG_ENTER("spider_db_free_result"); @@ -3423,10 +3423,10 @@ int spider_db_free_result( if ( final || - spider_param_reset_sql_alloc(trx->thd, share->reset_sql_alloc) == 1 + spider_param_reset_sql_alloc(thd, share->reset_sql_alloc) == 1 ) { int alloc_size = final ? 0 : - (spider_param_init_sql_alloc_size(trx->thd, share->init_sql_alloc_size)); + (spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size)); while (result) { position = result->first_position; @@ -3469,7 +3469,7 @@ int spider_db_free_result( { ulong realloced = 0; int init_sql_alloc_size = - spider_param_init_sql_alloc_size(trx->thd, share->init_sql_alloc_size); + spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); for (roop_count = 0; roop_count < (int) share->use_dbton_count; roop_count++) {