From e7570c7759ea5bb13b64e8dafec176cbbda97adb Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 17 Jun 2024 13:15:42 +0800 Subject: [PATCH 1/9] MDEV-31788 Remove spider_file_pos They are for unnecessary debugging purposes only. --- storage/spider/ha_spider.cc | 47 ---------- storage/spider/spd_conn.cc | 10 -- storage/spider/spd_db_conn.cc | 123 ------------------------ storage/spider/spd_db_mysql.cc | 124 ------------------------- storage/spider/spd_db_oracle.cc | 64 ------------- storage/spider/spd_direct_sql.cc | 1 - storage/spider/spd_group_by_handler.cc | 3 - storage/spider/spd_include.h | 14 --- storage/spider/spd_table.cc | 3 - 9 files changed, 389 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 814eee073be..8fff0c5b673 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1761,7 +1761,6 @@ int ha_spider::index_read_map_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if ( @@ -1771,7 +1770,6 @@ int ha_spider::index_read_map_internal( ) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -1787,7 +1785,6 @@ int ha_spider::index_read_map_internal( 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); if ( share->monitoring_kind[roop_count] && @@ -1884,7 +1881,6 @@ int ha_spider::index_read_map_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -2221,14 +2217,12 @@ int ha_spider::index_read_last_map_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -2244,7 +2238,6 @@ int ha_spider::index_read_last_map_internal( 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); if ( share->monitoring_kind[roop_count] && @@ -2341,7 +2334,6 @@ int ha_spider::index_read_last_map_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -2676,14 +2668,12 @@ int ha_spider::index_first_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -2699,7 +2689,6 @@ int ha_spider::index_first_internal( 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); if ( share->monitoring_kind[roop_count] && @@ -2796,7 +2785,6 @@ int ha_spider::index_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -3048,14 +3036,12 @@ int ha_spider::index_last_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -3071,7 +3057,6 @@ int ha_spider::index_last_internal( 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); if ( share->monitoring_kind[roop_count] && @@ -3168,7 +3153,6 @@ int ha_spider::index_last_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -3478,14 +3462,12 @@ int ha_spider::read_range_first_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } else { #endif @@ -3501,7 +3483,6 @@ int ha_spider::read_range_first_internal( 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); if ( share->monitoring_kind[roop_count] && @@ -3598,7 +3579,6 @@ int ha_spider::read_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -4091,14 +4071,12 @@ int ha_spider::read_multi_range_first_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL *range_info = (char *) mrr_cur_range.ptr; @@ -4120,7 +4098,6 @@ int ha_spider::read_multi_range_first_internal( 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); if ( share->monitoring_kind[roop_count] && @@ -4218,7 +4195,6 @@ int ha_spider::read_multi_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -4867,7 +4843,6 @@ int ha_spider::read_multi_range_first_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS @@ -4875,7 +4850,6 @@ int ha_spider::read_multi_range_first_internal( { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL *range_info = multi_range_keys[multi_range_hit_point]; @@ -4897,7 +4871,6 @@ int ha_spider::read_multi_range_first_internal( 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); if ( share->monitoring_kind[roop_count] && @@ -5039,7 +5012,6 @@ int ha_spider::read_multi_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -5502,14 +5474,12 @@ int ha_spider::read_multi_range_next( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS if (is_bulk_access_clone) { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL *range_info = multi_range_keys[multi_range_hit_point]; @@ -5531,7 +5501,6 @@ int ha_spider::read_multi_range_next( 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); if ( share->monitoring_kind[roop_count] && @@ -5629,7 +5598,6 @@ int ha_spider::read_multi_range_next( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -6277,7 +6245,6 @@ int ha_spider::read_multi_range_next( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS @@ -6285,7 +6252,6 @@ int ha_spider::read_multi_range_next( { connection_ids[roop_count] = conn->connection_id; spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); #ifdef HA_MRR_USE_DEFAULT_IMPL *range_info = multi_range_keys[multi_range_hit_point]; @@ -6307,7 +6273,6 @@ int ha_spider::read_multi_range_next( 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); if ( share->monitoring_kind[roop_count] && @@ -6449,7 +6414,6 @@ int ha_spider::read_multi_range_next( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifdef HA_CAN_BULK_ACCESS @@ -6934,7 +6898,6 @@ int ha_spider::rnd_next_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); @@ -6948,7 +6911,6 @@ int ha_spider::rnd_next_internal( 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); if ( share->monitoring_kind[roop_count] && @@ -7045,7 +7007,6 @@ int ha_spider::rnd_next_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -7552,7 +7513,6 @@ int ha_spider::ft_read_internal( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7564,7 +7524,6 @@ int ha_spider::ft_read_internal( 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); if ( share->monitoring_kind[roop_count] && @@ -7661,7 +7620,6 @@ int ha_spider::ft_read_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -10350,7 +10308,6 @@ void ha_spider::bulk_req_exec() spider_bg_conn_wait(conn); 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); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10375,7 +10332,6 @@ void ha_spider::bulk_req_exec() 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); } conn = conn->bulk_access_next; @@ -11998,7 +11954,6 @@ int ha_spider::drop_tmp_tables() DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -12010,7 +11965,6 @@ int ha_spider::drop_tmp_tables() 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); if ( share->monitoring_kind[roop_count] && @@ -12077,7 +12031,6 @@ int ha_spider::drop_tmp_tables() 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); } } diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 7c65f1d02eb..434a20e9e3e 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -276,7 +276,6 @@ int spider_free_conn_alloc( conn->db_conn = NULL; } spider_conn_done(conn); - DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name); pthread_mutex_destroy(&conn->mta_conn_mutex); conn->default_database.free(); DBUG_RETURN(0); @@ -1458,10 +1457,6 @@ void spider_conn_clear_queue( ) { DBUG_ENTER("spider_conn_clear_queue"); DBUG_PRINT("info", ("spider conn=%p", conn)); -/* - conn->queued_connect = FALSE; - conn->queued_ping = FALSE; -*/ conn->queued_trx_isolation = FALSE; conn->queued_semi_trx_isolation = FALSE; conn->queued_autocommit = FALSE; @@ -2593,7 +2588,6 @@ void *spider_bg_conn_action( } } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); #ifdef HA_CAN_BULK_ACCESS @@ -2689,10 +2683,8 @@ void *spider_bg_conn_action( 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); } else { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } else { @@ -2770,7 +2762,6 @@ void *spider_bg_conn_action( spider = (ha_spider*) conn->bg_target; 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); conn->need_mon = &spider->need_mons[conn->link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2786,7 +2777,6 @@ void *spider_bg_conn_action( 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); conn->bg_exec_sql = FALSE; continue; diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 046e024522f..7d786492bfe 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -179,7 +179,6 @@ int spider_db_ping_internal( int error_num; DBUG_ENTER("spider_db_ping_internal"); pthread_mutex_assert_owner(&conn->mta_conn_mutex); - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if (conn->server_lost || conn->queued_connect) { if ((error_num = spider_db_connect(share, conn, all_link_idx))) @@ -570,7 +569,6 @@ int spider_db_before_query( #endif conn->in_before_query = TRUE; pthread_mutex_assert_owner(&conn->mta_conn_mutex); - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if ((error_num = spider_db_conn_queue_action(conn))) { conn->in_before_query = FALSE; @@ -676,7 +674,6 @@ int spider_db_errorno( 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); @@ -698,7 +695,6 @@ int spider_db_errorno( 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); @@ -711,7 +707,6 @@ int spider_db_errorno( 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); @@ -737,7 +732,6 @@ int spider_db_errorno( 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); @@ -759,7 +753,6 @@ int spider_db_errorno( 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); @@ -767,7 +760,6 @@ int spider_db_errorno( 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(0); @@ -791,7 +783,6 @@ int spider_db_set_names_internal( ) { DBUG_ENTER("spider_db_set_names_internal"); 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); DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); if ( @@ -944,7 +935,6 @@ int spider_db_query_for_bulk_update( 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); if ( share->monitoring_kind[link_idx] && @@ -1032,7 +1022,6 @@ int spider_db_query_for_bulk_update( 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); if ( share->monitoring_kind[link_idx] && @@ -1061,7 +1050,6 @@ int spider_db_query_for_bulk_update( 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(0); } @@ -3594,7 +3582,6 @@ int spider_db_store_result( 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); @@ -3611,7 +3598,6 @@ int spider_db_store_result( 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_OUT_OF_MEM); @@ -3643,7 +3629,6 @@ int spider_db_store_result( 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_OUT_OF_MEM); @@ -3688,7 +3673,6 @@ int spider_db_store_result( 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_OUT_OF_MEM); @@ -3729,7 +3713,6 @@ int spider_db_store_result( 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); @@ -3758,7 +3741,6 @@ int spider_db_store_result( if (!conn->mta_conn_mutex_unlock_later && !call_db_errorno) { 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_END_OF_FILE); @@ -3766,7 +3748,6 @@ int spider_db_store_result( 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); } current->record_num = current->result->num_rows(); @@ -3810,7 +3791,6 @@ int spider_db_store_result( 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); } } else { @@ -3835,7 +3815,6 @@ int spider_db_store_result( 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); } } @@ -3847,7 +3826,6 @@ int spider_db_store_result( 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); } } @@ -4760,7 +4738,6 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if (conn->db_conn->limit_mode() == 1) { conn->db_conn->set_limit(result_list->limit_num); @@ -4769,12 +4746,10 @@ int spider_db_seek_next( if ((error_num = spider_db_store_result_for_reuse_cursor( spider, link_idx, table))) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); DBUG_RETURN(error_num); } } - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); } else { conn->need_mon = &spider->need_mons[link_idx]; @@ -4788,7 +4763,6 @@ int spider_db_seek_next( 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); if ( spider->need_mons[link_idx] @@ -4842,7 +4816,6 @@ int spider_db_seek_next( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, link_idx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -4872,7 +4845,6 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if (conn->db_conn->limit_mode() == 1) { conn->db_conn->set_limit(result_list->limit_num); @@ -4881,12 +4853,10 @@ int spider_db_seek_next( if ((error_num = spider_db_store_result_for_reuse_cursor( spider, link_idx, table))) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); DBUG_RETURN(error_num); } } - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); } else { conn->need_mon = &spider->need_mons[roop_count]; @@ -4900,7 +4870,6 @@ int spider_db_seek_next( 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); if ( share->monitoring_kind[roop_count] && @@ -5001,7 +4970,6 @@ int spider_db_seek_next( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -5145,7 +5113,6 @@ int spider_db_seek_last( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); if (conn->db_conn->limit_mode() == 1) { @@ -5155,12 +5122,10 @@ int spider_db_seek_last( if ((error_num = spider_db_store_result_for_reuse_cursor( spider, roop_count, table))) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); DBUG_RETURN(error_num); } } - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->bg_conn_mutex); } else { conn->need_mon = &spider->need_mons[roop_count]; @@ -5174,7 +5139,6 @@ int spider_db_seek_last( 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); if ( share->monitoring_kind[roop_count] && @@ -5272,7 +5236,6 @@ int spider_db_seek_last( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -5367,7 +5330,6 @@ int spider_db_seek_last( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); @@ -5380,7 +5342,6 @@ int spider_db_seek_last( 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); if ( share->monitoring_kind[roop_count] && @@ -5478,7 +5439,6 @@ int spider_db_seek_last( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } } @@ -6138,7 +6098,6 @@ int spider_db_bulk_insert( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[roop_count2]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6152,7 +6111,6 @@ int spider_db_bulk_insert( 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); if ( share->monitoring_kind[roop_count2] && @@ -6197,7 +6155,6 @@ int spider_db_bulk_insert( 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); if ( error_num != ER_DUP_ENTRY && @@ -6234,7 +6191,6 @@ int spider_db_bulk_insert( insert_info = conn->db_conn->inserted_info(dbton_handler, copy_info); } - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (first_insert_link_idx == -1) { @@ -6246,7 +6202,6 @@ int spider_db_bulk_insert( conn = first_insert_conn; 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); conn->need_mon = &spider->need_mons[first_insert_link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6275,7 +6230,6 @@ int spider_db_bulk_insert( 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); } @@ -6290,7 +6244,6 @@ int spider_db_bulk_insert( 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); } @@ -6299,7 +6252,6 @@ int spider_db_bulk_insert( 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); spider->store_last_insert_id = 0; #ifdef HA_CAN_BULK_ACCESS @@ -6337,7 +6289,6 @@ int spider_db_bulk_bulk_insert( conn = spider->conns[roop_count2]; 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); DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; @@ -6351,7 +6302,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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if (first_insert_link_idx == -1) { @@ -6363,7 +6313,6 @@ int spider_db_bulk_bulk_insert( conn = first_insert_conn; 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); conn->need_mon = &spider->need_mons[first_insert_link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6397,7 +6346,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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); spider->store_last_insert_id = 0; DBUG_RETURN(error_num); @@ -6512,7 +6460,6 @@ int spider_db_bulk_update_size_limit( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if ((error_num = spider_db_query_for_bulk_update( spider, conn, roop_count, &dup_key_found))) { @@ -6596,7 +6543,6 @@ int spider_db_bulk_update_end( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if ((error_num = spider_db_query_for_bulk_update( spider, conn, roop_count, dup_key_found))) { @@ -6635,7 +6581,6 @@ int spider_db_bulk_update_end( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); if ((error_num = spider_db_query_for_bulk_update( spider, conn, roop_count, dup_key_found))) { @@ -6715,7 +6660,6 @@ int spider_db_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6727,7 +6671,6 @@ int spider_db_update( 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); if ( share->monitoring_kind[roop_count] && @@ -6806,7 +6749,6 @@ int spider_db_update( 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); } @@ -6855,7 +6797,6 @@ int spider_db_update( 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); result_list->update_sqls[roop_count].length(0); } @@ -6976,7 +6917,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); #ifdef HA_CAN_BULK_ACCESS if (spider->is_bulk_access_clone) { @@ -6995,7 +6935,6 @@ int spider_db_direct_update( 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); if ( share->monitoring_kind[roop_count] && @@ -7078,7 +7017,6 @@ int spider_db_direct_update( #ifdef HA_CAN_BULK_ACCESS } #endif - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -7187,7 +7125,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); #ifdef HA_CAN_BULK_ACCESS if (spider->is_bulk_access_clone) { @@ -7206,7 +7143,6 @@ int spider_db_direct_update( 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); if ( share->monitoring_kind[roop_count] && @@ -7290,7 +7226,6 @@ int spider_db_direct_update( #ifdef HA_CAN_BULK_ACCESS } #endif - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -7322,7 +7257,6 @@ int spider_db_bulk_direct_update( conn = spider->conns[roop_count]; 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); DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; @@ -7344,7 +7278,6 @@ int spider_db_bulk_direct_update( 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); @@ -7405,7 +7338,6 @@ int spider_db_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; @@ -7417,7 +7349,6 @@ int spider_db_delete( 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); } @@ -7425,7 +7356,6 @@ int spider_db_delete( 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); result_list->update_sqls[roop_count].length(0); } @@ -7517,7 +7447,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); #ifdef HA_CAN_BULK_ACCESS if (spider->is_bulk_access_clone) { @@ -7536,7 +7465,6 @@ 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7611,7 +7539,6 @@ int spider_db_direct_delete( #ifdef HA_CAN_BULK_ACCESS } #endif - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } int error_num2 = 0; @@ -7696,7 +7623,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); #ifdef HA_CAN_BULK_ACCESS if (spider->is_bulk_access_clone) { @@ -7715,7 +7641,6 @@ 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); if ( share->monitoring_kind[roop_count] && @@ -7790,7 +7715,6 @@ int spider_db_direct_delete( #ifdef HA_CAN_BULK_ACCESS } #endif - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } int error_num2 = 0; @@ -7833,7 +7757,6 @@ int spider_db_delete_all_rows( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7864,7 +7787,6 @@ int spider_db_delete_all_rows( 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); if ( share->monitoring_kind[roop_count] && @@ -7895,7 +7817,6 @@ int spider_db_delete_all_rows( 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); if ( share->monitoring_kind[roop_count] && @@ -7962,7 +7883,6 @@ int spider_db_delete_all_rows( 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); if ( share->monitoring_kind[roop_count] && @@ -7992,7 +7912,6 @@ int spider_db_delete_all_rows( 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); } if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) @@ -9803,7 +9722,6 @@ int spider_db_udf_direct_sql( 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); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10034,7 +9952,6 @@ int spider_db_udf_direct_sql( 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); if (need_trx_end && insert_start) { @@ -10068,7 +9985,6 @@ int spider_db_udf_direct_sql_select_db( if ( spider_dbton[conn->dbton_id].db_util->database_has_default_value() ) { - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if ( !conn->default_database.length() || conn->default_database.length() != @@ -10111,7 +10027,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); - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); if ( !conn->access_charset || trx->udf_access_charset->cset != conn->access_charset->cset @@ -10198,7 +10113,6 @@ int spider_db_udf_ping_table( spider.db_request_id = &db_request_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); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10210,7 +10124,6 @@ int spider_db_udf_ping_table( 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); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); @@ -10227,7 +10140,6 @@ int spider_db_udf_ping_table( 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); if (!ping_only) { @@ -10273,7 +10185,6 @@ int spider_db_udf_ping_table( } 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); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10285,7 +10196,6 @@ int spider_db_udf_ping_table( 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); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); @@ -10317,7 +10227,6 @@ int spider_db_udf_ping_table( conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; spider_db_discard_result(&spider, 0, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); } @@ -10536,7 +10445,6 @@ int spider_db_udf_ping_table_mon_next( 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); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10548,7 +10456,6 @@ int spider_db_udf_ping_table_mon_next( 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); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), share->server_names[0]); @@ -10561,7 +10468,6 @@ int spider_db_udf_ping_table_mon_next( 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); my_afree(sql_buf); DBUG_RETURN(error_num); @@ -10595,7 +10501,6 @@ int spider_db_udf_ping_table_mon_next( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); DBUG_RETURN(error_num); @@ -10613,7 +10518,6 @@ int spider_db_udf_ping_table_mon_next( 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); my_afree(sql_buf); error_num = res->fetch_table_mon_status(mon_table_result->result_status); @@ -10699,7 +10603,6 @@ int spider_db_udf_copy_tables( { pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); tmp_conn->need_mon = &tmp_spider->need_mons[0]; DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); @@ -10711,7 +10614,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), tmp_spider->share->server_names[0]); @@ -10727,7 +10629,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_start_transaction; } @@ -10735,7 +10636,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); } } @@ -10758,7 +10658,6 @@ int spider_db_udf_copy_tables( tmp_conn = tmp_spider->conns[0]; pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); tmp_conn->need_mon = &tmp_spider->need_mons[0]; DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); @@ -10770,7 +10669,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), tmp_spider->share->server_names[0]); @@ -10788,7 +10686,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); tmp_conn->table_lock = 0; if (error_num == HA_ERR_OUT_OF_MEM) @@ -10799,7 +10696,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); tmp_conn->table_lock = 1; } @@ -10810,7 +10706,6 @@ int spider_db_udf_copy_tables( copy_tables->trx->thd, src_tbl_conn->share); pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); tmp_conn->need_mon = &src_tbl_conn->need_mon; DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); @@ -10857,7 +10752,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_db_query; } @@ -10876,7 +10770,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_db_query; } @@ -10906,7 +10799,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_db_query; } @@ -10925,7 +10817,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); error_num = ER_OUT_OF_RESOURCES; goto error_db_query; @@ -10941,7 +10832,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_db_query; } @@ -10951,7 +10841,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; dst_tbl_conn = dst_tbl_conn->next) @@ -10975,7 +10864,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, @@ -10988,7 +10876,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); } } @@ -11032,7 +10919,6 @@ int spider_db_udf_copy_tables( insert_ct = dst_tbl_conn->copy_table; pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); tmp_conn->need_mon = &dst_tbl_conn->need_mon; DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); @@ -11059,7 +10945,6 @@ int spider_db_udf_copy_tables( DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); tmp_conn->mta_conn_mutex_lock_already = FALSE; tmp_conn->mta_conn_mutex_unlock_later = FALSE; - SPIDER_CLEAR_FILE_POS(&tmp_conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); } } @@ -11205,9 +11090,7 @@ int spider_db_open_handler( DBUG_ENTER("spider_db_open_handler"); 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); conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name); DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; @@ -11251,7 +11134,6 @@ int spider_db_open_handler( 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(0); @@ -11260,7 +11142,6 @@ error: 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); } @@ -11292,7 +11173,6 @@ int spider_db_close_handler( DBUG_PRINT("info",("spider conn=%p", conn)); 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11308,7 +11188,6 @@ int spider_db_close_handler( 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); } @@ -11335,7 +11214,6 @@ int spider_db_close_handler( 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(0); @@ -11344,7 +11222,6 @@ error: 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); } diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index ed92a5d2e64..62fb57c8724 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -2496,7 +2496,6 @@ int spider_db_mbase::consistent_snapshot( DBUG_PRINT("info",("spider this=%p", this)); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2519,7 +2518,6 @@ int spider_db_mbase::consistent_snapshot( 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(0); } @@ -2558,7 +2556,6 @@ int spider_db_mbase::commit( DBUG_PRINT("info",("spider this=%p", this)); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2581,7 +2578,6 @@ int spider_db_mbase::commit( 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(0); } @@ -2595,7 +2591,6 @@ int spider_db_mbase::rollback( DBUG_PRINT("info",("spider this=%p", this)); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2620,7 +2615,6 @@ int spider_db_mbase::rollback( 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); } @@ -2629,7 +2623,6 @@ int spider_db_mbase::rollback( 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(0); } @@ -2666,7 +2659,6 @@ int spider_db_mbase::xa_end( spider_db_append_xid_str(&sql_str, xid); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2689,7 +2681,6 @@ int spider_db_mbase::xa_end( 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(0); } @@ -2709,7 +2700,6 @@ int spider_db_mbase::xa_prepare( spider_db_append_xid_str(&sql_str, xid); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2732,7 +2722,6 @@ int spider_db_mbase::xa_prepare( 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(0); } @@ -2752,7 +2741,6 @@ int spider_db_mbase::xa_commit( spider_db_append_xid_str(&sql_str, xid); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2775,7 +2763,6 @@ int spider_db_mbase::xa_commit( 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(0); } @@ -2795,7 +2782,6 @@ int spider_db_mbase::xa_rollback( spider_db_append_xid_str(&sql_str, xid); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2818,7 +2804,6 @@ int spider_db_mbase::xa_rollback( 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(0); } @@ -2841,7 +2826,6 @@ int spider_db_mbase::set_trx_isolation( case ISO_READ_UNCOMMITTED: 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2864,13 +2848,11 @@ int spider_db_mbase::set_trx_isolation( 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); break; case ISO_READ_COMMITTED: 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2893,13 +2875,11 @@ int spider_db_mbase::set_trx_isolation( 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); break; case ISO_REPEATABLE_READ: 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2922,13 +2902,11 @@ int spider_db_mbase::set_trx_isolation( 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); break; case ISO_SERIALIZABLE: 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2951,7 +2929,6 @@ int spider_db_mbase::set_trx_isolation( 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); break; default: @@ -2977,7 +2954,6 @@ int spider_db_mbase::set_autocommit( { 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3000,12 +2976,10 @@ int spider_db_mbase::set_autocommit( 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); } else { 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3028,7 +3002,6 @@ int spider_db_mbase::set_autocommit( 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(0); @@ -3051,7 +3024,6 @@ int spider_db_mbase::set_sql_log_off( { 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3074,12 +3046,10 @@ int spider_db_mbase::set_sql_log_off( 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); } else { 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3102,7 +3072,6 @@ int spider_db_mbase::set_sql_log_off( 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(0); @@ -3135,7 +3104,6 @@ int spider_db_mbase::set_wait_timeout( sql_str.q_append(timeout_str, timeout_str_length); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3158,7 +3126,6 @@ int spider_db_mbase::set_wait_timeout( 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(0); } @@ -3200,7 +3167,6 @@ int spider_db_mbase::set_sql_mode( sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3223,7 +3189,6 @@ int spider_db_mbase::set_sql_mode( 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(0); } @@ -3254,7 +3219,6 @@ int spider_db_mbase::set_time_zone( sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3277,7 +3241,6 @@ int spider_db_mbase::set_time_zone( 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(0); } @@ -3295,7 +3258,6 @@ int spider_db_mbase::exec_simple_sql_with_result( DBUG_ENTER("spider_db_mbase::exec_simple_sql_with_result"); 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3328,7 +3290,6 @@ int spider_db_mbase::exec_simple_sql_with_result( 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_PRINT("info", ("spider error_num=%d 1", error_num)); DBUG_RETURN(error_num); @@ -3340,7 +3301,6 @@ int spider_db_mbase::exec_simple_sql_with_result( 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_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); @@ -3366,7 +3326,6 @@ int spider_db_mbase::exec_simple_sql_with_result( 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_PRINT("info", ("spider error_num=%d 4", error_num)); DBUG_RETURN(error_num); @@ -3380,7 +3339,6 @@ int spider_db_mbase::exec_simple_sql_with_result( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); DBUG_RETURN(error_num); @@ -3399,7 +3357,6 @@ int spider_db_mbase::exec_simple_sql_with_result( 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(0); } @@ -7955,7 +7912,6 @@ int spider_mbase_share::discover_table_structure( } 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); conn->need_mon = &need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7979,7 +7935,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8004,7 +7959,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8025,7 +7979,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8035,7 +7988,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8049,7 +8001,6 @@ int spider_mbase_share::discover_table_structure( 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); my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), @@ -8067,7 +8018,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8081,7 +8031,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8091,7 +8040,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8105,7 +8053,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8118,7 +8065,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8132,7 +8078,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8142,7 +8087,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8156,7 +8100,6 @@ int spider_mbase_share::discover_table_structure( 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); continue; } @@ -8166,7 +8109,6 @@ int spider_mbase_share::discover_table_structure( 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); if (!error_num) break; @@ -13473,7 +13415,6 @@ int spider_mbase_handler::show_table_status( { 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -13507,7 +13448,6 @@ int spider_mbase_handler::show_table_status( 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); } @@ -13518,7 +13458,6 @@ int spider_mbase_handler::show_table_status( 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); } @@ -13545,7 +13484,6 @@ int spider_mbase_handler::show_table_status( 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); } @@ -13563,7 +13501,6 @@ int spider_mbase_handler::show_table_status( 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(0); } @@ -13576,7 +13513,6 @@ int spider_mbase_handler::show_table_status( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_RETURN(error_num); } @@ -13596,7 +13532,6 @@ int spider_mbase_handler::show_table_status( 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); error_num = res->fetch_table_status( sts_mode, @@ -13631,7 +13566,6 @@ int spider_mbase_handler::show_table_status( } else { 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -13665,7 +13599,6 @@ int spider_mbase_handler::show_table_status( 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); } @@ -13676,7 +13609,6 @@ int spider_mbase_handler::show_table_status( 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); } @@ -13703,7 +13635,6 @@ int spider_mbase_handler::show_table_status( 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); } @@ -13721,7 +13652,6 @@ int spider_mbase_handler::show_table_status( 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(0); } @@ -13742,7 +13672,6 @@ int spider_mbase_handler::show_table_status( 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); error_num = res->fetch_table_status( sts_mode, @@ -13822,7 +13751,6 @@ int spider_mbase_handler::show_index( { 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -13854,7 +13782,6 @@ int spider_mbase_handler::show_index( 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); } @@ -13864,7 +13791,6 @@ int spider_mbase_handler::show_index( 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); } @@ -13889,7 +13815,6 @@ int spider_mbase_handler::show_index( 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); } @@ -13908,7 +13833,6 @@ int spider_mbase_handler::show_index( 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); } @@ -13918,7 +13842,6 @@ int spider_mbase_handler::show_index( 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); if (res) { @@ -13972,7 +13895,6 @@ int spider_mbase_handler::show_index( } else { 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14004,7 +13926,6 @@ int spider_mbase_handler::show_index( 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); } @@ -14014,7 +13935,6 @@ int spider_mbase_handler::show_index( 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); } @@ -14039,7 +13959,6 @@ int spider_mbase_handler::show_index( 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); } @@ -14058,7 +13977,6 @@ int spider_mbase_handler::show_index( 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); } @@ -14068,7 +13986,6 @@ int spider_mbase_handler::show_index( 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); if (res) { @@ -14175,7 +14092,6 @@ int spider_mbase_handler::simple_action( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14207,7 +14123,6 @@ int spider_mbase_handler::simple_action( 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_PRINT("info", ("spider error_num=%d 1", error_num)); DBUG_RETURN(error_num); @@ -14218,7 +14133,6 @@ int spider_mbase_handler::simple_action( 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_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); @@ -14245,7 +14159,6 @@ int spider_mbase_handler::simple_action( 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_PRINT("info", ("spider error_num=%d 4", error_num)); DBUG_RETURN(error_num); @@ -14265,7 +14178,6 @@ int spider_mbase_handler::simple_action( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); DBUG_RETURN(error_num); @@ -14284,7 +14196,6 @@ int spider_mbase_handler::simple_action( 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); switch (simple_action) { @@ -14364,7 +14275,6 @@ ha_rows spider_mbase_handler::explain_select( 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14398,7 +14308,6 @@ ha_rows spider_mbase_handler::explain_select( 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(HA_POS_ERROR); } @@ -14410,7 +14319,6 @@ ha_rows spider_mbase_handler::explain_select( 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(HA_POS_ERROR); } @@ -14431,7 +14339,6 @@ ha_rows spider_mbase_handler::explain_select( 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(HA_POS_ERROR); } @@ -14442,7 +14349,6 @@ ha_rows spider_mbase_handler::explain_select( 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(HA_POS_ERROR); } @@ -14463,7 +14369,6 @@ ha_rows spider_mbase_handler::explain_select( 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(HA_POS_ERROR); } else { @@ -14472,7 +14377,6 @@ ha_rows spider_mbase_handler::explain_select( 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(HA_POS_ERROR); } @@ -14481,7 +14385,6 @@ ha_rows spider_mbase_handler::explain_select( 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); error_num = res->fetch_table_records( 2, @@ -14513,7 +14416,6 @@ int spider_mbase_handler::lock_tables( { 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14525,7 +14427,6 @@ int spider_mbase_handler::lock_tables( 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); } @@ -14549,7 +14450,6 @@ int spider_mbase_handler::lock_tables( 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); } if (!conn->table_locked) @@ -14584,7 +14484,6 @@ int spider_mbase_handler::unlock_tables( spider->share); 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14607,7 +14506,6 @@ int spider_mbase_handler::unlock_tables( 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); } } @@ -14630,7 +14528,6 @@ int spider_mbase_handler::disable_keys( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14642,7 +14539,6 @@ int spider_mbase_handler::disable_keys( 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); } @@ -14667,7 +14563,6 @@ int spider_mbase_handler::disable_keys( 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(0); } @@ -14688,7 +14583,6 @@ int spider_mbase_handler::enable_keys( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14700,7 +14594,6 @@ int spider_mbase_handler::enable_keys( 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); } @@ -14725,7 +14618,6 @@ int spider_mbase_handler::enable_keys( 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(0); } @@ -14747,7 +14639,6 @@ int spider_mbase_handler::check_table( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14759,7 +14650,6 @@ int spider_mbase_handler::check_table( 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); } @@ -14784,7 +14674,6 @@ int spider_mbase_handler::check_table( 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(0); } @@ -14806,7 +14695,6 @@ int spider_mbase_handler::repair_table( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14818,7 +14706,6 @@ int spider_mbase_handler::repair_table( 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); } @@ -14843,7 +14730,6 @@ int spider_mbase_handler::repair_table( 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(0); } @@ -14864,7 +14750,6 @@ int spider_mbase_handler::analyze_table( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14876,7 +14761,6 @@ int spider_mbase_handler::analyze_table( 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); } @@ -14901,7 +14785,6 @@ int spider_mbase_handler::analyze_table( 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(0); } @@ -14922,7 +14805,6 @@ int spider_mbase_handler::optimize_table( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -14934,7 +14816,6 @@ int spider_mbase_handler::optimize_table( 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); } @@ -14959,7 +14840,6 @@ int spider_mbase_handler::optimize_table( 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(0); } @@ -14984,7 +14864,6 @@ int spider_mbase_handler::flush_tables( share); 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -15008,7 +14887,6 @@ int spider_mbase_handler::flush_tables( 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(0); } @@ -15026,7 +14904,6 @@ int spider_mbase_handler::flush_logs( share); 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -15050,7 +14927,6 @@ int spider_mbase_handler::flush_logs( 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(0); } diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index e0eeaf2975b..9ed1aa32a96 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -2011,7 +2011,6 @@ int spider_db_oracle::set_trx_isolation( } 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2034,7 +2033,6 @@ int spider_db_oracle::set_trx_isolation( 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); break; case ISO_REPEATABLE_READ: @@ -2046,7 +2044,6 @@ int spider_db_oracle::set_trx_isolation( } 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2069,7 +2066,6 @@ int spider_db_oracle::set_trx_isolation( 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); break; default: @@ -2100,7 +2096,6 @@ int spider_db_oracle::set_autocommit( } 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2123,7 +2118,6 @@ int spider_db_oracle::set_autocommit( 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); } else { if (conn->in_before_query) @@ -2133,7 +2127,6 @@ int spider_db_oracle::set_autocommit( } 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); conn->need_mon = need_mon; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2156,7 +2149,6 @@ int spider_db_oracle::set_autocommit( 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(0); @@ -10844,7 +10836,6 @@ int spider_oracle_handler::show_table_status( } else { 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -10876,7 +10867,6 @@ int spider_oracle_handler::show_table_status( 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); } @@ -10886,7 +10876,6 @@ int spider_oracle_handler::show_table_status( 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); } @@ -10911,7 +10900,6 @@ int spider_oracle_handler::show_table_status( 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); } @@ -10937,7 +10925,6 @@ int spider_oracle_handler::show_table_status( 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); error_num = res->fetch_table_status( sts_mode, @@ -10996,7 +10983,6 @@ int spider_oracle_handler::show_index( } else { 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11028,7 +11014,6 @@ int spider_oracle_handler::show_index( 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); } @@ -11038,7 +11023,6 @@ int spider_oracle_handler::show_index( 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); } @@ -11063,7 +11047,6 @@ int spider_oracle_handler::show_index( 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); } @@ -11082,7 +11065,6 @@ int spider_oracle_handler::show_index( 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); } @@ -11092,7 +11074,6 @@ int spider_oracle_handler::show_index( 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); if (res) { @@ -11137,7 +11118,6 @@ int spider_oracle_handler::show_records( DBUG_ENTER("spider_oracle_handler::show_records"); 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11169,7 +11149,6 @@ int spider_oracle_handler::show_records( 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_PRINT("info", ("spider error_num=%d 1", error_num)); DBUG_RETURN(error_num); @@ -11180,7 +11159,6 @@ int spider_oracle_handler::show_records( 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_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); @@ -11207,7 +11185,6 @@ int spider_oracle_handler::show_records( 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_PRINT("info", ("spider error_num=%d 4", error_num)); DBUG_RETURN(error_num); @@ -11227,7 +11204,6 @@ int spider_oracle_handler::show_records( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); DBUG_RETURN(error_num); @@ -11246,7 +11222,6 @@ int spider_oracle_handler::show_records( 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); error_num = res->fetch_table_records( 1, @@ -11278,7 +11253,6 @@ int spider_oracle_handler::show_autoinc( 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11310,7 +11284,6 @@ int spider_oracle_handler::show_autoinc( 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_PRINT("info", ("spider error_num=%d 1", error_num)); DBUG_RETURN(error_num); @@ -11321,7 +11294,6 @@ int spider_oracle_handler::show_autoinc( 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_PRINT("info", ("spider error_num=%d 2", error_num)); DBUG_RETURN(error_num); @@ -11348,7 +11320,6 @@ int spider_oracle_handler::show_autoinc( 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_PRINT("info", ("spider error_num=%d 4", error_num)); DBUG_RETURN(error_num); @@ -11368,7 +11339,6 @@ int spider_oracle_handler::show_autoinc( conn->mta_conn_mutex_unlock_later = FALSE; if (error_num) { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); DBUG_RETURN(error_num); @@ -11387,7 +11357,6 @@ int spider_oracle_handler::show_autoinc( 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); error_num = res->fetch_table_records( 1, @@ -11496,7 +11465,6 @@ ha_rows spider_oracle_handler::explain_select( 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11530,7 +11498,6 @@ ha_rows spider_oracle_handler::explain_select( 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(HA_POS_ERROR); } @@ -11542,7 +11509,6 @@ ha_rows spider_oracle_handler::explain_select( 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(HA_POS_ERROR); } @@ -11563,7 +11529,6 @@ ha_rows spider_oracle_handler::explain_select( 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(HA_POS_ERROR); } @@ -11574,7 +11539,6 @@ ha_rows spider_oracle_handler::explain_select( 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(HA_POS_ERROR); } @@ -11595,7 +11559,6 @@ ha_rows spider_oracle_handler::explain_select( 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(HA_POS_ERROR); } else { @@ -11604,7 +11567,6 @@ ha_rows spider_oracle_handler::explain_select( 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(HA_POS_ERROR); } @@ -11613,7 +11575,6 @@ ha_rows spider_oracle_handler::explain_select( 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); error_num = res->fetch_table_records( 2, @@ -11646,7 +11607,6 @@ int spider_oracle_handler::lock_tables( { 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11658,7 +11618,6 @@ int spider_oracle_handler::lock_tables( 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); } @@ -11682,7 +11641,6 @@ int spider_oracle_handler::lock_tables( 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); } if (!conn->table_locked) @@ -11727,7 +11685,6 @@ int spider_oracle_handler::disable_keys( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11739,7 +11696,6 @@ int spider_oracle_handler::disable_keys( 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); } @@ -11764,7 +11720,6 @@ int spider_oracle_handler::disable_keys( 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(0); } @@ -11786,7 +11741,6 @@ int spider_oracle_handler::enable_keys( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11798,7 +11752,6 @@ int spider_oracle_handler::enable_keys( 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); } @@ -11823,7 +11776,6 @@ int spider_oracle_handler::enable_keys( 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(0); } @@ -11846,7 +11798,6 @@ int spider_oracle_handler::check_table( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11858,7 +11809,6 @@ int spider_oracle_handler::check_table( 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); } @@ -11883,7 +11833,6 @@ int spider_oracle_handler::check_table( 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(0); } @@ -11906,7 +11855,6 @@ int spider_oracle_handler::repair_table( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11918,7 +11866,6 @@ int spider_oracle_handler::repair_table( 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); } @@ -11943,7 +11890,6 @@ int spider_oracle_handler::repair_table( 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(0); } @@ -11965,7 +11911,6 @@ int spider_oracle_handler::analyze_table( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -11977,7 +11922,6 @@ int spider_oracle_handler::analyze_table( 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); } @@ -12002,7 +11946,6 @@ int spider_oracle_handler::analyze_table( 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(0); } @@ -12024,7 +11967,6 @@ int spider_oracle_handler::optimize_table( } 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -12036,7 +11978,6 @@ int spider_oracle_handler::optimize_table( 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); } @@ -12061,7 +12002,6 @@ int spider_oracle_handler::optimize_table( 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(0); } @@ -12087,7 +12027,6 @@ int spider_oracle_handler::flush_tables( share); 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -12111,7 +12050,6 @@ int spider_oracle_handler::flush_tables( 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(0); } @@ -12129,7 +12067,6 @@ int spider_oracle_handler::flush_logs( share); 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); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -12153,7 +12090,6 @@ int spider_oracle_handler::flush_logs( 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(0); } diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 0d12b3b25b3..7c7f9aa7558 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -477,7 +477,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( DBUG_RETURN(conn); error: - DBUG_ASSERT(!conn->mta_conn_mutex_file_pos.file_name); error_too_many_ipport_count: spider_conn_done(conn); error_conn_init: diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 9b71f5bc13f..fa9f041c83b 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1196,7 +1196,6 @@ static int spider_send_query( SPIDER_SQL_TYPE_SELECT_SQL, link_idx, link_idx_chain))) DBUG_RETURN(error_num); pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); conn->need_mon = &spider->need_mons[link_idx]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -1210,7 +1209,6 @@ static int spider_send_query( 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); if (spider->need_mons[link_idx]) error_num = fields->ping_table_mon_from_table(link_idx_chain); @@ -1268,7 +1266,6 @@ static int spider_send_query( } else { spider_db_discard_result(spider, link_idx, conn); - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); pthread_mutex_unlock(&conn->mta_conn_mutex); } #ifndef WITHOUT_SPIDER_BG_SEARCH diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 12320f73742..5627f15bd4f 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -453,11 +453,6 @@ enum spider_malloc_id { #define SPIDER_CONN_RESTORE_DASTATUS_AND_RESET_TMP_ERROR_NUM \ if (thd && conn->error_mode) {SPIDER_RESTORE_DASTATUS; tmp_error_num = 0;} -#define SPIDER_SET_FILE_POS(A) \ - {(A)->thd = current_thd; (A)->func_name = __func__; (A)->file_name = __FILE__; (A)->line_no = __LINE__;} -#define SPIDER_CLEAR_FILE_POS(A) \ - {DBUG_PRINT("info", ("spider thd=%p func_name=%s file_name=%s line_no=%lu", (A)->thd, (A)->func_name ? (A)->func_name : "NULL", (A)->file_name ? (A)->file_name : "NULL", (A)->line_no)); (A)->thd = NULL; (A)->func_name = NULL; (A)->file_name = NULL; (A)->line_no = 0;} - class ha_spider; typedef struct st_spider_share SPIDER_SHARE; typedef struct st_spider_table_mon_list SPIDER_TABLE_MON_LIST; @@ -481,14 +476,6 @@ typedef struct st_spider_thread } SPIDER_THREAD; #endif -typedef struct st_spider_file_pos -{ - THD *thd; - const char *func_name; - const char *file_name; - ulong line_no; -} SPIDER_FILE_POS; - typedef struct st_spider_link_for_hash { ha_spider *spider; @@ -610,7 +597,6 @@ typedef struct st_spider_conn pthread_mutex_t mta_conn_mutex; volatile bool mta_conn_mutex_lock_already; volatile bool mta_conn_mutex_unlock_later; - SPIDER_FILE_POS mta_conn_mutex_file_pos; uint join_trx; int trx_isolation; bool semi_trx_isolation_chk; diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 145d9dc9c40..1503c61b1bb 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -5741,7 +5741,6 @@ int spider_open_all_tables( conn->error_mode &= spider_param_error_write_mode(thd, 0); 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); conn->need_mon = &mon_val; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -5753,7 +5752,6 @@ int spider_open_all_tables( 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); spider_sys_index_end(table_tables); spider_close_sys_table(thd, table_tables, @@ -5767,7 +5765,6 @@ int spider_open_all_tables( 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); if (lock && spider_param_use_snapshot_with_flush_tables(thd) == 2) From f5b7c25e1e2ca9f86a4679422eff16d3e3db45f9 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 18 Jun 2024 10:21:38 +0800 Subject: [PATCH 2/9] MDEV-27643 Spider: remove #ifdef HA_CAN_BULK_ACCESS --- storage/spider/ha_spider.cc | 1242 ------------------------------- storage/spider/ha_spider.h | 141 ---- storage/spider/spd_conn.cc | 14 - storage/spider/spd_db_conn.cc | 232 ------ storage/spider/spd_db_conn.h | 26 - storage/spider/spd_db_include.h | 2 - storage/spider/spd_db_mysql.cc | 4 - storage/spider/spd_db_oracle.cc | 4 - storage/spider/spd_include.h | 27 - storage/spider/spd_param.cc | 25 - storage/spider/spd_param.h | 5 - storage/spider/spd_table.cc | 28 - storage/spider/spd_trx.cc | 41 - storage/spider/spd_trx.h | 6 - 14 files changed, 1797 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 8fff0c5b673..e910ffcff56 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -94,17 +94,6 @@ ha_spider::ha_spider( use_pre_call = FALSE; use_pre_action = FALSE; do_direct_update = FALSE; -#ifdef HA_CAN_BULK_ACCESS - is_bulk_access_clone = FALSE; - synced_from_clone_source = FALSE; - bulk_access_started = FALSE; - bulk_access_executing = FALSE; - bulk_access_pre_called = FALSE; - bulk_access_link_first = NULL; -/* - init_ha_mem_root = FALSE; -*/ -#endif prev_index_rnd_init = SPD_NONE; direct_aggregate_item_first = NULL; result_link_idx = 0; @@ -173,17 +162,6 @@ ha_spider::ha_spider( use_pre_call = FALSE; use_pre_action = FALSE; do_direct_update = FALSE; -#ifdef HA_CAN_BULK_ACCESS - is_bulk_access_clone = FALSE; - synced_from_clone_source = FALSE; - bulk_access_started = FALSE; - bulk_access_executing = FALSE; - bulk_access_pre_called = FALSE; - bulk_access_link_first = NULL; -/* - init_ha_mem_root = FALSE; -*/ -#endif prev_index_rnd_init = SPD_NONE; direct_aggregate_item_first = NULL; result_link_idx = 0; @@ -514,9 +492,6 @@ int ha_spider::open( } else wide_handler->semi_table_lock = spider_param_semi_table_lock(thd, share->semi_table_lock); -#ifdef HA_CAN_BULK_ACCESS - external_lock_cnt = 0; -#endif if (reset()) { @@ -606,22 +581,6 @@ int ha_spider::close() delete [] mrr_key_buff; mrr_key_buff = NULL; } -#endif -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_link_first) - { - do { - DBUG_PRINT("info",("spider bulk_access_link->spider=%p", - bulk_access_link_first->spider)); - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - bulk_access_link_first->spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=" - "%p", &bulk_access_link_first->spider->dbton_handler)); - bulk_access_link_current = bulk_access_link_first->next; - delete_bulk_access_link(bulk_access_link_first); - bulk_access_link_first = bulk_access_link_current; - } while (bulk_access_link_first); - } #endif while (direct_aggregate_item_first) { @@ -780,33 +739,6 @@ void ha_spider::check_access_kind( DBUG_VOID_RETURN; } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::additional_lock( - THD *thd, - enum thr_lock_type lock_type -) { - DBUG_ENTER("ha_spider::additional_lock"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_executing) - { - if (is_bulk_access_clone) - { - check_access_kind(thd); - DBUG_RETURN(check_access_kind_for_connection(thd, - (lock_type >= TL_WRITE_ALLOW_WRITE))); - } else if (bulk_access_link_exec_tgt->called) - { - bulk_access_link_exec_tgt->spider->check_access_kind(thd); - DBUG_RETURN(bulk_access_link_exec_tgt->spider-> - check_access_kind_for_connection( - thd, (lock_type >= TL_WRITE_ALLOW_WRITE))); - } - } - check_access_kind(thd); - DBUG_RETURN(check_access_kind_for_connection(thd, - (lock_type >= TL_WRITE_ALLOW_WRITE))); -} -#endif THR_LOCK_DATA **ha_spider::store_lock( THD *thd, @@ -1144,40 +1076,6 @@ int ha_spider::reset() backup_error_status(); DBUG_ENTER("ha_spider::reset"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - SPIDER_BULK_ACCESS_LINK *tmp_bulk_access_link = bulk_access_link_first; - while (tmp_bulk_access_link) - { - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - tmp_bulk_access_link->spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &tmp_bulk_access_link->spider->dbton_handler)); - if (!tmp_bulk_access_link->used) - break; - if ((error_num2 = tmp_bulk_access_link->spider->ha_reset())) - error_num = error_num2; - tmp_bulk_access_link->used = FALSE; - tmp_bulk_access_link = tmp_bulk_access_link->next; - } - synced_from_clone_source = FALSE; - bulk_access_started = FALSE; - bulk_access_executing = FALSE; - bulk_access_pre_called = FALSE; - if ( - bulk_access_link_first && - !spider_param_bulk_access_free(share->bulk_access_free) - ) { - do { - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - bulk_access_link_first->spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &bulk_access_link_first->spider->dbton_handler)); - bulk_access_link_current = bulk_access_link_first->next; - delete_bulk_access_link(bulk_access_link_first); - bulk_access_link_first = bulk_access_link_current; - } while (bulk_access_link_first); - } -#endif direct_aggregate_item_current = direct_aggregate_item_first; while (direct_aggregate_item_current) { @@ -1319,17 +1217,6 @@ int ha_spider::reset() use_fields = FALSE; #endif error_mode = 0; -#ifdef HA_CAN_BULK_ACCESS -#ifndef DBUG_OFF - if (bulk_access_link_first) - { - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - bulk_access_link_first->spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &bulk_access_link_first->spider->dbton_handler)); - } -#endif -#endif DBUG_RETURN(error_num); } @@ -1438,19 +1325,6 @@ int ha_spider::index_init( DBUG_ENTER("ha_spider::index_init"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider idx=%u", idx)); -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_index_init( - idx, sorted)); - } - } -#endif if (!dml_inited) { if (unlikely((error_num = dml_init()))) @@ -1499,16 +1373,6 @@ int ha_spider::index_init( DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_index_init( - uint idx, - bool sorted -) { - DBUG_ENTER("ha_spider::pre_index_init"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_index_init(idx, sorted)); -} -#endif int ha_spider::index_end() { @@ -1516,21 +1380,6 @@ int ha_spider::index_end() backup_error_status(); DBUG_ENTER("ha_spider::index_end"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - error_num = bulk_access_link_exec_tgt->spider->ha_index_end(); - if (error_num) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); - } - } -#endif active_index = MAX_KEY; /* #ifdef INFO_KIND_FORCE_LIMIT_BEGIN @@ -1550,14 +1399,6 @@ int ha_spider::index_end() DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_index_end() -{ - DBUG_ENTER("ha_spider::pre_index_end"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_index_end()); -} -#endif int ha_spider::index_read_map_internal( uchar *buf, @@ -1762,17 +1603,6 @@ int ha_spider::index_read_map_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if ( - is_bulk_access_clone && - !bulk_access_executing && - conn_kind[roop_count] != SPIDER_CONN_KIND_MYSQL - ) { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -1883,9 +1713,6 @@ int ha_spider::index_read_map_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -1901,42 +1728,13 @@ int ha_spider::pre_index_read_map( enum ha_rkey_function find_flag, bool use_parallel ) { -#ifdef HA_CAN_BULK_ACCESS - int error_num; -#endif DBUG_ENTER("ha_spider::pre_index_read_map"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider->pre_index_read_map(key, - keypart_map, find_flag, TRUE); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } else if ( - bulk_access_executing && !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - DBUG_RETURN(bulk_access_link_exec_tgt->spider->pre_index_read_map(key, - keypart_map, find_flag, TRUE)); - } -#endif check_pre_call(use_parallel); if (use_pre_call) { store_error_num = index_read_map_internal(NULL, key, keypart_map, find_flag); -#ifdef HA_CAN_BULK_ACCESS - if ( - !store_error_num && - bulk_access_executing && - is_bulk_access_clone && - !bulk_access_pre_called - ) { - bulk_req_exec(); - } -#endif DBUG_RETURN(store_error_num); } DBUG_RETURN(0); @@ -1951,59 +1749,6 @@ int ha_spider::index_read_map( int error_num; DBUG_ENTER("ha_spider::index_read_map"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if (is_bulk_access_clone) - { - if (bulk_access_pre_called) - { - SPIDER_CONN *conn; - int roop_count, roop_start, roop_end, tmp_lock_mode, link_ok, - tmp_error_num; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } - for (roop_count = roop_start; roop_count < roop_end; - roop_count = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - conn = conns[roop_count]; - if ((tmp_error_num = spider_db_bulk_store_result(this, conn, - roop_count, (roop_count != link_ok)))) - { - store_error_num = tmp_error_num; - } else { - result_link_idx = link_ok; - } - } - use_pre_call = TRUE; - bulk_access_pre_called = FALSE; - } else { - /* do access normally */ - } - } else if (bulk_access_link_exec_tgt->called) - { - DBUG_RETURN(bulk_access_link_exec_tgt->spider->index_read_map(buf, key, - keypart_map, find_flag)); - } - } -#endif if (use_pre_call) { if (store_error_num) @@ -2218,14 +1963,6 @@ int ha_spider::index_read_last_map_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2336,9 +2073,6 @@ int ha_spider::index_read_last_map_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -2401,21 +2135,6 @@ int ha_spider::index_next( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - error_num = bulk_access_link_exec_tgt->spider->index_next(buf); - if (error_num) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); - } - } -#endif if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -2447,21 +2166,6 @@ int ha_spider::index_prev( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - error_num = bulk_access_link_exec_tgt->spider->index_prev(buf); - if (error_num) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); - } - } -#endif if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -2669,14 +2373,6 @@ int ha_spider::index_first_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -2787,9 +2483,6 @@ int ha_spider::index_first_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -3037,14 +2730,6 @@ int ha_spider::index_last_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3155,9 +2840,6 @@ int ha_spider::index_last_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -3231,22 +2913,6 @@ int ha_spider::index_next_same( my_error(ER_QUERY_INTERRUPTED, MYF(0)); DBUG_RETURN(ER_QUERY_INTERRUPTED); } -#ifdef HA_CAN_BULK_ACCESS - DBUG_ASSERT(!bulk_access_started); - if (bulk_access_executing) - { - if ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - error_num = bulk_access_link_exec_tgt->spider->index_next_same(buf, key, - keylen); - if (error_num) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); - } - } -#endif if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -3463,14 +3129,6 @@ int ha_spider::read_range_first_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -3581,9 +3239,6 @@ int ha_spider::read_range_first_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -4072,20 +3727,6 @@ int ha_spider::read_multi_range_first_internal( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); -#ifdef HA_MRR_USE_DEFAULT_IMPL - *range_info = (char *) mrr_cur_range.ptr; -#else - *found_range_p = multi_range_curr; -#endif - DBUG_RETURN(0); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -4198,9 +3839,6 @@ int ha_spider::read_multi_range_first_internal( pthread_mutex_unlock(&conn->mta_conn_mutex); } } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -4845,20 +4483,6 @@ int ha_spider::read_multi_range_first_internal( pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); -#ifdef HA_MRR_USE_DEFAULT_IMPL - *range_info = multi_range_keys[multi_range_hit_point]; -#else - *found_range_p = &multi_range_ranges[multi_range_hit_point]; -#endif - DBUG_RETURN(0); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -5014,9 +4638,6 @@ int ha_spider::read_multi_range_first_internal( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -5475,20 +5096,6 @@ int ha_spider::read_multi_range_next( } pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); -#ifdef HA_MRR_USE_DEFAULT_IMPL - *range_info = multi_range_keys[multi_range_hit_point]; -#else - *found_range_p = &multi_range_ranges[multi_range_hit_point]; -#endif - DBUG_RETURN(0); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -5601,9 +5208,6 @@ int ha_spider::read_multi_range_next( pthread_mutex_unlock(&conn->mta_conn_mutex); } } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -6247,20 +5851,6 @@ int ha_spider::read_multi_range_next( pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(wide_handler->trx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); -#ifdef HA_MRR_USE_DEFAULT_IMPL - *range_info = multi_range_keys[multi_range_hit_point]; -#else - *found_range_p = &multi_range_ranges[multi_range_hit_point]; -#endif - DBUG_RETURN(0); - } else { -#endif conn->need_mon = &need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -6416,9 +6006,6 @@ int ha_spider::read_multi_range_next( spider_db_discard_result(this, roop_count, conn); pthread_mutex_unlock(&conn->mta_conn_mutex); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -6655,15 +6242,6 @@ int ha_spider::rnd_init( DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_rnd_init( - bool scan -) { - DBUG_ENTER("ha_spider::pre_rnd_init"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_rnd_init(scan)); -} -#endif int ha_spider::rnd_end() { @@ -6687,14 +6265,6 @@ int ha_spider::rnd_end() DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_rnd_end() -{ - DBUG_ENTER("ha_spider::pre_rnd_end"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_rnd_end()); -} -#endif int ha_spider::rnd_next_internal( uchar *buf @@ -8700,8 +8270,6 @@ ulonglong ha_spider::table_flags() const #endif #ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON HA_CAN_TABLE_CONDITION_PUSHDOWN | -#endif -#ifdef HA_CAN_BULK_ACCESS #endif SPIDER_CAN_BG_SEARCH | SPIDER_CAN_BG_INSERT | @@ -9046,30 +8614,6 @@ int ha_spider::write_row( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - ulonglong option_backup = 0; - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_bulk_insert(this)); - } - option_backup = thd->variables.option_bits; - thd->variables.option_bits &= ~OPTION_BIN_LOG; - error_num = bulk_access_link_exec_tgt->spider->ha_write_row(buf); - thd->variables.option_bits = option_backup; - DBUG_RETURN(error_num); - } -#endif if (!dml_inited) { if (unlikely((error_num = dml_init()))) @@ -9156,35 +8700,9 @@ int ha_spider::write_row( if ((error_num = spider_db_bulk_insert(this, table, ©_info, FALSE))) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - /* bulk access disabled case (like using partitioning) */ - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_bulk_insert(this)); - } -#endif DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::pre_write_row( - uchar *buf -) { - int error_num; - ulonglong option_backup = 0; - THD *thd = wide_handler->trx->thd; - DBUG_ENTER("ha_spider::pre_write_row"); - DBUG_PRINT("info",("spider this=%p", this)); - option_backup = thd->variables.option_bits; - thd->variables.option_bits &= ~OPTION_BIN_LOG; - error_num = bulk_access_link_current->spider->ha_write_row(buf); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - thd->variables.option_bits = option_backup; - DBUG_RETURN(error_num); -} -#endif void ha_spider::direct_update_init( THD *thd, @@ -9258,20 +8776,6 @@ int ha_spider::update_row( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - ulonglong option_backup = 0; - option_backup = thd->variables.option_bits; - thd->variables.option_bits &= ~OPTION_BIN_LOG; - error_num = bulk_access_link_exec_tgt->spider->ha_update_row( - old_data, new_data); - thd->variables.option_bits = option_backup; - DBUG_RETURN(error_num); - } -#endif #ifndef SPIDER_WITHOUT_HA_STATISTIC_INCREMENT ha_statistic_increment(&SSV::ha_update_count); #endif @@ -9357,27 +8861,6 @@ int ha_spider::direct_update_rows_init( THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_update_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - DBUG_PRINT("info",("spider return pre_direct_init_result %d", - pre_direct_init_result)); - DBUG_RETURN(pre_direct_init_result); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init( - update_fields, mode, ranges, range_count, sorted, new_data)); - } -#endif if (!dml_inited) { if (unlikely((error_num = dml_init()))) @@ -9495,27 +8978,6 @@ int ha_spider::direct_update_rows_init( } } } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - DBUG_PRINT("info",("spider return pre_direct_init_result %d", - pre_direct_init_result)); - DBUG_RETURN(pre_direct_init_result); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider-> - direct_update_rows_init(update_fields)); - } -#endif if (!dml_inited) { if (unlikely(dml_init())) @@ -9586,78 +9048,6 @@ int ha_spider::direct_update_rows_init( } #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::pre_direct_update_rows_init( - List *update_fields, - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data -) -{ - int error_num; - DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init( - update_fields, mode, ranges, range_count, sorted, new_data); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } - if (!dml_inited) - { - if (unlikely((error_num = dml_init()))) - { - DBUG_RETURN(error_num); - } - } - pre_direct_init_result = direct_update_rows_init( - update_fields, mode, ranges, range_count, sorted, new_data); - DBUG_RETURN(pre_direct_init_result); -} -#else -/** - Do initialization for performing parallel direct update - for a handlersocket update request. - - @param update fields Pointer to the list of fields to update. - - @return >0 Error. - 0 Success. -*/ - -int ha_spider::pre_direct_update_rows_init( - List *update_fields -) -{ - int error_num; - DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init(update_fields); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } - if (!dml_inited) - { - if (unlikely((error_num = dml_init()))) - { - DBUG_RETURN(error_num); - } - } - pre_direct_init_result = direct_update_rows_init(update_fields); - DBUG_RETURN(pre_direct_init_result); -} -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int ha_spider::direct_update_rows( @@ -9679,26 +9069,6 @@ int ha_spider::direct_update_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows, found_rows)); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_update_rows( - ranges, range_count, sorted, new_data, update_rows, found_rows)); - } -#endif if ( (active_index != MAX_KEY && (error_num = index_handler_init())) || (active_index == MAX_KEY && (error_num = rnd_handler_init())) || @@ -9707,13 +9077,6 @@ int ha_spider::direct_update_rows( ) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows, found_rows)); - } -#endif DBUG_RETURN(0); } #else @@ -9732,26 +9095,6 @@ int ha_spider::direct_update_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows, found_rows)); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_update_rows( - update_rows, found_rows)); - } -#endif if ( (active_index != MAX_KEY && (error_num = index_handler_init())) || (active_index == MAX_KEY && (error_num = rnd_handler_init())) || @@ -9759,44 +9102,10 @@ int ha_spider::direct_update_rows( ) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_direct_update(this, update_rows, found_rows)); - } -#endif DBUG_RETURN(0); } #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::pre_direct_update_rows( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data, - ha_rows *update_rows, - ha_rows *found_rows -) { - DBUG_ENTER("ha_spider::pre_direct_update_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_direct_update_rows(ranges, - range_count, sorted, new_data, update_rows, found_rows)); -} -#else -int ha_spider::pre_direct_update_rows() -{ - uint update_rows; - uint found_rows; - DBUG_ENTER("ha_spider::pre_direct_update_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_direct_update_rows( - &update_rows, &found_rows)); -} -#endif -#endif bool ha_spider::start_bulk_delete( ) { @@ -9830,19 +9139,6 @@ int ha_spider::delete_row( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) { - ulonglong option_backup = 0; - option_backup = thd->variables.option_bits; - thd->variables.option_bits &= ~OPTION_BIN_LOG; - error_num = bulk_access_link_exec_tgt->spider->ha_delete_row(buf); - thd->variables.option_bits = option_backup; - DBUG_RETURN(error_num); - } -#endif #ifndef SPIDER_WITHOUT_HA_STATISTIC_INCREMENT ha_statistic_increment(&SSV::ha_delete_count); #endif @@ -9887,25 +9183,6 @@ int ha_spider::direct_delete_rows_init( THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_delete_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - DBUG_RETURN(pre_direct_init_result); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_delete_rows_init( - mode, ranges, range_count, sorted)); - } -#endif if (!dml_inited) { if (unlikely((error_num = dml_init()))) @@ -9980,24 +9257,6 @@ int ha_spider::direct_delete_rows_init() THD *thd = wide_handler->trx->thd; DBUG_ENTER("ha_spider::direct_delete_rows_init"); DBUG_PRINT("info",("spider this=%p", this)); -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - DBUG_RETURN(pre_direct_init_result); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_delete_rows_init()); - } -#endif if (!dml_inited) { if (unlikely(dml_init())) @@ -10048,63 +9307,6 @@ int ha_spider::direct_delete_rows_init() } #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::pre_direct_delete_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted -) { - int error_num; - DBUG_ENTER("ha_spider::pre_direct_delete_rows_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider-> - pre_direct_delete_rows_init( - mode, ranges, range_count, sorted); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } - if (!dml_inited) - { - if (unlikely((error_num = dml_init()))) - { - DBUG_RETURN(error_num); - } - } - pre_direct_init_result = direct_delete_rows_init( - mode, ranges, range_count, sorted); - DBUG_RETURN(pre_direct_init_result); -} -#else -int ha_spider::pre_direct_delete_rows_init() -{ - int error_num; - DBUG_ENTER("ha_spider::pre_direct_delete_rows_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - error_num = bulk_access_link_current->spider-> - pre_direct_delete_rows_init(); - bulk_access_link_current->spider->bulk_access_pre_called = TRUE; - bulk_access_link_current->called = TRUE; - DBUG_RETURN(error_num); - } - if (!dml_inited) - { - if (unlikely((error_num = dml_init()))) - { - DBUG_RETURN(error_num); - } - } - pre_direct_init_result = direct_delete_rows_init(); - DBUG_RETURN(pre_direct_init_result); -} -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int ha_spider::direct_delete_rows( @@ -10124,26 +9326,6 @@ int ha_spider::direct_delete_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_delete_rows( - ranges, range_count, sorted, delete_rows)); - } -#endif if ( (active_index != MAX_KEY && (error_num = index_handler_init())) || (active_index == MAX_KEY && (error_num = rnd_handler_init())) || @@ -10152,13 +9334,6 @@ int ha_spider::direct_delete_rows( ) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); - } -#endif DBUG_RETURN(0); } #else @@ -10176,26 +9351,6 @@ int ha_spider::direct_delete_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } -#ifdef HA_CAN_BULK_ACCESS - if ( - bulk_access_executing && - ( - ( - !is_bulk_access_clone && - bulk_access_link_exec_tgt->called - ) || - bulk_access_pre_called - ) - ) { - if (is_bulk_access_clone) - { - bulk_access_pre_called = FALSE; - DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); - } - DBUG_RETURN(bulk_access_link_exec_tgt->spider->ha_direct_delete_rows( - delete_rows)); - } -#endif if ( (active_index != MAX_KEY && (error_num = index_handler_init())) || (active_index == MAX_KEY && (error_num = rnd_handler_init())) || @@ -10203,41 +9358,10 @@ int ha_spider::direct_delete_rows( ) DBUG_RETURN(check_error_mode(error_num)); -#ifdef HA_CAN_BULK_ACCESS - if (bulk_access_executing && is_bulk_access_clone) - { - bulk_req_exec(); - DBUG_RETURN(spider_db_bulk_direct_update(this, delete_rows)); - } -#endif DBUG_RETURN(0); } #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::pre_direct_delete_rows( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - ha_rows *delete_rows -) { - DBUG_ENTER("ha_spider::pre_direct_delete_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_direct_delete_rows( - ranges, range_count, sorted, delete_rows)); -} -#else -int ha_spider::pre_direct_delete_rows() -{ - uint delete_rows; - DBUG_ENTER("ha_spider::pre_direct_delete_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(bulk_access_link_current->spider->ha_direct_delete_rows( - &delete_rows)); -} -#endif -#endif int ha_spider::delete_all_rows() { @@ -10289,57 +9413,6 @@ int ha_spider::truncate() DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -void ha_spider::bulk_req_exec() -{ - int need_mon; - SPIDER_CONN *conn = wide_handler->trx->bulk_access_conn_first; - DBUG_ENTER("ha_spider::bulk_req_exec"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider trx=%p", wide_handler->trx)); - DBUG_PRINT("info",("spider first_conn=%p", conn)); - while (conn) - { - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->bulk_access_requests=%u", - conn->bulk_access_requests)); - if (conn->bulk_access_requests) - { - spider_bg_conn_wait(conn); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - /* currently only used for HS */ - conn->bulk_access_error_num = 0; - if (spider_db_query( - conn, - NULL, - 0, - -1, - &need_mon) - ) { - conn->bulk_access_error_num = spider_db_errorno(conn); - } -/* - conn->bulk_access_sended += conn->bulk_access_requests; -*/ - conn->bulk_access_requests = 0; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - conn = conn->bulk_access_next; - } - wide_handler->trx->bulk_access_conn_first = NULL; - DBUG_VOID_RETURN; -} -#endif double ha_spider::scan_time() { @@ -11148,12 +10221,6 @@ Field *ha_spider::field_exchange( Field *field ) { DBUG_ENTER("ha_spider::field_exchange"); -#ifdef HA_CAN_BULK_ACCESS - if (is_bulk_access_clone) - { - DBUG_RETURN(pt_clone_source_handler->field_exchange(field)); - } -#endif DBUG_PRINT("info",("spider in field=%p", field)); DBUG_PRINT("info",("spider in field->table=%p", field->table)); DBUG_PRINT("info",("spider table=%p", table)); @@ -11231,28 +10298,6 @@ int ha_spider::info_push( wide_handler->stage = SPD_HND_STAGE_INFO_PUSH; wide_handler->stage_executor = this; #endif -#ifdef HA_CAN_BULK_ACCESS - if ( - info_type != INFO_KIND_BULK_ACCESS_BEGIN && - info_type != INFO_KIND_BULK_ACCESS_CURRENT && - info_type != INFO_KIND_BULK_ACCESS_END - ) { - if (!is_bulk_access_clone) - { - if ( - bulk_access_executing && - bulk_access_link_exec_tgt->called - ) { - DBUG_RETURN(bulk_access_link_exec_tgt->spider->info_push(info_type, - info)); - } else if (bulk_access_started) - { - DBUG_RETURN(bulk_access_link_current->spider->info_push(info_type, - info)); - } - } - } -#endif switch (info_type) { @@ -11282,65 +10327,6 @@ int ha_spider::info_push( DBUG_PRINT("info",("spider INFO_KIND_FORCE_LIMIT_END")); wide_handler->info_limit = 9223372036854775807LL; break; -#endif -#ifdef HA_CAN_BULK_ACCESS - case INFO_KIND_BULK_ACCESS_BEGIN: - DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_BEGIN")); - 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]->bulk_access_begin(info))) - { - DBUG_RETURN(error_num); - } - } - } else { - if ((error_num = bulk_access_begin(info))) - { - DBUG_RETURN(error_num); - } - } - break; - case INFO_KIND_BULK_ACCESS_CURRENT: - DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_CURRENT")); - 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]->bulk_access_current(info))) - { - DBUG_RETURN(error_num); - } - } - } else { - if ((error_num = bulk_access_current(info))) - { - DBUG_RETURN(error_num); - } - } - break; - case INFO_KIND_BULK_ACCESS_END: - DBUG_PRINT("info",("spider INFO_KIND_BULK_ACCESS_END")); - 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) - { - handlers[roop_count]->bulk_access_end(); - } - } else { - bulk_access_end(); - } - break; #endif default: break; @@ -12475,145 +11461,6 @@ void ha_spider::check_insert_dup_update_pushdown() DBUG_VOID_RETURN; } -#ifdef HA_CAN_BULK_ACCESS -SPIDER_BULK_ACCESS_LINK *ha_spider::create_bulk_access_link() -{ - uchar *ref; - ha_spider *spider; - SPIDER_BULK_ACCESS_LINK *bulk_access_link; - DBUG_ENTER("ha_spider::create_bulk_access_link"); - DBUG_PRINT("info",("spider this=%p", this)); -/* - if (!init_ha_mem_root) - { - SPD_INIT_ALLOC_ROOT(&ha_mem_root, sizeof(ha_spider) * 16, - sizeof(ha_spider) * 16, MYF(MY_WME)); - init_ha_mem_root = TRUE; - } -*/ - if (!(bulk_access_link = (SPIDER_BULK_ACCESS_LINK *) - spider_bulk_malloc(spider_current_trx, SPD_MID_HA_SPIDER_CREATE_BULK_ACCESS_LINK_1, MYF(MY_WME), - &bulk_access_link, (uint) (sizeof(SPIDER_BULK_ACCESS_LINK)), - &ref, (uint) (ALIGN_SIZE(ref_length) * 2), - NullS)) - ) { - goto error_bulk_malloc; - } - SPD_INIT_ALLOC_ROOT(&bulk_access_link->mem_root, sizeof(ha_spider), 0, - MYF(MY_WME)); -/* - if (!(spider = new ha_spider(spider_hton_ptr, table_share))) - if (!(spider = (ha_spider *) spider_create_handler( - spider_hton_ptr, table_share, &ha_mem_root))) -*/ - if (!(spider = (ha_spider *) spider_create_handler( - spider_hton_ptr, table_share, &bulk_access_link->mem_root))) - { - goto error_new_spider; - } - DBUG_PRINT("info",("spider spider=%p", spider)); - bulk_access_link->spider = spider; - spider->ref = ref; - bulk_access_link->next = NULL; - spider->is_clone = TRUE; - spider->is_bulk_access_clone = TRUE; - spider->pt_clone_source_handler = this; - if (spider->ha_open(table, share->table_name, table->db_stat, - HA_OPEN_IGNORE_IF_LOCKED)) - { - goto error_ha_open; - } - DBUG_RETURN(bulk_access_link); - -error_ha_open: - delete spider; -error_new_spider: - free_root(&bulk_access_link->mem_root, MYF(0)); - spider_free(spider_current_trx, bulk_access_link, MYF(0)); -error_bulk_malloc: - DBUG_RETURN(NULL); -} - -void ha_spider::delete_bulk_access_link( - SPIDER_BULK_ACCESS_LINK *bulk_access_link -) { - ha_spider *spider = bulk_access_link->spider; - DBUG_ENTER("ha_spider::delete_bulk_access_link"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider spider=%p", spider)); - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - spider->dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &spider->dbton_handler)); - spider->close(); - delete spider; - free_root(&bulk_access_link->mem_root, MYF(0)); - spider_free(spider_current_trx, bulk_access_link, MYF(0)); - DBUG_VOID_RETURN; -} - -int ha_spider::sync_from_clone_source( - ha_spider *spider -) { - int error_num; - DBUG_ENTER("ha_spider::sync_from_clone_source"); - sync_from_clone_source_base(spider); - if (!synced_from_clone_source) - { - DBUG_PRINT("info",("spider synced from clone source all")); - wide_handler->trx = spider->wide_handler->trx; - sql_command = spider->sql_command; - wide_handler->external_lock_type = - spider->wide_handler->external_lock_type; - selupd_lock_mode = spider->selupd_lock_mode; - update_request = spider->update_request; - lock_mode = spider->lock_mode; - high_priority = spider->high_priority; - low_priority = spider->low_priority; - memcpy(conns, spider->conns, - sizeof(SPIDER_CONN *) * share->link_count); - spider_thread_id = spider->spider_thread_id; - trx_conn_adjustment = spider->trx_conn_adjustment; - search_link_idx = spider->search_link_idx; - external_lock_cnt = spider->external_lock_cnt; - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl, *dbton_hdl2; - for (roop_count = 0; roop_count < share->use_dbton_count; roop_count++) - { - dbton_id = share->use_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - dbton_hdl2 = spider->dbton_handler[dbton_id]; - dbton_hdl->sync_from_clone_source(dbton_hdl2); - } - synced_from_clone_source = TRUE; - } else if (external_lock_cnt != spider->external_lock_cnt) - { - DBUG_PRINT("info",("spider synced from clone source")); - sql_command = spider->sql_command; - wide_handler->external_lock_type = - spider->wide_handler->external_lock_type; - selupd_lock_mode = spider->selupd_lock_mode; - update_request = spider->update_request; - lock_mode = spider->lock_mode; - high_priority = spider->high_priority; - low_priority = spider->low_priority; - - if ((error_num = spider_check_trx_and_get_conn( - spider->wide_handler->trx->thd, - this, TRUE))) - { - DBUG_RETURN(error_num); - } - external_lock_cnt = spider->external_lock_cnt; - } - - DBUG_PRINT("info",("spider bulk_access_link->spider->dbton_handler=%p", - dbton_handler)); - DBUG_PRINT("info",("spider ptr bulk_access_link->spider->dbton_handler=%p", - &dbton_handler)); - DBUG_RETURN(0); -} -#endif void ha_spider::sync_from_clone_source_base( ha_spider *spider @@ -14783,92 +13630,3 @@ int ha_spider::dml_init() DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int ha_spider::bulk_access_begin( - void *info -) { - DBUG_ENTER("ha_spider::bulk_access_begin"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { - if (!bulk_access_link_current->next) - { - if (!(bulk_access_link_current->next = create_bulk_access_link())) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - bulk_access_link_current->next->sequence_num = - bulk_access_link_current->sequence_num + 1; - } - bulk_access_link_current = bulk_access_link_current->next; - } else { - if (!bulk_access_link_first) - { - if (!(bulk_access_link_first = create_bulk_access_link())) - { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - bulk_access_link_first->sequence_num = 0; - } - bulk_access_link_current = bulk_access_link_first; - bulk_access_started = TRUE; - bulk_access_executing = FALSE; - } - bulk_access_link_current->spider-> - check_access_kind(wide_handler->trx->thd); - if ( - (error_num = bulk_access_link_current->spider-> - sync_from_clone_source(this)) || - (error_num = bulk_access_link_current->spider-> - check_access_kind_for_connection(wide_handler->trx->thd, - (lock_type >= TL_WRITE_ALLOW_WRITE))) - ) { - DBUG_RETURN(error_num); - } - 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; - bulk_access_link_current->called = FALSE; - *((void **) info) = bulk_access_link_current; - DBUG_RETURN(0); -} - -int ha_spider::bulk_access_current( - void *info -) { - DBUG_ENTER("ha_spider::bulk_access_current"); - DBUG_PRINT("info",("spider this=%p", this)); - bulk_access_executing = TRUE; - bulk_access_link_exec_tgt = (SPIDER_BULK_ACCESS_LINK *) info; - if (bulk_access_link_exec_tgt->spider->pt_clone_source_handler != this) - { - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider pt_clone_source_handler=%p", - bulk_access_link_exec_tgt->spider->pt_clone_source_handler)); - /* partitioned */ - uint sequence_num = bulk_access_link_exec_tgt->sequence_num; - for ( - bulk_access_link_exec_tgt = bulk_access_link_first; - bulk_access_link_exec_tgt; - bulk_access_link_exec_tgt = bulk_access_link_exec_tgt->next - ) { - if (bulk_access_link_exec_tgt->sequence_num >= sequence_num) - { - DBUG_ASSERT( - bulk_access_link_exec_tgt->sequence_num == sequence_num); - break; - } - } - } - bulk_access_link_exec_tgt->spider->bulk_access_executing = TRUE; - DBUG_RETURN(0); -} - -void ha_spider::bulk_access_end() -{ - DBUG_ENTER("ha_spider::bulk_access_end"); - DBUG_PRINT("info",("spider this=%p", this)); - bulk_access_started = FALSE; - DBUG_VOID_RETURN; -} -#endif diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index a57359ce025..446bbbc4d94 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -88,21 +88,6 @@ public: bool wide_handler_owner = FALSE; SPIDER_WIDE_HANDLER *wide_handler = NULL; -#ifdef HA_CAN_BULK_ACCESS - int pre_direct_init_result; - bool is_bulk_access_clone; - bool synced_from_clone_source; - bool bulk_access_started; - bool bulk_access_executing; - bool bulk_access_pre_called; - SPIDER_BULK_ACCESS_LINK *bulk_access_link_first; - SPIDER_BULK_ACCESS_LINK *bulk_access_link_current; - SPIDER_BULK_ACCESS_LINK *bulk_access_link_exec_tgt; -/* - bool init_ha_mem_root; - MEM_ROOT ha_mem_root; -*/ -#endif bool is_clone; ha_spider *pt_clone_source_handler; ha_spider *pt_clone_last_searcher; @@ -221,12 +206,6 @@ public: void check_access_kind( THD *thd ); -#ifdef HA_CAN_BULK_ACCESS - int additional_lock( - THD *thd, - enum thr_lock_type lock_type - ); -#endif THR_LOCK_DATA **store_lock( THD *thd, THR_LOCK_DATA **to, @@ -248,16 +227,7 @@ public: uint idx, bool sorted ) override; -#ifdef HA_CAN_BULK_ACCESS - int pre_index_init( - uint idx, - bool sorted - ); -#endif int index_end() override; -#ifdef HA_CAN_BULK_ACCESS - int pre_index_end(); -#endif int index_read_map( uchar *buf, const uchar *key, @@ -345,15 +315,7 @@ public: int rnd_init( bool scan ) override; -#ifdef HA_CAN_BULK_ACCESS - int pre_rnd_init( - bool scan - ); -#endif int rnd_end() override; -#ifdef HA_CAN_BULK_ACCESS - int pre_rnd_end(); -#endif int rnd_next( uchar *buf ) override; @@ -467,11 +429,6 @@ public: int write_row( const uchar *buf ) override; -#ifdef HA_CAN_BULK_ACCESS - int pre_write_row( - uchar *buf - ); -#endif void direct_update_init( THD *thd, bool hs_request @@ -514,27 +471,6 @@ public: List *update_fields ) override; #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int pre_direct_update_rows_init( - List *update_fields - ) { - return pre_direct_update_rows_init(update_fields, 2, NULL, 0, FALSE, NULL); - } - int pre_direct_update_rows_init( - List *update_fields, - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data - ); -#else - int pre_direct_update_rows_init( - List *update_fields - ); -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS inline int direct_update_rows(ha_rows *update_rows, ha_rows *found_rows) { @@ -553,28 +489,6 @@ public: ha_rows *update_rows, ha_rows *found_row ) override; -#endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int pre_direct_update_rows() - { - ha_rows update_rows; - ha_rows found_rows; - - return pre_direct_update_rows(NULL, 0, FALSE, NULL, &update_rows, - &found_rows); - } - int pre_direct_update_rows( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data, - ha_rows *update_rows, - ha_rows *found_row - ); -#else - int pre_direct_update_rows(); -#endif #endif bool start_bulk_delete() override; int end_bulk_delete() override; @@ -600,22 +514,6 @@ public: #else int direct_delete_rows_init() override; #endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int pre_direct_delete_rows_init() - { - return pre_direct_delete_rows_init(2, NULL, 0, FALSE); - } - int pre_direct_delete_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted - ); -#else - int pre_direct_delete_rows_init(); -#endif -#endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS inline int direct_delete_rows(ha_rows *delete_rows) { @@ -631,24 +529,6 @@ public: int direct_delete_rows( ha_rows *delete_rows ) override; -#endif -#ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int pre_direct_delete_rows() - { - ha_rows delete_rows; - - return pre_direct_delete_rows(NULL, 0, FALSE, &delete_rows); - } - int pre_direct_delete_rows( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - ha_rows *delete_rows - ); -#else - int pre_direct_delete_rows(); -#endif #endif int delete_all_rows() override; int truncate() override; @@ -658,9 +538,6 @@ public: uint ranges, ha_rows rows ) override; -#ifdef HA_CAN_BULK_ACCESS - void bulk_req_exec(); -#endif const key_map *keys_to_use_for_scanning() override; ha_rows estimate_rows_upper_bound() override; void print_error( @@ -818,15 +695,6 @@ public: bool use_parallel ); void check_insert_dup_update_pushdown(); -#ifdef HA_CAN_BULK_ACCESS - SPIDER_BULK_ACCESS_LINK *create_bulk_access_link(); - void delete_bulk_access_link( - SPIDER_BULK_ACCESS_LINK *bulk_access_link - ); - int sync_from_clone_source( - ha_spider *spider - ); -#endif void sync_from_clone_source_base( ha_spider *spider ); @@ -1044,15 +912,6 @@ public: int append_lock_tables_list(); int lock_tables(); int dml_init(); -#ifdef HA_CAN_BULK_ACCESS - int bulk_access_begin( - void *info - ); - int bulk_access_current( - void *info - ); - void bulk_access_end(); -#endif }; diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index 434a20e9e3e..cc3a6b52719 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -2590,13 +2590,6 @@ void *spider_bg_conn_action( pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[conn->link_idx] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->trx, conn); - } -#endif if (!result_list->bgs_error) { conn->need_mon = &spider->need_mons[conn->link_idx]; @@ -2604,10 +2597,6 @@ void *spider_bg_conn_action( DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = TRUE; conn->mta_conn_mutex_unlock_later = TRUE; -#ifdef HA_CAN_BULK_ACCESS - if (!spider->is_bulk_access_clone) - { -#endif if (!(result_list->bgs_error = spider_db_set_names(spider, conn, conn->link_idx))) { @@ -2676,9 +2665,6 @@ void *spider_bg_conn_action( strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd)); } -#ifdef HA_CAN_BULK_ACCESS - } -#endif DBUG_ASSERT(conn->mta_conn_mutex_lock_already); DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 7d786492bfe..4319616961b 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -4476,42 +4476,6 @@ void spider_db_discard_multiple_result( DBUG_VOID_RETURN; } -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_store_result( - ha_spider *spider, - SPIDER_CONN *conn, - int link_idx, - bool discard_result -) { - int error_num, tmp_error_num; - DBUG_ENTER("spider_db_bulk_store_result"); - DBUG_PRINT("info",("spider spider=%p", spider)); - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider link_idx=%d", link_idx)); - if (conn->conn_kind == SPIDER_CONN_KIND_MYSQL) - { - /* already stored */ - DBUG_RETURN(0); - } - error_num = spider_db_bulk_open_handler(spider, conn, link_idx); - if (!discard_result) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_unlock_later = TRUE; - if ((tmp_error_num = spider_db_store_result(spider, link_idx, - spider->get_table()))) - { - error_num = tmp_error_num; - } - conn->mta_conn_mutex_unlock_later = FALSE; - } else { - if (spider->connection_ids[link_idx] == conn->connection_id) - spider_db_discard_result(spider, link_idx, conn); - } - DBUG_RETURN(error_num); -} -#endif int spider_db_fetch( uchar *buf, @@ -6070,10 +6034,6 @@ int spider_db_bulk_insert( spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); DBUG_RETURN(error_num); } -#ifdef HA_CAN_BULK_ACCESS - if (!spider->is_bulk_access_clone) - { -#endif bool insert_info = FALSE; for ( roop_count2 = spider_conn_link_idx_next(share->link_statuses, @@ -6254,9 +6214,6 @@ int spider_db_bulk_insert( conn->mta_conn_mutex_unlock_later = FALSE; pthread_mutex_unlock(&conn->mta_conn_mutex); spider->store_last_insert_id = 0; -#ifdef HA_CAN_BULK_ACCESS - } -#endif } if ( (bulk_end || !spider->bulk_insert) && @@ -6266,91 +6223,6 @@ int spider_db_bulk_insert( DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_bulk_insert( - ha_spider *spider -) { - int error_num = 0, first_insert_link_idx = -1, tmp_error_num; - int roop_count2; - SPIDER_SHARE *share = spider->share; - SPIDER_CONN *conn, *first_insert_conn = NULL; - TABLE *table = spider->get_table(); - THD *thd = spider->wide_handler->trx->thd; - DBUG_ENTER("spider_db_bulk_bulk_insert"); - 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) - ) { - conn = spider->conns[roop_count2]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if ((tmp_error_num = spider_db_bulk_open_handler(spider, conn, - roop_count2))) - { - error_num = tmp_error_num; - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - if (first_insert_link_idx == -1) - { - first_insert_link_idx = roop_count2; - first_insert_conn = conn; - } - } - - conn = first_insert_conn; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[first_insert_link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (table->next_number_field && - ( - !table->auto_increment_field_not_null || - ( - !table->next_number_field->val_int() && - !(thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) - ) - ) - ) { - ulonglong last_insert_id; - if (spider->store_last_insert_id) - last_insert_id = spider->store_last_insert_id; - else - last_insert_id = conn->db_conn->last_insert_id(); - table->next_number_field->set_notnull(); - if ( - (tmp_error_num = spider_db_update_auto_increment(spider, - first_insert_link_idx)) || - (tmp_error_num = table->next_number_field->store( - last_insert_id, TRUE)) - ) { - error_num = tmp_error_num; - } - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - spider->store_last_insert_id = 0; - DBUG_RETURN(error_num); -} -#endif int spider_db_update_auto_increment( ha_spider *spider, @@ -6917,13 +6789,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7014,9 +6879,6 @@ int spider_db_direct_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; -#ifdef HA_CAN_BULK_ACCESS - } -#endif pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -7125,13 +6987,6 @@ int spider_db_direct_update( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7223,9 +7078,6 @@ int spider_db_direct_update( DBUG_ASSERT(conn->mta_conn_mutex_unlock_later); conn->mta_conn_mutex_lock_already = FALSE; conn->mta_conn_mutex_unlock_later = FALSE; -#ifdef HA_CAN_BULK_ACCESS - } -#endif pthread_mutex_unlock(&conn->mta_conn_mutex); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -7233,56 +7085,6 @@ int spider_db_direct_update( } #endif -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_direct_update( - ha_spider *spider, - ha_rows *update_rows, - ha_rows *found_rows -) { - int error_num = 0, roop_count, tmp_error_num; - SPIDER_SHARE *share = spider->share; - SPIDER_CONN *conn; - bool counted = FALSE; - DBUG_ENTER("spider_db_bulk_direct_update"); - for ( - roop_count = spider_conn_link_idx_next(share->link_statuses, - spider->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, - spider->conn_link_idx, roop_count, share->link_count, - SPIDER_LINK_STATUS_RECOVERY) - ) { - DBUG_PRINT("info", ("spider exec sql")); - conn = spider->conns[roop_count]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if ((tmp_error_num = spider_db_bulk_open_handler(spider, conn, - roop_count))) - { - error_num = tmp_error_num; - } - if (!counted) - { - *update_rows = spider->conns[roop_count]->db_conn->affected_rows(); - DBUG_PRINT("info", ("spider update_rows = %llu", *update_rows)); - *found_rows = spider->conns[roop_count]->db_conn->matched_rows(); - DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); - counted = TRUE; - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(error_num); -} -#endif int spider_db_bulk_delete( ha_spider *spider, @@ -7447,13 +7249,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7536,9 +7331,6 @@ int spider_db_direct_delete( DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } -#ifdef HA_CAN_BULK_ACCESS - } -#endif pthread_mutex_unlock(&conn->mta_conn_mutex); } int error_num2 = 0; @@ -7623,13 +7415,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num); } pthread_mutex_lock(&conn->mta_conn_mutex); -#ifdef HA_CAN_BULK_ACCESS - if (spider->is_bulk_access_clone) - { - spider->connection_ids[roop_count] = conn->connection_id; - spider_trx_add_bulk_access_conn(spider->wide_handler->trx, conn); - } else { -#endif conn->need_mon = &spider->need_mons[roop_count]; DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); @@ -7712,9 +7497,6 @@ int spider_db_direct_delete( DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } -#ifdef HA_CAN_BULK_ACCESS - } -#endif pthread_mutex_unlock(&conn->mta_conn_mutex); } int error_num2 = 0; @@ -11146,20 +10928,6 @@ error: DBUG_RETURN(error_num); } -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_open_handler( - ha_spider *spider, - SPIDER_CONN *conn, - int link_idx -) { - int error_num = 0; - 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)); - DBUG_RETURN(error_num); -} -#endif int spider_db_close_handler( ha_spider *spider, diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h index aa451b861d2..6e94e2d1517 100644 --- a/storage/spider/spd_db_conn.h +++ b/storage/spider/spd_db_conn.h @@ -634,14 +634,6 @@ void spider_db_discard_multiple_result( SPIDER_CONN *conn ); -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_store_result( - ha_spider *spider, - SPIDER_CONN *conn, - int link_idx, - bool discard_result -); -#endif int spider_db_fetch( uchar *buf, @@ -764,11 +756,6 @@ int spider_db_bulk_insert( bool bulk_end ); -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_bulk_insert( - ha_spider *spider -); -#endif int spider_db_update_auto_increment( ha_spider *spider, @@ -815,12 +802,6 @@ int spider_db_direct_update( ); #endif -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_direct_update( - ha_spider *spider, - ha_rows *update_rows -); -#endif int spider_db_bulk_delete( ha_spider *spider, @@ -1190,13 +1171,6 @@ int spider_db_open_handler( int link_idx ); -#ifdef HA_CAN_BULK_ACCESS -int spider_db_bulk_open_handler( - ha_spider *spider, - SPIDER_CONN *conn, - int link_idx -); -#endif int spider_db_close_handler( ha_spider *spider, diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 50974269e0c..ac031dfe64d 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -1766,8 +1766,6 @@ typedef struct st_spider_result_list SPIDER_RESULT *current; KEY *key_info; int key_order; -#ifdef HA_CAN_BULK_ACCESS -#endif spider_string *sqls; int ha_read_kind; bool have_sql_kind_backup; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 62fb57c8724..8c8ed349d32 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -15005,11 +15005,7 @@ void spider_mbase_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; diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 9ed1aa32a96..c5bf59b8df8 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -12167,11 +12167,7 @@ void spider_oracle_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; diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 5627f15bd4f..d06d0d7be8b 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -745,12 +745,6 @@ typedef struct st_spider_conn Time_zone *queued_time_zone_val; XID *queued_xa_start_xid; -#ifdef HA_CAN_BULK_ACCESS - uint bulk_access_requests; - uint bulk_access_sended; - int bulk_access_error_num; - st_spider_conn *bulk_access_next; -#endif bool disable_connect_retry; /* TRUE if it is unnecessary to retry to connect after a @@ -878,9 +872,6 @@ typedef struct st_spider_wide_handler uint top_table_fields; #ifdef INFO_KIND_FORCE_LIMIT_BEGIN longlong info_limit; -#endif -#ifdef HA_CAN_BULK_ACCESS - ulonglong external_lock_cnt; #endif bool between_flg; bool idx_bitmap_is_set; @@ -954,10 +945,6 @@ typedef struct st_spider_transaction ulonglong direct_aggregate_count; ulonglong parallel_search_count; -#ifdef HA_CAN_BULK_ACCESS - SPIDER_CONN *bulk_access_conn_first; - SPIDER_CONN *bulk_access_conn_last; -#endif pthread_mutex_t *udf_table_mutexes; CHARSET_INFO *udf_access_charset; @@ -1175,9 +1162,6 @@ typedef struct st_spider_share int error_read_mode; int error_write_mode; int active_link_count; -#ifdef HA_CAN_BULK_ACCESS - int bulk_access_free; -#endif #ifdef HA_CAN_FORCE_BULK_UPDATE int force_bulk_update; #endif @@ -1583,17 +1567,6 @@ typedef struct st_spider_trx_ha bool wait_for_reusing; } SPIDER_TRX_HA; -#ifdef HA_CAN_BULK_ACCESS -typedef struct st_spider_bulk_access_link -{ - ha_spider *spider; - uint sequence_num; - bool used; - bool called; - MEM_ROOT mem_root; - st_spider_bulk_access_link *next; -} SPIDER_BULK_ACCESS_LINK; -#endif #define SPIDER_INT_HLD_TGT_SIZE 100 typedef struct st_spider_int_hld diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index 41a065bfd29..55842682782 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -2033,28 +2033,6 @@ static MYSQL_THDVAR_INT( SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, read_only_mode) -#ifdef HA_CAN_BULK_ACCESS -static int spider_bulk_access_free; -/* - -1 :fallback to default - 0 :in reset - 1 :in close - */ -static MYSQL_SYSVAR_INT( - bulk_access_free, - spider_bulk_access_free, - PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, - "Free mode of bulk access resources", - NULL, - NULL, - 0, - -1, - 1, - 0 -); - -SPIDER_SYSVAR_OVERRIDE_VALUE_FUN(int, bulk_access_free) -#endif /* -1 :fallback to default @@ -2657,9 +2635,6 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(skip_parallel_search), MYSQL_SYSVAR(direct_order_limit), MYSQL_SYSVAR(read_only_mode), -#ifdef HA_CAN_BULK_ACCESS - MYSQL_SYSVAR(bulk_access_free), -#endif MYSQL_SYSVAR(udf_ds_use_real_table), MYSQL_SYSVAR(general_log), MYSQL_SYSVAR(index_hint_pushdown), diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h index d7d35b17df5..c93d41022d5 100644 --- a/storage/spider/spd_param.h +++ b/storage/spider/spd_param.h @@ -337,11 +337,6 @@ int spider_param_read_only_mode( THD *thd, int read_only_mode ); -#ifdef HA_CAN_BULK_ACCESS -int spider_param_bulk_access_free( - int bulk_access_free -); -#endif int spider_param_udf_ds_use_real_table( THD *thd, int udf_ds_use_real_table diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 1503c61b1bb..dc30278e66c 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -1834,9 +1834,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; -#ifdef HA_CAN_BULK_ACCESS - share->bulk_access_free = -1; -#endif #ifdef HA_CAN_FORCE_BULK_UPDATE share->force_bulk_update = -1; #endif @@ -2160,9 +2157,6 @@ int spider_parse_connect_info( 2147483647); SPIDER_PARAM_INT_WITH_MAX("aim", auto_increment_mode, 0, 3); SPIDER_PARAM_INT("alc", active_link_count, 1); -#ifdef HA_CAN_BULK_ACCESS - SPIDER_PARAM_INT_WITH_MAX("baf", bulk_access_free, 0, 1); -#endif SPIDER_PARAM_INT("bfz", buffer_size, 0); #ifndef WITHOUT_SPIDER_BG_SEARCH SPIDER_PARAM_LONGLONG("bfr", bgs_first_read, 0); @@ -2419,10 +2413,6 @@ int spider_parse_connect_info( net_read_timeouts, 0, 2147483647); SPIDER_PARAM_INT_WITH_MAX( "error_write_mode", error_write_mode, 0, 1); -#ifdef HA_CAN_BULK_ACCESS - SPIDER_PARAM_INT_WITH_MAX( - "bulk_access_free", bulk_access_free, 0, 1); -#endif SPIDER_PARAM_INT_WITH_MAX( "query_cache_sync", query_cache_sync, 0, 3); error_num = parse.fail(true); @@ -4549,8 +4539,6 @@ SPIDER_SHARE *spider_get_share( sizeof(uchar) * share->link_bitmap_size, &result_list->tmp_table_created, sizeof(uchar) * share->link_bitmap_size, -#ifdef HA_CAN_BULK_ACCESS -#endif &result_list->sql_kind_backup, sizeof(uint) * share->link_count, &result_list->casual_read, sizeof(int) * share->link_count, &spider->dbton_handler, @@ -5027,8 +5015,6 @@ SPIDER_SHARE *spider_get_share( sizeof(uchar) * share->link_bitmap_size, &result_list->tmp_table_created, sizeof(uchar) * share->link_bitmap_size, -#ifdef HA_CAN_BULK_ACCESS -#endif &result_list->sql_kind_backup, sizeof(uint) * share->link_count, &result_list->casual_read, sizeof(int) * share->link_count, &spider->dbton_handler, @@ -7733,18 +7719,10 @@ bool spider_check_direct_order_limit( spider->use_index_merge ? "TRUE" : "FALSE")); DBUG_PRINT("info",("spider is_clone=%s", spider->is_clone ? "TRUE" : "FALSE")); -#ifdef HA_CAN_BULK_ACCESS - DBUG_PRINT("info",("spider is_bulk_access_clone=%s", - spider->is_bulk_access_clone ? "TRUE" : "FALSE")); -#endif if ( spider->wide_handler->sql_command != SQLCOM_HA_READ && !spider->use_index_merge && -#ifdef HA_CAN_BULK_ACCESS - (!spider->is_clone || spider->is_bulk_access_clone) -#else !spider->is_clone -#endif ) { spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); bool first_check = TRUE; @@ -7946,12 +7924,6 @@ Field *spider_field_exchange( Field *field ) { DBUG_ENTER("spider_field_exchange"); -#ifdef HA_CAN_BULK_ACCESS - if (handler->is_bulk_access_clone) - { - handler = handler->pt_clone_source_handler; - } -#endif DBUG_PRINT("info",("spider in field=%p", field)); DBUG_PRINT("info",("spider in field->table=%p", field->table)); DBUG_PRINT("info",("spider table=%p", handler->get_table())); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index 11dc7a81ad8..305d8fc7327 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -3097,11 +3097,6 @@ int spider_commit( if (!(trx = (SPIDER_TRX*) thd_get_ha_data(thd, spider_hton_ptr))) DBUG_RETURN(0); /* transaction is not started */ -#ifdef HA_CAN_BULK_ACCESS - DBUG_PRINT("info",("spider trx->bulk_access_conn_first=%p", - trx->bulk_access_conn_first)); - trx->bulk_access_conn_first = NULL; -#endif /* We do (almost) nothing if the following two conditions are both met: @@ -3195,11 +3190,6 @@ int spider_rollback( if (!(trx = (SPIDER_TRX*) thd_get_ha_data(thd, spider_hton_ptr))) DBUG_RETURN(0); /* transaction is not started */ -#ifdef HA_CAN_BULK_ACCESS - DBUG_PRINT("info",("spider trx->bulk_access_conn_first=%p", - trx->bulk_access_conn_first)); - trx->bulk_access_conn_first = NULL; -#endif /* In case the rollback happens due to failure of LOCK TABLE, we need to clear the list of tables to lock. */ @@ -3936,34 +3926,3 @@ int spider_trx_check_link_idx_failed( DBUG_RETURN(0); } -#ifdef HA_CAN_BULK_ACCESS -void spider_trx_add_bulk_access_conn( - SPIDER_TRX *trx, - SPIDER_CONN *conn -) { - DBUG_ENTER("spider_trx_add_bulk_access_conn"); - DBUG_PRINT("info",("spider trx=%p", trx)); - DBUG_PRINT("info",("spider conn=%p", conn)); - DBUG_PRINT("info",("spider conn->bulk_access_requests=%u", - conn->bulk_access_requests)); - DBUG_PRINT("info",("spider conn->bulk_access_sended=%u", - conn->bulk_access_sended)); - DBUG_PRINT("info",("spider trx->bulk_access_conn_first=%p", - trx->bulk_access_conn_first)); - if (!conn->bulk_access_requests && !conn->bulk_access_sended) - { - if (!trx->bulk_access_conn_first) - { - trx->bulk_access_conn_first = conn; - } else { - trx->bulk_access_conn_last->bulk_access_next = conn; - } - trx->bulk_access_conn_last = conn; - conn->bulk_access_next = NULL; - } - conn->bulk_access_requests++; - DBUG_PRINT("info",("spider conn->bulk_access_requests=%u", - conn->bulk_access_requests)); - DBUG_VOID_RETURN; -} -#endif diff --git a/storage/spider/spd_trx.h b/storage/spider/spd_trx.h index 3bf93aada1a..2055a49717e 100644 --- a/storage/spider/spd_trx.h +++ b/storage/spider/spd_trx.h @@ -266,9 +266,3 @@ int spider_trx_check_link_idx_failed( ha_spider *spider ); -#ifdef HA_CAN_BULK_ACCESS -void spider_trx_add_bulk_access_conn( - SPIDER_TRX *trx, - SPIDER_CONN *conn -); -#endif From 84067291b4fe177a40754418a315ede7bf9536e8 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 18 Jun 2024 19:14:42 +0800 Subject: [PATCH 3/9] MDEV-28360 Spider: remove #ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name --- storage/spider/spd_db_conn.cc | 45 --------------------------------- storage/spider/spd_db_mysql.cc | 5 ---- storage/spider/spd_db_oracle.cc | 5 ---- storage/spider/spd_include.h | 1 - 4 files changed, 56 deletions(-) diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 4319616961b..a3113059143 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -1614,13 +1614,8 @@ int spider_db_append_key_where_internal( if (sql_kind == SPIDER_SQL_KIND_HANDLER) { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name const char *key_name = key_info->name.str; key_name_length = key_info->name.length; -#else - const char *key_name = key_info->name; - key_name_length = strlen(key_name); -#endif if (str->reserve(SPIDER_SQL_READ_LEN + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + key_name_length)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -8480,13 +8475,8 @@ int spider_db_open_item_ident( } if (str) { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if (item_ident->field_name.str) field_name_length = item_ident->field_name.length; -#else - if (item_ident->field_name) - field_name_length = strlen(item_ident->field_name); -#endif else field_name_length = 0; if (share->access_charset->cset == system_charset_info->cset) @@ -8497,14 +8487,9 @@ int spider_db_open_item_ident( DBUG_RETURN(HA_ERR_OUT_OF_MEM); } str->q_append(alias, alias_length); -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_dbton[dbton_id].db_util-> append_escaped_name(str, item_ident->field_name.str, field_name_length))) -#else - if ((error_num = spider_dbton[dbton_id].db_util-> - append_escaped_name(str, item_ident->field_name, field_name_length))) -#endif { DBUG_RETURN(error_num); } @@ -8512,15 +8497,9 @@ int spider_db_open_item_ident( if (str->reserve(alias_length)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(alias, alias_length); -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_dbton[dbton_id].db_util-> append_escaped_name_with_charset(str, item_ident->field_name.str, field_name_length, system_charset_info))) -#else - if ((error_num = spider_dbton[dbton_id].db_util-> - append_escaped_name_with_charset(str, item_ident->field_name, - field_name_length, system_charset_info))) -#endif { DBUG_RETURN(error_num); } @@ -8630,7 +8609,6 @@ int spider_db_open_item_ref( DBUG_ENTER("spider_db_open_item_ref"); if (item_ref->ref) { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ( (*(item_ref->ref))->type() != Item::CACHE_ITEM && item_ref->ref_type() != Item_ref::VIEW_REF && @@ -8638,34 +8616,16 @@ int spider_db_open_item_ref( item_ref->name.str && item_ref->alias_name_used ) -#else - if ( - (*(item_ref->ref))->type() != Item::CACHE_ITEM && - item_ref->ref_type() != Item_ref::VIEW_REF && - !item_ref->table_name && - item_ref->name && - item_ref->alias_name_used - ) -#endif { if (str) { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name uint length = item_ref->name.length; -#else - uint length = strlen(item_ref->name); -#endif if (str->reserve(length + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2)) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_dbton[dbton_id].db_util-> append_name(str, item_ref->name.str, length))) -#else - if ((error_num = spider_dbton[dbton_id].db_util-> - append_name(str, item_ref->name, length))) -#endif { DBUG_RETURN(error_num); } @@ -10320,13 +10280,8 @@ int spider_db_udf_copy_key_row( ) { int error_num; DBUG_ENTER("spider_db_udf_copy_key_row"); -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name if ((error_num = spider_db_append_name_with_quote_str(str, (char *) field->field_name.str, dbton_id))) -#else - if ((error_num = spider_db_append_name_with_quote_str(str, - (char *) field->field_name, dbton_id))) -#endif DBUG_RETURN(error_num); if (str->reserve(joint_length + *length + SPIDER_SQL_AND_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 8c8ed349d32..f0d0a166ed3 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -3669,13 +3669,8 @@ void spider_db_mbase::set_dup_key_idx( key_name = spider->share->tgt_pk_names[all_link_idx]; key_name_length = spider->share->tgt_pk_names_lengths[all_link_idx]; } else { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name key_name = table->key_info[roop_count].name.str; key_name_length = table->key_info[roop_count].name.length; -#else - key_name = table->key_info[roop_count].name; - key_name_length = strlen(key_name); -#endif } DBUG_PRINT("info",("spider key_name=%s", key_name)); if ( diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index c5bf59b8df8..455b52177dd 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -2431,13 +2431,8 @@ void spider_db_oracle::set_dup_key_idx( key_name = spider->share->tgt_pk_names[all_link_idx]; key_name_length = spider->share->tgt_pk_names_lengths[all_link_idx]; } else { -#ifdef SPIDER_use_LEX_CSTRING_for_KEY_Field_name key_name = (char *) table->s->key_info[roop_count].name.str; key_name_length = table->s->key_info[roop_count].name.length; -#else - key_name = table->s->key_info[roop_count].name; - key_name_length = strlen(key_name); -#endif } memcpy(tmp_pos, key_name, key_name_length + 1); DBUG_PRINT("info",("spider key_name=%s", key_name)); diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index d06d0d7be8b..473bdc2c416 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -109,7 +109,6 @@ #define SPIDER_read_record_read_record(A) read_record() #define SPIDER_has_Item_with_subquery -#define SPIDER_use_LEX_CSTRING_for_KEY_Field_name #define SPIDER_use_LEX_CSTRING_for_Field_blob_constructor #define SPIDER_use_LEX_CSTRING_for_database_tablename_alias #define SPIDER_THD_db_str(A) (A)->db.str From 9e1579788fcd7de5f79a7018869ba82977b2fe81 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 10 Sep 2024 11:52:22 +1000 Subject: [PATCH 4/9] MDEV-31788 Factor spider locking and unlocking code around sending queries --- storage/spider/ha_spider.cc | 360 +---- storage/spider/spd_conn.cc | 70 +- storage/spider/spd_conn.h | 10 + storage/spider/spd_db_conn.cc | 729 ++------- storage/spider/spd_db_mysql.cc | 1895 ++++-------------------- storage/spider/spd_group_by_handler.cc | 28 +- storage/spider/spd_table.cc | 20 +- 7 files changed, 528 insertions(+), 2584 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index e910ffcff56..2a49af4ee3b 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1381,18 +1381,6 @@ int ha_spider::index_end() DBUG_ENTER("ha_spider::index_end"); DBUG_PRINT("info",("spider this=%p", this)); active_index = MAX_KEY; -/* -#ifdef INFO_KIND_FORCE_LIMIT_BEGIN - info_limit = 9223372036854775807LL; -#endif - if ( - (error_num = drop_tmp_tables()) || - (error_num = check_and_end_bulk_update( - SPD_BU_START_BY_INDEX_OR_RND_INIT)) || - (error_num = spider_trx_check_link_idx_failed(this)) - ) - DBUG_RETURN(check_error_mode(error_num)); -*/ if ((error_num = drop_tmp_tables())) DBUG_RETURN(check_error_mode(error_num)); result_list.use_union = FALSE; @@ -1438,6 +1426,7 @@ int ha_spider::index_read_map_internal( start_key.key = key; start_key.keypart_map = keypart_map; start_key.flag = find_flag; + /* Query construction */ if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) DBUG_RETURN(error_num); @@ -1529,6 +1518,7 @@ int ha_spider::index_read_map_internal( } } + /* Query execution */ int roop_start, roop_end, lock_mode, link_ok; lock_mode = spider_conn_lock_mode(this); if (lock_mode) @@ -1596,26 +1586,16 @@ int ha_spider::index_read_map_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -1647,11 +1627,7 @@ int ha_spider::index_read_map_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -1676,13 +1652,9 @@ int ha_spider::index_read_map_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -1711,7 +1683,7 @@ int ha_spider::index_read_map_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -1956,26 +1928,16 @@ int ha_spider::index_read_last_map_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2007,11 +1969,7 @@ int ha_spider::index_read_last_map_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2036,13 +1994,9 @@ int ha_spider::index_read_last_map_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -2071,7 +2025,7 @@ int ha_spider::index_read_last_map_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -2365,27 +2319,17 @@ int ha_spider::index_first_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2417,11 +2361,7 @@ int ha_spider::index_first_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2446,13 +2386,9 @@ int ha_spider::index_first_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -2481,7 +2417,7 @@ int ha_spider::index_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -2722,27 +2658,17 @@ int ha_spider::index_last_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2774,11 +2700,7 @@ int ha_spider::index_last_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -2803,13 +2725,9 @@ int ha_spider::index_last_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -2838,7 +2756,7 @@ int ha_spider::index_last_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -3122,26 +3040,16 @@ int ha_spider::read_range_first_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -3173,11 +3081,7 @@ int ha_spider::read_range_first_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -3202,13 +3106,9 @@ int ha_spider::read_range_first_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -3237,7 +3137,7 @@ int ha_spider::read_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -3719,27 +3619,17 @@ int ha_spider::read_multi_range_first_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -3772,11 +3662,7 @@ int ha_spider::read_multi_range_first_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -3803,13 +3689,9 @@ int ha_spider::read_multi_range_first_internal( if (!error_num) { connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - error_num = spider_db_store_result(this, roop_count, table); + error_num = spider_unlock_after_query_2(conn, this, roop_count, table); if ( error_num && error_num != HA_ERR_END_OF_FILE && @@ -3836,7 +3718,7 @@ int ha_spider::read_multi_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -4474,28 +4356,18 @@ int ha_spider::read_multi_range_first_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -4534,11 +4406,7 @@ int ha_spider::read_multi_range_first_internal( -1, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -4572,11 +4440,7 @@ int ha_spider::read_multi_range_first_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -4601,13 +4465,9 @@ int ha_spider::read_multi_range_first_internal( break; } connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -4636,7 +4496,7 @@ int ha_spider::read_multi_range_first_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -5088,27 +4948,17 @@ int ha_spider::read_multi_range_next( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5141,11 +4991,7 @@ int ha_spider::read_multi_range_next( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5172,13 +5018,9 @@ int ha_spider::read_multi_range_next( if (!error_num) { connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - error_num = spider_db_store_result(this, roop_count, table); + error_num = spider_unlock_after_query_2(conn, this, roop_count, table); if ( error_num && error_num != HA_ERR_END_OF_FILE && @@ -5205,7 +5047,7 @@ int ha_spider::read_multi_range_next( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -5842,28 +5684,18 @@ int ha_spider::read_multi_range_next( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5902,11 +5734,7 @@ int ha_spider::read_multi_range_next( -1, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5940,11 +5768,7 @@ int ha_spider::read_multi_range_next( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -5969,13 +5793,9 @@ int ha_spider::read_multi_range_next( break; } connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -6004,7 +5824,7 @@ int ha_spider::read_multi_range_next( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -6461,27 +6281,17 @@ int ha_spider::rnd_next_internal( sql_type = SPIDER_SQL_TYPE_HANDLER; } 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -6513,11 +6323,7 @@ int ha_spider::rnd_next_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -6542,13 +6348,9 @@ int ha_spider::rnd_next_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -6577,7 +6379,7 @@ int ha_spider::rnd_next_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -7076,25 +6878,15 @@ int ha_spider::ft_read_internal( uint dbton_id = share->sql_dbton_ids[roop_count]; spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; SPIDER_CONN *conn = conns[roop_count]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_SELECT_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mons[roop_count]); if ((error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -7126,11 +6918,7 @@ int ha_spider::ft_read_internal( result_list.quick_mode, &need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -7155,13 +6943,9 @@ int ha_spider::ft_read_internal( DBUG_RETURN(check_error_mode_eof(error_num)); } connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(this, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -7190,7 +6974,7 @@ int ha_spider::ft_read_internal( result_link_idx = link_ok; } else { spider_db_discard_result(this, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } @@ -10933,25 +10717,15 @@ int ha_spider::drop_tmp_tables() uint dbton_id = share->sql_dbton_ids[roop_count]; spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; SPIDER_CONN *conn = conns[roop_count]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_TMP_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ((tmp_error_num = spider_db_set_names(this, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -10985,11 +10759,7 @@ int ha_spider::drop_tmp_tables() -1, &need_mons[roop_count]) ) { - 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; - tmp_error_num = spider_db_errorno(conn); + tmp_error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && need_mons[roop_count] @@ -11013,11 +10783,7 @@ int ha_spider::drop_tmp_tables() } error_num = tmp_error_num; } else { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } spider_clear_bit(result_list.tmp_table_created, roop_count); diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index cc3a6b52719..8cb55e8415f 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -2568,7 +2568,6 @@ void *spider_bg_conn_action( } else { sql_type = SPIDER_SQL_TYPE_HANDLER; } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (spider->use_fields) { if ((error_num = dbton_handler->set_sql_for_exec(sql_type, @@ -2587,16 +2586,12 @@ void *spider_bg_conn_action( strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd)); } } - pthread_mutex_lock(&conn->mta_conn_mutex); + /* todo: is it ok if the following statement is not locked? */ sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL; DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); if (!result_list->bgs_error) { - conn->need_mon = &spider->need_mons[conn->link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[conn->link_idx]); if (!(result_list->bgs_error = spider_db_set_names(spider, conn, conn->link_idx))) { @@ -2665,13 +2660,7 @@ void *spider_bg_conn_action( strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd)); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } else { spider->connection_ids[conn->link_idx] = conn->connection_id; @@ -2746,24 +2735,14 @@ void *spider_bg_conn_action( { DBUG_PRINT("info",("spider bg exec sql start")); spider = (ha_spider*) conn->bg_target; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[conn->link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[conn->link_idx]); *conn->bg_error_num = spider_db_query_with_set_names( conn->bg_sql_type, spider, conn, conn->link_idx ); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); conn->bg_exec_sql = FALSE; continue; } @@ -4134,3 +4113,42 @@ void spider_free_ipport_conn(void *info) } DBUG_VOID_RETURN; } + +void spider_lock_before_query(SPIDER_CONN *conn, int *need_mon) +{ + pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); + pthread_mutex_lock(&conn->mta_conn_mutex); + conn->need_mon = need_mon; + DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); + DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); + conn->mta_conn_mutex_lock_already = TRUE; + conn->mta_conn_mutex_unlock_later = TRUE; +} + +int spider_unlock_after_query(SPIDER_CONN *conn, int ret) +{ + 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; + pthread_mutex_unlock(&conn->mta_conn_mutex); + return ret; +} + +int spider_unlock_after_query_1(SPIDER_CONN *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; + return spider_db_errorno(conn); +} + +int spider_unlock_after_query_2(SPIDER_CONN *conn, ha_spider *spider, int link_idx, TABLE *table) +{ + 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; + return spider_db_store_result(spider, link_idx, table); +} diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h index 405832a1e7b..59802b00712 100644 --- a/storage/spider/spd_conn.h +++ b/storage/spider/spd_conn.h @@ -24,6 +24,8 @@ #define SPIDER_SIMPLE_RECORDS 3 #define SPIDER_SIMPLE_CHECKSUM_TABLE 4 +struct TABLE; + /* The SPIDER_CONN_LOOP_CHECK has been added to the loop_check queue to check for self-reference. @@ -454,3 +456,11 @@ SPIDER_CONN* spider_get_conn_from_idle_connection int *error_num ); void spider_free_ipport_conn(void *info); + +void spider_lock_before_query(SPIDER_CONN *conn, int *need_mon); + +int spider_unlock_after_query(SPIDER_CONN *conn, int ret); + +int spider_unlock_after_query_1(SPIDER_CONN *conn); + +int spider_unlock_after_query_2(SPIDER_CONN *conn, ha_spider *spider, int link_idx, TABLE *table); diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index a3113059143..8750e87237e 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -100,8 +100,6 @@ int spider_db_connect( } } - if (thd) - { conn->connect_timeout = spider_param_connect_timeout(thd, share->connect_timeouts[link_idx]); conn->net_read_timeout = spider_param_net_read_timeout(thd, @@ -113,16 +111,6 @@ int spider_db_connect( connect_retry_count = 0; else connect_retry_count = spider_param_connect_retry_count(thd); - } else { - conn->connect_timeout = spider_param_connect_timeout(NULL, - share->connect_timeouts[link_idx]); - conn->net_read_timeout = spider_param_net_read_timeout(NULL, - share->net_read_timeouts[link_idx]); - conn->net_write_timeout = spider_param_net_write_timeout(NULL, - share->net_write_timeouts[link_idx]); - connect_retry_interval = spider_param_connect_retry_interval(NULL); - connect_retry_count = spider_param_connect_retry_count(NULL); - } DBUG_PRINT("info",("spider connect_timeout=%u", conn->connect_timeout)); DBUG_PRINT("info",("spider net_read_timeout=%u", conn->net_read_timeout)); DBUG_PRINT("info",("spider net_write_timeout=%u", conn->net_write_timeout)); @@ -923,19 +911,10 @@ int spider_db_query_for_bulk_update( SPIDER_SHARE *share = spider->share; DBUG_ENTER("spider_db_query_for_bulk_update"); - pthread_mutex_assert_owner(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[link_idx] && spider->need_mons[link_idx] @@ -969,11 +948,7 @@ int spider_db_query_for_bulk_update( -1, &spider->need_mons[link_idx]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -1018,11 +993,7 @@ int spider_db_query_for_bulk_update( } if (error_num > 0 && !conn->db_conn->is_dup_entry_error(error_num)) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[link_idx] && spider->need_mons[link_idx] @@ -1046,12 +1017,7 @@ int spider_db_query_for_bulk_update( } DBUG_RETURN(error_num); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_unlock_after_query(conn, 0)); } size_t spider_db_real_escape_string( @@ -4689,16 +4655,16 @@ int spider_db_seek_next( link_idx = link_idx_holder->link_idx; spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, link_idx))) { DBUG_PRINT("info",("spider error_num 6=%d", error_num)); DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); if (conn->db_conn->limit_mode() == 1) { + pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); + pthread_mutex_lock(&conn->mta_conn_mutex); conn->db_conn->set_limit(result_list->limit_num); if (fields->is_first_link_ok_chain(link_idx_chain)) { @@ -4711,18 +4677,10 @@ int spider_db_seek_next( } pthread_mutex_unlock(&conn->bg_conn_mutex); } else { - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[conn->link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( spider->need_mons[link_idx] ) { @@ -4739,11 +4697,7 @@ int spider_db_seek_next( result_list->quick_mode, &spider->need_mons[link_idx]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( spider->need_mons[link_idx] ) { @@ -4753,14 +4707,9 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } spider->connection_ids[link_idx] = conn->connection_id; - 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; if (fields->is_first_link_ok_chain(link_idx_chain)) { - if ((error_num = spider_db_store_result(spider, link_idx, - table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, link_idx, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -4775,7 +4724,7 @@ int spider_db_seek_next( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, link_idx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } } @@ -4796,16 +4745,16 @@ int spider_db_seek_next( } spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count))) { DBUG_PRINT("info",("spider error_num 6=%d", error_num)); DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); if (conn->db_conn->limit_mode() == 1) { + pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); + pthread_mutex_lock(&conn->mta_conn_mutex); conn->db_conn->set_limit(result_list->limit_num); if (roop_count == link_ok) { @@ -4818,18 +4767,10 @@ int spider_db_seek_next( } pthread_mutex_unlock(&conn->bg_conn_mutex); } else { - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -4862,11 +4803,7 @@ int spider_db_seek_next( result_list->quick_mode, &spider->need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -4892,14 +4829,9 @@ int spider_db_seek_next( DBUG_RETURN(error_num); } spider->connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(spider, roop_count, - table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -4929,7 +4861,7 @@ int spider_db_seek_next( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } } @@ -5066,15 +4998,15 @@ int spider_db_seek_last( } conn = spider->conns[roop_count]; spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); if (conn->db_conn->limit_mode() == 1) { + pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); + pthread_mutex_lock(&conn->mta_conn_mutex); conn->db_conn->set_limit(result_list->limit_num); if (roop_count == link_ok) { @@ -5087,18 +5019,10 @@ int spider_db_seek_last( } pthread_mutex_unlock(&conn->bg_conn_mutex); } else { - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -5131,11 +5055,7 @@ int spider_db_seek_last( result_list->quick_mode, &spider->need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -5160,13 +5080,9 @@ int spider_db_seek_last( DBUG_RETURN(error_num); } spider->connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(spider, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -5195,7 +5111,7 @@ int spider_db_seek_last( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } } @@ -5283,25 +5199,15 @@ int spider_db_seek_last( } conn = spider->conns[roop_count]; spider_db_handler *dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -5334,11 +5240,7 @@ int spider_db_seek_last( result_list->quick_mode, &spider->need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -5363,13 +5265,9 @@ int spider_db_seek_last( DBUG_RETURN(error_num); } spider->connection_ids[roop_count] = conn->connection_id; - 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; if (roop_count == link_ok) { - if ((error_num = spider_db_store_result(spider, roop_count, table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, roop_count, table))) { if ( error_num != HA_ERR_END_OF_FILE && @@ -5398,7 +5296,7 @@ int spider_db_seek_last( spider->result_link_idx = link_ok; } else { spider_db_discard_result(spider, roop_count, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } } DBUG_RETURN(spider_db_fetch(buf, spider, table)); @@ -6044,7 +5942,6 @@ int spider_db_bulk_insert( sql_type = SPIDER_SQL_TYPE_INSERT_SQL; conn = spider->conns[roop_count2]; dbton_handler = spider->dbton_handler[conn->dbton_id]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_handler->set_sql_for_exec(sql_type, roop_count2))) { @@ -6052,21 +5949,12 @@ int spider_db_bulk_insert( spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count2]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count2]); if ((error_num = spider_db_set_names(spider, conn, roop_count2))) { if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count2] && spider->need_mons[roop_count2] @@ -6106,11 +5994,7 @@ int spider_db_bulk_insert( { conn->db_conn->set_dup_key_idx(spider, roop_count2); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -6137,16 +6021,12 @@ int spider_db_bulk_insert( } DBUG_RETURN(error_num); } - 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; if (!insert_info && copy_info) { insert_info = conn->db_conn->inserted_info(dbton_handler, copy_info); } - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (first_insert_link_idx == -1) { first_insert_link_idx = roop_count2; @@ -6155,13 +6035,7 @@ int spider_db_bulk_insert( } conn = first_insert_conn; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[first_insert_link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[first_insert_link_idx]); if (spider->sql_kinds & SPIDER_SQL_KIND_SQL) spider->set_insert_to_pos_sql(SPIDER_SQL_TYPE_INSERT_SQL); if (table->next_number_field && @@ -6181,12 +6055,7 @@ int spider_db_bulk_insert( else if ((error_num = dbton_handler-> show_last_insert_id(first_insert_link_idx, last_insert_id))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } table->next_number_field->set_notnull(); if ( @@ -6195,19 +6064,10 @@ int spider_db_bulk_insert( (error_num = table->next_number_field->store( last_insert_id, TRUE)) ) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); spider->store_last_insert_id = 0; } if ( @@ -6520,25 +6380,15 @@ int spider_db_update( conn = spider->conns[roop_count]; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; conn->ignore_dup_key = spider->wide_handler->ignore_dup_key; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_UPDATE_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -6571,11 +6421,7 @@ int spider_db_update( -1, &spider->need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -6612,12 +6458,7 @@ int spider_db_update( if ((error_num = dbton_hdl->append_insert_for_recovery( SPIDER_SQL_TYPE_INSERT_SQL, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, spider->wide_handler->trx->thd, @@ -6628,11 +6469,7 @@ int spider_db_update( -1, &spider->need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -6660,11 +6497,7 @@ int spider_db_update( DBUG_RETURN(error_num); } } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); result_list->update_sqls[roop_count].length(0); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); @@ -6778,24 +6611,14 @@ int spider_db_direct_update( conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_UPDATE_SQL; 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_setup_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -6831,11 +6654,7 @@ int spider_db_direct_update( ) && (error_num != HA_ERR_FOUND_DUPP_KEY || !spider->ignore_dup_key) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -6870,11 +6689,7 @@ int spider_db_direct_update( DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); counted = TRUE; } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); DBUG_RETURN(0); @@ -6976,24 +6791,14 @@ int spider_db_direct_update( conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_UPDATE_SQL; 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7030,11 +6835,7 @@ int spider_db_direct_update( (error_num != HA_ERR_FOUND_DUPP_KEY || !spider->wide_handler->ignore_dup_key) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( error_num != ER_DUP_ENTRY && error_num != ER_DUP_KEY && @@ -7069,11 +6870,7 @@ int spider_db_direct_update( DBUG_PRINT("info", ("spider found_rows = %llu", *found_rows)); counted = TRUE; } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } spider->reset_sql_sql(SPIDER_SQL_TYPE_UPDATE_SQL); DBUG_RETURN(0); @@ -7128,32 +6925,18 @@ int spider_db_delete( ) { conn = spider->conns[roop_count]; 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( SPIDER_SQL_TYPE_DELETE_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_query_with_set_names( SPIDER_SQL_TYPE_DELETE_SQL, spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); result_list->update_sqls[roop_count].length(0); } if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) @@ -7238,24 +7021,14 @@ int spider_db_direct_delete( conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_DELETE_SQL; 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_setup_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7288,11 +7061,7 @@ int spider_db_direct_delete( -1, &spider->need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7316,17 +7085,13 @@ int spider_db_direct_delete( } DBUG_RETURN(error_num); } - 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; if (!counted) { *delete_rows = spider->conns[roop_count]->db_conn->affected_rows(); DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } int error_num2 = 0; if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) @@ -7404,24 +7169,14 @@ int spider_db_direct_delete( conn = spider->conns[roop_count]; sql_type = SPIDER_SQL_TYPE_DELETE_SQL; 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))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7454,11 +7209,7 @@ int spider_db_direct_delete( -1, &spider->need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7482,17 +7233,13 @@ int spider_db_direct_delete( } DBUG_RETURN(error_num); } - 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; if (!counted) { *delete_rows = spider->conns[roop_count]->db_conn->affected_rows(); DBUG_PRINT("info", ("spider delete_rows = %llu", *delete_rows)); counted = TRUE; } - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } int error_num2 = 0; if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) @@ -7527,18 +7274,12 @@ int spider_db_delete_all_rows( uint dbton_id = share->sql_dbton_ids[roop_count]; spider_db_handler *dbton_hdl = spider->dbton_handler[dbton_id]; conn = spider->conns[roop_count]; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_DELETE_SQL, roop_count))) { DBUG_RETURN(error_num); } - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[roop_count]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[roop_count]); spider_conn_set_timeout_from_share(conn, roop_count, spider->wide_handler->trx->thd, share); @@ -7560,11 +7301,7 @@ int spider_db_delete_all_rows( /* retry */ if ((error_num = spider_db_ping(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7590,11 +7327,7 @@ int spider_db_delete_all_rows( } if ((error_num = spider_db_set_names(spider, conn, roop_count))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7627,11 +7360,7 @@ int spider_db_delete_all_rows( -1, &spider->need_mons[roop_count]) ) { - 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; - error_num = spider_db_errorno(conn); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7656,11 +7385,7 @@ int spider_db_delete_all_rows( DBUG_RETURN(error_num); } } else { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if ( share->monitoring_kind[roop_count] && spider->need_mons[roop_count] @@ -7685,11 +7410,7 @@ int spider_db_delete_all_rows( DBUG_RETURN(error_num); } } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) DBUG_RETURN(error_num); @@ -9462,13 +9183,7 @@ int spider_db_udf_direct_sql( sql_command_backup = c_thd->lex->sql_command; c_thd->lex->sql_command = SQLCOM_INSERT; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ( !(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)) @@ -9690,11 +9405,7 @@ int spider_db_udf_direct_sql( } while (status == 0); } } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (need_trx_end && insert_start) { if (error_num) @@ -9853,20 +9564,10 @@ int spider_db_udf_ping_table( spider.conn_link_idx = &tmp_conn_link_idx; spider.db_request_phase = &db_request_phase; spider.db_request_id = &db_request_id; - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ((error_num = spider_db_ping(&spider, conn, 0))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); if (error_num == ER_CON_COUNT_ERROR) @@ -9878,11 +9579,7 @@ int spider_db_udf_ping_table( share->server_names[0]); DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (!ping_only) { int init_sql_alloc_size = @@ -9925,20 +9622,10 @@ int spider_db_udf_ping_table( my_afree(sql_buf); DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ((error_num = spider_db_set_names(&spider, conn, 0))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); DBUG_PRINT("info",("spider error_num=%d", error_num)); @@ -9953,23 +9640,15 @@ int spider_db_udf_ping_table( -1, &need_mon) ) { - 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; - error_num = spider_db_errorno(conn); + error_num = spider_unlock_after_query_1(conn); table_mon_list->last_mon_result = error_num; pthread_mutex_unlock(&table_mon_list->monitor_mutex); DBUG_PRINT("info",("spider error_num=%d", error_num)); my_afree(sql_buf); DBUG_RETURN(error_num); } - 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_unlock_after_query(conn, 0); spider_db_discard_result(&spider, 0, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); } table_mon_list->last_mon_result = 0; @@ -10185,34 +9864,18 @@ int spider_db_udf_ping_table_mon_next( DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &need_mon); if ((error_num = spider_db_ping(&spider, conn, 0))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), share->server_names[0]); my_afree(sql_buf); - DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE); + DBUG_RETURN(spider_unlock_after_query(conn, ER_CONNECT_TO_FOREIGN_DATA_SOURCE)); } if ((error_num = spider_db_set_names(&spider, conn, 0))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } spider_conn_set_timeout_from_share(conn, 0, thd, share); if (spider_db_query( @@ -10222,12 +9885,8 @@ int spider_db_udf_ping_table_mon_next( -1, &need_mon) ) { - 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; my_afree(sql_buf); - DBUG_RETURN(spider_db_errorno(conn)); + DBUG_RETURN(spider_unlock_after_query_1(conn)); } st_spider_db_request_key request_key; request_key.spider_thread_id = trx.spider_thread_id; @@ -10237,30 +9896,22 @@ int spider_db_udf_ping_table_mon_next( request_key.next = NULL; if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) { - 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; if (error_num) { - pthread_mutex_unlock(&conn->mta_conn_mutex); my_afree(sql_buf); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } - else if ((error_num = spider_db_errorno(conn))) + else if ((error_num = spider_unlock_after_query_1(conn))) { my_afree(sql_buf); DBUG_RETURN(error_num); } + spider_unlock_after_query(conn, 0); my_error(HA_ERR_OUT_OF_MEM, MYF(0)); my_afree(sql_buf); DBUG_RETURN(HA_ERR_OUT_OF_MEM); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); my_afree(sql_buf); error_num = res->fetch_table_mon_status(mon_table_result->result_status); res->free_result(); @@ -10338,20 +9989,10 @@ int spider_db_udf_copy_tables( spider_conn_clear_queue_at_commit(tmp_conn); if (!tmp_conn->trx_start) { - pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); - pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - tmp_conn->need_mon = &tmp_spider->need_mons[0]; - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = TRUE; - tmp_conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(tmp_conn, &tmp_spider->need_mons[0]); if (spider_db_ping(tmp_spider, tmp_conn, 0)) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), tmp_spider->share->server_names[0]); error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; @@ -10362,18 +10003,10 @@ int spider_db_udf_copy_tables( (error_num = spider_db_start_transaction(tmp_conn, tmp_spider->need_mons)) ) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_start_transaction; } - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); } } } else { @@ -10393,20 +10026,10 @@ int spider_db_udf_copy_tables( { tmp_spider = &spider[roop_count]; tmp_conn = tmp_spider->conns[0]; - pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); - pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - tmp_conn->need_mon = &tmp_spider->need_mons[0]; - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = TRUE; - tmp_conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(tmp_conn, &tmp_spider->need_mons[0]); if (spider_db_ping(tmp_spider, tmp_conn, 0)) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), tmp_spider->share->server_names[0]); error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE; @@ -10419,21 +10042,13 @@ int spider_db_udf_copy_tables( (error_num = spider_db_lock_tables(tmp_spider, 0)) ) ) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); tmp_conn->table_lock = 0; if (error_num == HA_ERR_OUT_OF_MEM) my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); goto error_lock_tables; } - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); tmp_conn->table_lock = 1; } } @@ -10441,23 +10056,13 @@ int spider_db_udf_copy_tables( tmp_conn = src_tbl_conn->conn; spider_conn_set_timeout_from_share(tmp_conn, 0, copy_tables->trx->thd, src_tbl_conn->share); - pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); - pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - tmp_conn->need_mon = &src_tbl_conn->need_mon; - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = TRUE; - tmp_conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(tmp_conn, &src_tbl_conn->need_mon); if (select_ct->exec_query( tmp_conn, -1, &src_tbl_conn->need_mon) ) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(tmp_conn); + error_num= spider_unlock_after_query_1(tmp_conn); if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); @@ -10485,11 +10090,7 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_db_query; } for (dst_tbl_conn = dst_tbl_conn->next; dst_tbl_conn; @@ -10503,11 +10104,7 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_db_query; } } @@ -10532,11 +10129,7 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_db_query; } if ( @@ -10550,12 +10143,7 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); - error_num = ER_OUT_OF_RESOURCES; + error_num= spider_unlock_after_query(tmp_conn, ER_OUT_OF_RESOURCES); goto error_db_query; } error_num = 0; @@ -10565,20 +10153,12 @@ int spider_db_udf_copy_tables( my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); goto error_db_query; } result->free_result(); delete result; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn; dst_tbl_conn = dst_tbl_conn->next) { @@ -10597,11 +10177,7 @@ int spider_db_udf_copy_tables( } if (error_num) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); @@ -10609,31 +10185,12 @@ int spider_db_udf_copy_tables( } error_num = HA_ERR_END_OF_FILE; end_of_file = TRUE; - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); } } if (!error_num && roop_count) { -/* - dst_tbl_conn = copy_tables->table_conn[1]; - spider_db_copy_table *source_ct = dst_tbl_conn->copy_table; - for (dst_tbl_conn = dst_tbl_conn->next; dst_tbl_conn; - dst_tbl_conn = dst_tbl_conn->next) - { - insert_ct = dst_tbl_conn->copy_table; - if (insert_ct->copy_insert_values(source_ct)) - { - my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); - error_num = ER_OUT_OF_RESOURCES; - goto error_db_query; - } - } -*/ #ifndef WITHOUT_SPIDER_BG_SEARCH if (copy_tables->bg_mode) { @@ -10654,13 +10211,7 @@ int spider_db_udf_copy_tables( { tmp_conn = dst_tbl_conn->conn; insert_ct = dst_tbl_conn->copy_table; - pthread_mutex_assert_not_owner(&tmp_conn->mta_conn_mutex); - pthread_mutex_lock(&tmp_conn->mta_conn_mutex); - tmp_conn->need_mon = &dst_tbl_conn->need_mon; - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = TRUE; - tmp_conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(tmp_conn, &dst_tbl_conn->need_mon); spider_conn_set_timeout_from_share(tmp_conn, 0, copy_tables->trx->thd, dst_tbl_conn->share); if (insert_ct->exec_query( @@ -10668,21 +10219,13 @@ int spider_db_udf_copy_tables( -1, &dst_tbl_conn->need_mon) ) { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - error_num = spider_db_errorno(tmp_conn); + error_num= spider_unlock_after_query_1(tmp_conn); if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM) my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM, ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0)); goto error_db_query; } else { - DBUG_ASSERT(tmp_conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(tmp_conn->mta_conn_mutex_unlock_later); - tmp_conn->mta_conn_mutex_lock_already = FALSE; - tmp_conn->mta_conn_mutex_unlock_later = FALSE; - pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); + spider_unlock_after_query(tmp_conn, 0); } } #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -10818,20 +10361,14 @@ int spider_db_open_handler( SPIDER_CONN *conn, int link_idx ) { - int error_num; + int error_num= 0; SPIDER_SHARE *share = spider->share; uint *handler_id_ptr = &spider->m_handler_id[link_idx] ; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; DBUG_ENTER("spider_db_open_handler"); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if (!spider->handler_opened(link_idx, conn->conn_kind)) *handler_id_ptr = conn->opened_handlers; if (!spider->handler_opened(link_idx, conn->conn_kind)) @@ -10867,20 +10404,9 @@ int spider_db_open_handler( } DBUG_PRINT("info",("spider conn=%p", conn)); DBUG_PRINT("info",("spider opened_handlers=%u", conn->opened_handlers)); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); error: - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } @@ -10890,31 +10416,17 @@ int spider_db_close_handler( int link_idx, uint tgt_conn_kind ) { - int error_num; + int error_num= 0; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; DBUG_ENTER("spider_db_close_handler"); DBUG_PRINT("info",("spider conn=%p", conn)); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if (spider->handler_opened(link_idx, tgt_conn_kind)) { dbton_hdl->reset_sql(SPIDER_SQL_TYPE_HANDLER); if ((error_num = dbton_hdl->append_close_handler_part( SPIDER_SQL_TYPE_HANDLER, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - + goto error; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, spider->share); @@ -10933,20 +10445,9 @@ int spider_db_close_handler( conn->opened_handlers--; DBUG_PRINT("info",("spider opened_handlers=%u", conn->opened_handlers)); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); error: - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index f0d0a166ed3..9ab15058253 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -2489,37 +2489,24 @@ int spider_db_mbase::select_db( DBUG_RETURN(mysql_select_db(db_conn, dbname)); } +static int spider_db_query_with_lock(SPIDER_CONN *conn, const char *query, + uint len, int *need_mon) +{ + int error_num= 0; + spider_lock_before_query(conn, need_mon); + if (spider_db_query(conn, query, len, -1, need_mon)) + error_num= spider_db_errorno(conn); + return spider_unlock_after_query(conn, error_num); +} + int spider_db_mbase::consistent_snapshot( int *need_mon ) { DBUG_ENTER("spider_db_mbase::consistent_snapshot"); DBUG_PRINT("info",("spider this=%p", this)); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_START_CONSISTENT_SNAPSHOT_STR, - SPIDER_SQL_START_CONSISTENT_SNAPSHOT_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_START_CONSISTENT_SNAPSHOT_STR, + SPIDER_SQL_START_CONSISTENT_SNAPSHOT_LEN, need_mon)); } bool spider_db_mbase::trx_start_in_bulk_sql() @@ -2554,77 +2541,30 @@ int spider_db_mbase::commit( ) { DBUG_ENTER("spider_db_mbase::commit"); DBUG_PRINT("info",("spider this=%p", this)); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_COMMIT_STR, - SPIDER_SQL_COMMIT_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, SPIDER_SQL_COMMIT_STR, + SPIDER_SQL_COMMIT_LEN, need_mon)); } int spider_db_mbase::rollback( int *need_mon ) { bool is_error; - int error_num; + int error_num= 0; DBUG_ENTER("spider_db_mbase::rollback"); DBUG_PRINT("info",("spider this=%p", this)); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ROLLBACK_STR, - SPIDER_SQL_ROLLBACK_LEN, - -1, - need_mon) - ) { - is_error = conn->thd->is_error(); - error_num = spider_db_errorno(conn); - if ( - error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && - !is_error - ) + spider_lock_before_query(conn, need_mon); + if (spider_db_query(conn, SPIDER_SQL_ROLLBACK_STR, + SPIDER_SQL_ROLLBACK_LEN, -1, need_mon)) + { + is_error= conn->thd->is_error(); + error_num= spider_db_errorno(conn); + if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && !is_error) + { conn->thd->clear_error(); - else { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + error_num= 0; } } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_db_mbase::xa_start( @@ -2657,32 +2597,8 @@ int spider_db_mbase::xa_end( sql_str.length(0); sql_str.q_append(SPIDER_SQL_XA_END_STR, SPIDER_SQL_XA_END_LEN); spider_db_append_xid_str(&sql_str, xid); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, sql_str.ptr(), + sql_str.length(), need_mon)); } int spider_db_mbase::xa_prepare( @@ -2698,32 +2614,8 @@ int spider_db_mbase::xa_prepare( sql_str.length(0); sql_str.q_append(SPIDER_SQL_XA_PREPARE_STR, SPIDER_SQL_XA_PREPARE_LEN); spider_db_append_xid_str(&sql_str, xid); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, sql_str.ptr(), + sql_str.length(), need_mon)); } int spider_db_mbase::xa_commit( @@ -2739,32 +2631,8 @@ int spider_db_mbase::xa_commit( sql_str.length(0); sql_str.q_append(SPIDER_SQL_XA_COMMIT_STR, SPIDER_SQL_XA_COMMIT_LEN); spider_db_append_xid_str(&sql_str, xid); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, sql_str.ptr(), + sql_str.length(), need_mon)); } int spider_db_mbase::xa_rollback( @@ -2780,32 +2648,8 @@ int spider_db_mbase::xa_rollback( sql_str.length(0); sql_str.q_append(SPIDER_SQL_XA_ROLLBACK_STR, SPIDER_SQL_XA_ROLLBACK_LEN); spider_db_append_xid_str(&sql_str, xid); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock(conn, sql_str.ptr(), + sql_str.length(), need_mon)); } bool spider_db_mbase::set_trx_isolation_in_bulk_sql() @@ -2824,113 +2668,21 @@ int spider_db_mbase::set_trx_isolation( switch (trx_isolation) { case ISO_READ_UNCOMMITTED: - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ISO_READ_UNCOMMITTED_STR, - SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - break; + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_ISO_READ_UNCOMMITTED_STR, + SPIDER_SQL_ISO_READ_UNCOMMITTED_LEN, need_mon)); case ISO_READ_COMMITTED: - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ISO_READ_COMMITTED_STR, - SPIDER_SQL_ISO_READ_COMMITTED_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - break; + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_ISO_READ_COMMITTED_STR, + SPIDER_SQL_ISO_READ_COMMITTED_LEN, need_mon)); case ISO_REPEATABLE_READ: - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ISO_REPEATABLE_READ_STR, - SPIDER_SQL_ISO_REPEATABLE_READ_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - break; + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_ISO_REPEATABLE_READ_STR, + SPIDER_SQL_ISO_REPEATABLE_READ_LEN, need_mon)); case ISO_SERIALIZABLE: - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_ISO_SERIALIZABLE_STR, - SPIDER_SQL_ISO_SERIALIZABLE_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - break; + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_ISO_SERIALIZABLE_STR, + SPIDER_SQL_ISO_SERIALIZABLE_LEN, need_mon)); default: DBUG_RETURN(HA_ERR_UNSUPPORTED); } @@ -2951,60 +2703,12 @@ int spider_db_mbase::set_autocommit( DBUG_ENTER("spider_db_mbase::set_autocommit"); DBUG_PRINT("info",("spider this=%p", this)); if (autocommit) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_AUTOCOMMIT_ON_STR, - SPIDER_SQL_AUTOCOMMIT_ON_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_AUTOCOMMIT_OFF_STR, - SPIDER_SQL_AUTOCOMMIT_OFF_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_AUTOCOMMIT_ON_STR, + SPIDER_SQL_AUTOCOMMIT_ON_LEN, need_mon)); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_AUTOCOMMIT_OFF_STR, + SPIDER_SQL_AUTOCOMMIT_OFF_LEN, need_mon)); } bool spider_db_mbase::set_sql_log_off_in_bulk_sql() @@ -3021,60 +2725,12 @@ int spider_db_mbase::set_sql_log_off( DBUG_ENTER("spider_db_mbase::set_sql_log_off"); DBUG_PRINT("info",("spider this=%p", this)); if (sql_log_off) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_SQL_LOG_ON_STR, - SPIDER_SQL_SQL_LOG_ON_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } else { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_SQL_LOG_OFF_STR, - SPIDER_SQL_SQL_LOG_OFF_LEN, - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_SQL_LOG_ON_STR, + SPIDER_SQL_SQL_LOG_ON_LEN, need_mon)); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_SQL_LOG_OFF_STR, + SPIDER_SQL_SQL_LOG_OFF_LEN, need_mon)); } bool spider_db_mbase::set_wait_timeout_in_bulk_sql() @@ -3102,32 +2758,8 @@ int spider_db_mbase::set_wait_timeout( DBUG_RETURN(HA_ERR_OUT_OF_MEM); sql_str.q_append(SPIDER_SQL_WAIT_TIMEOUT_STR, SPIDER_SQL_WAIT_TIMEOUT_LEN); sql_str.q_append(timeout_str, timeout_str_length); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, sql_str.ptr(), sql_str.length(), need_mon)); } bool spider_db_mbase::set_sql_mode_in_bulk_sql() @@ -3165,32 +2797,8 @@ int spider_db_mbase::set_sql_mode( } } sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, sql_str.ptr(), sql_str.length(), need_mon)); } bool spider_db_mbase::set_time_zone_in_bulk_sql() @@ -3217,32 +2825,8 @@ int spider_db_mbase::set_time_zone( sql_str.q_append(SPIDER_SQL_TIME_ZONE_STR, SPIDER_SQL_TIME_ZONE_LEN); sql_str.q_append(tz_str->ptr(), tz_str->length()); sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - need_mon) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, sql_str.ptr(), sql_str.length(), need_mon)); } int spider_db_mbase::exec_simple_sql_with_result( @@ -3254,17 +2838,10 @@ int spider_db_mbase::exec_simple_sql_with_result( int *need_mon, SPIDER_DB_RESULT **res ) { - int error_num; + int error_num= 0; DBUG_ENTER("spider_db_mbase::exec_simple_sql_with_result"); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, all_link_idx, trx->thd, - share); + spider_lock_before_query(conn, need_mon); + spider_conn_set_timeout_from_share(conn, all_link_idx, trx->thd, share); if ( (error_num = spider_db_set_names_internal(trx, share, conn, all_link_idx, need_mon)) || @@ -3278,87 +2855,39 @@ int spider_db_mbase::exec_simple_sql_with_result( (error_num = spider_db_errorno(conn)) ) ) { - if ( - error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && - !conn->disable_reconnect - ) { - /* retry */ - if ((error_num = spider_db_ping_internal(share, conn, - all_link_idx, need_mon))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); - DBUG_RETURN(error_num); - } - if ((error_num = spider_db_set_names_internal(trx, share, conn, - all_link_idx, need_mon))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, all_link_idx, trx->thd, - share); - if (spider_db_query( - conn, - sql, - sql_length, - -1, - need_mon) + if ( + error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect ) { - 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; - DBUG_PRINT("info", ("spider error_num=%d 3", error_num)); - DBUG_RETURN(spider_db_errorno(conn)); - } - } else { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); - DBUG_RETURN(error_num); + if ((error_num = spider_db_ping_internal(share, conn, + all_link_idx, need_mon))) + goto unlock; + if ((error_num= spider_db_set_names_internal(trx, share, conn, + all_link_idx, need_mon))) + goto unlock; + spider_conn_set_timeout_from_share(conn, all_link_idx, trx->thd, + share); + if (spider_db_query( + conn, + sql, + sql_length, + -1, + need_mon) + ) { + error_num= spider_db_errorno(conn); + goto unlock; + } + } else + goto unlock; } - } - if (!(*res = store_result(NULL, NULL, &error_num))) - { - 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; - if (error_num) + if (!(*res = store_result(NULL, NULL, &error_num))) { - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); - DBUG_RETURN(error_num); + if (error_num || (error_num= spider_db_errorno(conn)) || + (error_num= ER_QUERY_ON_FOREIGN_DATA_SOURCE)) + goto unlock; } - else if ((error_num = spider_db_errorno(conn))) - { - DBUG_PRINT("info", ("spider error_num=%d 6", error_num)); - DBUG_RETURN(error_num); - } else { - DBUG_PRINT("info", ("spider error_num=%d 7", - ER_QUERY_ON_FOREIGN_DATA_SOURCE)); - DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); - } - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_db_mbase::show_master_status( @@ -3411,10 +2940,6 @@ int spider_db_mbase::show_master_status( spider_store_binlog_pos_gtid(table, NULL, 0, conn->access_charset); } } -/* - res->free_result(); - delete res; -*/ if (error_num) { DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); @@ -3480,10 +3005,6 @@ int spider_db_mbase::select_binlog_gtid_pos( { spider_store_binlog_pos_gtid(table, gtid_pos, strlen(gtid_pos), conn->access_charset); } -/* - res->free_result(); - delete res; -*/ if (error_num) { DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); @@ -4016,70 +3537,15 @@ int spider_db_mysql_util::append_column_value( 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); -*/ #ifdef DBUG_TRACE 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)); -*/ #endif -/* - 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); @@ -4108,27 +3574,6 @@ int spider_db_mysql_util::append_column_value( 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 -*/ if (field->result_type() == STRING_RESULT) { DBUG_PRINT("info", ("spider STRING_RESULT")); @@ -7898,169 +7343,105 @@ int spider_mbase_share::discover_table_structure( sql_str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN); SPIDER_CONN *conn; - int need_mon; + int need_mon_deref; + int *need_mon= &need_mon_deref; if (!(conn = spider_get_conn( spider_share, 0, spider_share->conn_keys[roop_count], trx, NULL, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL, &error_num)) ) { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &need_mon; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, need_mon); if (!conn->disable_reconnect) { ha_spider tmp_spider; SPIDER_WIDE_HANDLER wide_handler; - int need_mon = 0; - uint tmp_conn_link_idx = 0; - tmp_spider.wide_handler = &wide_handler; - wide_handler.trx = trx; - tmp_spider.share = spider_share; - tmp_spider.need_mons = &need_mon; - tmp_spider.conn_link_idx = &tmp_conn_link_idx; - if ((error_num = spider_db_ping(&tmp_spider, conn, 0))) + int need_mon= 0; + uint tmp_conn_link_idx= 0; + tmp_spider.wide_handler= &wide_handler; + wide_handler.trx= trx; + tmp_spider.share= spider_share; + tmp_spider.need_mons= &need_mon; + tmp_spider.conn_link_idx= &tmp_conn_link_idx; + if ((error_num= spider_db_ping(&tmp_spider, conn, 0))) { - DBUG_PRINT("info",("spider spider_db_ping error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } } spider_conn_set_timeout_from_share(conn, roop_count, trx->thd, - spider_share); - if ( - (error_num = spider_db_set_names_internal(trx, spider_share, conn, - roop_count, &need_mon)) || - ( - spider_db_query( - conn, - sql_str.ptr(), - sql_str.length(), - -1, - &need_mon) && - (error_num = spider_db_errorno(conn)) - ) - ) { - DBUG_PRINT("info",("spider spider_get_trx error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_share); + if ((error_num= spider_db_set_names_internal(trx, spider_share, conn, + roop_count, need_mon)) || + (spider_db_query(conn, sql_str.ptr(), sql_str.length(), -1, + need_mon) && + (error_num= spider_db_errorno(conn)))) + { + spider_unlock_after_query(conn, 0); continue; } st_spider_db_request_key request_key; - request_key.spider_thread_id = trx->spider_thread_id; - request_key.query_id = trx->thd->query_id; - request_key.handler = NULL; - request_key.request_id = 1; - request_key.next = NULL; - spider_db_result *res; + request_key.spider_thread_id= trx->spider_thread_id; + request_key.query_id= trx->thd->query_id; request_key.handler= NULL; + request_key.request_id= 1; request_key.next= NULL; + spider_db_result * res; /* get column list */ - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) - { - if (error_num || (error_num = spider_db_errorno(conn))) + if (!(res= conn->db_conn->store_result(NULL, &request_key, + &error_num))) { + if (error_num || (error_num= spider_db_errorno(conn))) { - DBUG_PRINT("info",("spider column store error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } - /* no record */ - DBUG_PRINT("info",("spider column no record error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } - if ((error_num = res->fetch_columns_for_discover_table_structure(str, - spider_share->access_charset))) - { - DBUG_PRINT("info",("spider column fetch error")); + if ((error_num= + res->fetch_columns_for_discover_table_structure( + str, spider_share->access_charset))) { + DBUG_PRINT("info", ("spider column fetch error")); res->free_result(); delete res; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, - ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), - db_names_str[roop_count].ptr(), - table_names_str[roop_count].ptr()); - error_num = ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM; + ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), + db_names_str[roop_count].ptr(), + table_names_str[roop_count].ptr()); + error_num= ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM; + spider_unlock_after_query(conn, 0); continue; } res->free_result(); delete res; if (conn->db_conn->next_result()) { - DBUG_PRINT("info",("spider single result error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } /* get index list */ - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) - { - if (error_num || (error_num = spider_db_errorno(conn))) + if (!(res= conn->db_conn->store_result(NULL, &request_key, + &error_num))) { + if (error_num || (error_num= spider_db_errorno(conn))) { - DBUG_PRINT("info",("spider index store error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } - /* no record */ - DBUG_PRINT("info",("spider index no record error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } - if ((error_num = res->fetch_index_for_discover_table_structure(str, - spider_share->access_charset))) - { - DBUG_PRINT("info",("spider index fetch error")); + if ((error_num= + res->fetch_index_for_discover_table_structure( + str, spider_share->access_charset))) { + DBUG_PRINT("info", ("spider index fetch error")); res->free_result(); delete res; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } res->free_result(); delete res; - if (conn->db_conn->next_result()) - { - DBUG_PRINT("info",("spider dual result error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + if (conn->db_conn->next_result()) { + DBUG_PRINT("info", ("spider dual result error")); + spider_unlock_after_query(conn, 0); continue; } /* get table info */ @@ -8069,44 +7450,30 @@ int spider_mbase_share::discover_table_structure( if (error_num || (error_num = spider_db_errorno(conn))) { DBUG_PRINT("info",("spider table store error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } /* no record */ DBUG_PRINT("info",("spider table no record error")); - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } if ((error_num = res->fetch_table_for_discover_table_structure(str, - spider_share, spider_share->access_charset))) + spider_share, spider_share->access_charset))) { DBUG_PRINT("info",("spider table fetch error")); res->free_result(); delete res; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); continue; } res->free_result(); delete res; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); if (!error_num) + { + spider_unlock_after_query(conn, 0); break; + } } DBUG_RETURN(error_num); } @@ -13401,20 +12768,12 @@ int spider_mbase_handler::show_table_status( SPIDER_CONN *conn = spider->conns[link_idx]; SPIDER_DB_RESULT *res; SPIDER_SHARE *share = spider->share; - uint pos = (2 * spider->conn_link_idx[link_idx]); + uint pos = 2 * spider->conn_link_idx[link_idx] + (sts_mode == 1 ? 0 : 1); ulonglong auto_increment_value = 0; DBUG_ENTER("spider_mbase_handler::show_table_status"); DBUG_PRINT("info",("spider sts_mode=%d", sts_mode)); - if (sts_mode == 1) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); conn->disable_connect_retry = TRUE; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, @@ -13424,8 +12783,8 @@ int spider_mbase_handler::show_table_status( ( spider_db_query( conn, - mysql_share->show_table_status[0 + pos].ptr(), - mysql_share->show_table_status[0 + pos].length(), + mysql_share->show_table_status[pos].ptr(), + mysql_share->show_table_status[pos].length(), -1, &spider->need_mons[link_idx]) && (error_num = spider_db_errorno(conn)) @@ -13438,51 +12797,29 @@ int spider_mbase_handler::show_table_status( /* retry */ if ((error_num = spider_db_ping(spider, conn, link_idx))) { - conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } if ((error_num = spider_db_set_names(spider, conn, link_idx))) { - conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); if (spider_db_query( conn, - mysql_share->show_table_status[0 + pos].ptr(), - mysql_share->show_table_status[0 + pos].length(), + mysql_share->show_table_status[pos].ptr(), + mysql_share->show_table_status[pos].length(), -1, &spider->need_mons[link_idx]) ) { - conn->disable_connect_retry = FALSE; - 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; - DBUG_RETURN(spider_db_errorno(conn)); + goto unlock; } } else { - conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } } + error_num= 0; 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; @@ -13491,43 +12828,27 @@ int spider_mbase_handler::show_table_status( request_key.next = NULL; if (spider_param_dry_access()) { - conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + goto unlock; } if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) { - conn->disable_connect_retry = FALSE; - 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; - if (error_num) - { - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - else if ((error_num = spider_db_errorno(conn))) - DBUG_RETURN(error_num); - else { + if (error_num || (error_num = spider_db_errorno(conn))) + goto unlock; + else if (sts_mode == 1) { my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), mysql_share->table_names_str[spider->conn_link_idx[ link_idx]].ptr()); - DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM); + error_num= ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM; + goto unlock; + } + else /* sts_mode != 1 */ + { + error_num= ER_QUERY_ON_FOREIGN_DATA_SOURCE; + goto unlock; } } - conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_status( sts_mode, share->stat @@ -13556,168 +12877,29 @@ int spider_mbase_handler::show_table_status( default: break; } - DBUG_RETURN(error_num); + goto unlock; } - } else { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - conn->disable_connect_retry = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if ( - (error_num = spider_db_set_names(spider, conn, link_idx)) || - ( - spider_db_query( - conn, - mysql_share->show_table_status[1 + pos].ptr(), - mysql_share->show_table_status[1 + pos].length(), - -1, - &spider->need_mons[link_idx]) && - (error_num = spider_db_errorno(conn)) - ) - ) { - if ( - error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && - !conn->disable_reconnect - ) { - /* retry */ - if ((error_num = spider_db_ping(spider, conn, link_idx))) - { - conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if (spider_db_query( - conn, - mysql_share->show_table_status[1 + pos].ptr(), - mysql_share->show_table_status[1 + pos].length(), - -1, - &spider->need_mons[link_idx]) - ) { - conn->disable_connect_retry = FALSE; - 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; - DBUG_RETURN(spider_db_errorno(conn)); - } - } else { - conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - } - 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 = 1; - request_key.next = NULL; - if (spider_param_dry_access()) + if ((error_num = ((spider_db_mbase *) conn->db_conn)->fetch_and_print_warnings(NULL))) { - conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + goto unlock; } - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + if (share->static_records_for_status != -1) { - conn->disable_connect_retry = FALSE; - 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; - if (error_num || (error_num = spider_db_errorno(conn))) - DBUG_RETURN(error_num); - else - DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + share->stat.records = (ha_rows) share->static_records_for_status; } + if (share->static_mean_rec_length != -1) + { + share->stat.mean_rec_length = (ulong) share->static_mean_rec_length; + } + 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)); + } +unlock: conn->disable_connect_retry = FALSE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - error_num = res->fetch_table_status( - sts_mode, - share->stat - ); - auto_increment_value = share->stat.auto_increment_value; - res->free_result(); - delete res; - if (error_num) - { - switch (error_num) - { - case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM: - my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, - ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), - mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), - mysql_share->table_names_str[spider->conn_link_idx[ - link_idx]].ptr()); - break; - case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM: - my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM, - ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0), - mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), - mysql_share->table_names_str[spider->conn_link_idx[ - link_idx]].ptr()); - break; - default: - break; - } - DBUG_RETURN(error_num); - } - } - if ((error_num = ((spider_db_mbase *) conn->db_conn)->fetch_and_print_warnings(NULL))) - { - DBUG_RETURN(error_num); - } - if (share->static_records_for_status != -1) - { - share->stat.records = (ha_rows) share->static_records_for_status; - } - if (share->static_mean_rec_length != -1) - { - share->stat.mean_rec_length = (ulong) share->static_mean_rec_length; - } - 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); + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::crd_mode_exchange( @@ -13739,18 +12921,10 @@ int spider_mbase_handler::show_index( SPIDER_DB_RESULT *res; int roop_count; longlong *tmp_cardinality; - uint pos = (2 * spider->conn_link_idx[link_idx]); + uint pos = 2 * spider->conn_link_idx[link_idx] + (crd_mode == 1 ? 0 : 1); DBUG_ENTER("spider_mbase_handler::show_index"); DBUG_PRINT("info",("spider crd_mode=%d", crd_mode)); - if (crd_mode == 1) - { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -13759,8 +12933,8 @@ int spider_mbase_handler::show_index( ( spider_db_query( conn, - mysql_share->show_index[0 + pos].ptr(), - mysql_share->show_index[0 + pos].length(), + mysql_share->show_index[pos].ptr(), + mysql_share->show_index[pos].length(), -1, &spider->need_mons[link_idx]) && (error_num = spider_db_errorno(conn)) @@ -13772,48 +12946,27 @@ int spider_mbase_handler::show_index( ) { /* retry */ if ((error_num = spider_db_ping(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); if (spider_db_query( conn, - mysql_share->show_index[0 + pos].ptr(), - mysql_share->show_index[0 + pos].length(), + mysql_share->show_index[pos].ptr(), + mysql_share->show_index[pos].length(), -1, &spider->need_mons[link_idx]) ) { - 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; - DBUG_RETURN(spider_db_errorno(conn)); + error_num= spider_db_errorno(conn); + goto unlock; } } else { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } } + error_num= 0; 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; @@ -13824,20 +12977,10 @@ int spider_mbase_handler::show_index( { 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + goto unlock; } /* no record is ok */ } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); if (res) { error_num = res->fetch_table_cardinality( @@ -13885,154 +13028,10 @@ int spider_mbase_handler::show_index( default: break; } - DBUG_RETURN(error_num); + goto unlock; } - } else { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if ( - (error_num = spider_db_set_names(spider, conn, link_idx)) || - ( - spider_db_query( - conn, - mysql_share->show_index[1 + pos].ptr(), - mysql_share->show_index[1 + pos].length(), - -1, - &spider->need_mons[link_idx]) && - (error_num = spider_db_errorno(conn)) - ) - ) { - if ( - error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && - !conn->disable_reconnect - ) { - /* retry */ - if ((error_num = spider_db_ping(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if (spider_db_query( - conn, - mysql_share->show_index[1 + pos].ptr(), - mysql_share->show_index[1 + pos].length(), - -1, - &spider->need_mons[link_idx]) - ) { - 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; - DBUG_RETURN(spider_db_errorno(conn)); - } - } else { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - } - 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 = 1; - request_key.next = NULL; - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - /* no record is ok */ - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - if (res) - { - error_num = res->fetch_table_cardinality( - crd_mode, - table, - share->cardinality, - share->cardinality_upd, - share->bitmap_size - ); - } - for (roop_count = 0, tmp_cardinality = share->cardinality; - roop_count < (int) table->s->fields; - roop_count++, tmp_cardinality++) - { - if (!spider_bit_is_set(share->cardinality_upd, roop_count)) - { - DBUG_PRINT("info", - ("spider uninitialized column cardinality id=%d", roop_count)); - *tmp_cardinality = -1; - } - } - if (res) - { - res->free_result(); - delete res; - } - if (error_num) - { - switch (error_num) - { - case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM: - my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, - ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0), - mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), - mysql_share->table_names_str[spider->conn_link_idx[ - link_idx]].ptr()); - break; - case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM: - my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM, - ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0), - mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(), - mysql_share->table_names_str[spider->conn_link_idx[ - link_idx]].ptr()); - break; - default: - break; - } - DBUG_RETURN(error_num); - } - } - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::simple_action( @@ -14084,14 +13083,8 @@ int spider_mbase_handler::simple_action( default: DBUG_ASSERT(0); DBUG_RETURN(0); - } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + } + spider_lock_before_query(conn, &spider->need_mons[link_idx]); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14113,25 +13106,9 @@ int spider_mbase_handler::simple_action( ) { /* retry */ if ((error_num = spider_db_ping(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 1", error_num)); - DBUG_RETURN(error_num); - } + goto unlock; if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 2", error_num)); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14142,23 +13119,14 @@ int spider_mbase_handler::simple_action( -1, &spider->need_mons[link_idx]) ) { - 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; - DBUG_PRINT("info", ("spider error_num=%d 3", error_num)); - DBUG_RETURN(spider_db_errorno(conn)); + error_num= spider_db_errorno(conn); + goto unlock; } } else { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 4", error_num)); - DBUG_RETURN(error_num); + goto unlock; } } + error_num= 0; 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; @@ -14167,31 +13135,15 @@ int spider_mbase_handler::simple_action( request_key.next = NULL; if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) { - 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; if (error_num) - { - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_PRINT("info", ("spider error_num=%d 5", error_num)); - DBUG_RETURN(error_num); - } + goto unlock; else if ((error_num = spider_db_errorno(conn))) - { - DBUG_PRINT("info", ("spider error_num=%d 6", error_num)); - DBUG_RETURN(error_num); - } else { - DBUG_PRINT("info", ("spider error_num=%d 7", - ER_QUERY_ON_FOREIGN_DATA_SOURCE)); - DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); + goto unlock; + else { + error_num= ER_QUERY_ON_FOREIGN_DATA_SOURCE; + goto unlock; } } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); switch (simple_action) { case SPIDER_SIMPLE_RECORDS: @@ -14208,12 +13160,8 @@ int spider_mbase_handler::simple_action( } res->free_result(); delete res; - if (error_num) - { - DBUG_PRINT("info", ("spider error_num=%d 7", error_num)); - DBUG_RETURN(error_num); - } - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::show_records( @@ -14268,13 +13216,7 @@ ha_rows spider_mbase_handler::explain_select( DBUG_RETURN(HA_POS_ERROR); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, spider->share); @@ -14299,23 +13241,15 @@ ha_rows spider_mbase_handler::explain_select( { if (spider->check_error_mode(error_num)) my_errno = error_num; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } if ((error_num = spider_db_set_names(spider, conn, link_idx))) { if (spider->check_error_mode(error_num)) my_errno = error_num; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, @@ -14330,22 +13264,14 @@ ha_rows spider_mbase_handler::explain_select( error_num = spider_db_errorno(conn); if (spider->check_error_mode(error_num)) my_errno = error_num; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } } else { if (spider->check_error_mode(error_num)) my_errno = error_num; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } } st_spider_db_request_key request_key; @@ -14360,27 +13286,13 @@ ha_rows spider_mbase_handler::explain_select( { if (spider->check_error_mode(error_num)) my_errno = error_num; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } else { - my_errno = ER_QUERY_ON_FOREIGN_DATA_SOURCE; - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; + goto unlock; } } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); error_num = res->fetch_table_records( 2, rows @@ -14390,8 +13302,10 @@ ha_rows spider_mbase_handler::explain_select( if (error_num) { my_errno = error_num; - DBUG_RETURN(HA_POS_ERROR); + rows= HA_POS_ERROR; } +unlock: + spider_unlock_after_query(conn, 0); DBUG_RETURN(rows); } @@ -14409,22 +13323,9 @@ int spider_mbase_handler::lock_tables( } if (str->length()) { - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, spider->share); @@ -14434,18 +13335,9 @@ int spider_mbase_handler::lock_tables( str->length(), -1, &spider->need_mons[link_idx]) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + ) + DBUG_RETURN(spider_unlock_after_query_1(conn)); + spider_unlock_after_query(conn, 0); } if (!conn->table_locked) { @@ -14477,31 +13369,9 @@ int spider_mbase_handler::unlock_tables( spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, spider->share); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - str->ptr(), - str->length(), - -1, - &spider->need_mons[link_idx]) - ) { - 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; - DBUG_RETURN(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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + DBUG_RETURN(spider_db_query_with_lock( + conn, str->ptr(), str->length(), + &spider->need_mons[link_idx])); } } DBUG_RETURN(0); @@ -14521,22 +13391,9 @@ int spider_mbase_handler::disable_keys( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14546,20 +13403,10 @@ int spider_mbase_handler::disable_keys( str->length(), -1, &spider->need_mons[link_idx]) - ) { - 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; + ) error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::enable_keys( @@ -14576,22 +13423,9 @@ int spider_mbase_handler::enable_keys( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14601,20 +13435,10 @@ int spider_mbase_handler::enable_keys( str->length(), -1, &spider->need_mons[link_idx]) - ) { - 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; + ) error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::check_table( @@ -14632,22 +13456,9 @@ int spider_mbase_handler::check_table( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14658,19 +13469,10 @@ int spider_mbase_handler::check_table( -1, &spider->need_mons[link_idx]) ) { - 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; error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::repair_table( @@ -14688,22 +13490,9 @@ int spider_mbase_handler::repair_table( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14714,19 +13503,10 @@ int spider_mbase_handler::repair_table( -1, &spider->need_mons[link_idx]) ) { - 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; error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::analyze_table( @@ -14743,45 +13523,18 @@ int spider_mbase_handler::analyze_table( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, link_idx, - spider->wide_handler->trx->thd, - share); - if (spider_db_query( - conn, - str->ptr(), - str->length(), - -1, - &spider->need_mons[link_idx]) - ) { - 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; - error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + spider_lock_before_query(conn, &spider->need_mons[link_idx]); + error_num = spider_db_set_names(spider, conn, link_idx); + if (!error_num) + { + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, + share); + if (spider_db_query(conn, str->ptr(), str->length(), -1, + &spider->need_mons[link_idx])) + error_num = spider_db_errorno(conn); + } + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::optimize_table( @@ -14798,22 +13551,9 @@ int spider_mbase_handler::optimize_table( { DBUG_RETURN(error_num); } - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) - { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } + goto unlock; spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); @@ -14824,19 +13564,10 @@ int spider_mbase_handler::optimize_table( -1, &spider->need_mons[link_idx]) ) { - 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; error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); +unlock: + DBUG_RETURN(spider_unlock_after_query(conn, error_num)); } int spider_mbase_handler::flush_tables( @@ -14857,73 +13588,23 @@ int spider_mbase_handler::flush_tables( spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - str->ptr(), - str->length(), - -1, - &spider->need_mons[link_idx]) - ) { - 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; - error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, str->ptr(), str->length(), &spider->need_mons[link_idx])); } int spider_mbase_handler::flush_logs( SPIDER_CONN *conn, int link_idx ) { - int error_num; SPIDER_SHARE *share = spider->share; DBUG_ENTER("spider_mbase_handler::flush_logs"); DBUG_PRINT("info",("spider this=%p", this)); spider_conn_set_timeout_from_share(conn, link_idx, spider->wide_handler->trx->thd, share); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - if (spider_db_query( - conn, - SPIDER_SQL_FLUSH_LOGS_STR, - SPIDER_SQL_FLUSH_LOGS_LEN, - -1, - &spider->need_mons[link_idx]) - ) { - 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; - error_num = spider_db_errorno(conn); - DBUG_RETURN(error_num); - } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); + DBUG_RETURN(spider_db_query_with_lock( + conn, SPIDER_SQL_FLUSH_LOGS_STR, + SPIDER_SQL_FLUSH_LOGS_LEN, &spider->need_mons[link_idx])); } int spider_mbase_handler::insert_opened_handler( diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index fa9f041c83b..481291ec6f0 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1191,25 +1191,15 @@ static int spider_send_query( } } else { #endif - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_SELECT_SQL, link_idx, link_idx_chain))) DBUG_RETURN(error_num); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &spider->need_mons[link_idx]; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &spider->need_mons[link_idx]); if ((error_num = spider_db_set_names(spider, conn, link_idx))) if ((error_num = spider_db_set_names(spider, conn, link_idx))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (spider->need_mons[link_idx]) error_num = fields->ping_table_mon_from_table(link_idx_chain); if ((error_num = spider->check_error_mode_eof(error_num)) == @@ -1227,11 +1217,7 @@ static int spider_send_query( spider->result_list.quick_mode, &spider->need_mons[link_idx])) { - 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; - error_num = spider_db_errorno(conn); + error_num= spider_unlock_after_query_1(conn); if (spider->need_mons[link_idx]) error_num = fields->ping_table_mon_from_table(link_idx_chain); if ((error_num = spider->check_error_mode_eof(error_num)) == @@ -1243,13 +1229,9 @@ static int spider_send_query( DBUG_RETURN(error_num); } spider->connection_ids[link_idx] = conn->connection_id; - 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; if (fields->is_first_link_ok_chain(link_idx_chain)) { - if ((error_num = spider_db_store_result(spider, link_idx, table))) + if ((error_num = spider_unlock_after_query_2(conn, spider, link_idx, table))) { if (error_num != HA_ERR_END_OF_FILE && spider->need_mons[link_idx]) error_num = fields->ping_table_mon_from_table(link_idx_chain); @@ -1266,7 +1248,7 @@ static int spider_send_query( } else { spider_db_discard_result(spider, link_idx, conn); - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); } #ifndef WITHOUT_SPIDER_BG_SEARCH } diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index dc30278e66c..d41a957d436 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -5725,20 +5725,10 @@ int spider_open_all_tables( } conn->error_mode &= spider_param_error_read_mode(thd, 0); conn->error_mode &= spider_param_error_write_mode(thd, 0); - pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); - pthread_mutex_lock(&conn->mta_conn_mutex); - conn->need_mon = &mon_val; - DBUG_ASSERT(!conn->mta_conn_mutex_lock_already); - DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; + spider_lock_before_query(conn, &mon_val); if ((error_num = spider_db_before_query(conn, &mon_val))) { - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); spider_sys_index_end(table_tables); spider_close_sys_table(thd, table_tables, &open_tables_backup, TRUE); @@ -5747,11 +5737,7 @@ int spider_open_all_tables( free_root(&mem_root, MYF(0)); DBUG_RETURN(error_num); } - 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; - pthread_mutex_unlock(&conn->mta_conn_mutex); + spider_unlock_after_query(conn, 0); if (lock && spider_param_use_snapshot_with_flush_tables(thd) == 2) { From 0ba97e4dc6209bfc109b33522719270543f0658d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 11:29:57 +0800 Subject: [PATCH 5/9] MDEV-31788 Factor out calls to spider_ping_table_mon_from_table in ha_spider.cc --- storage/spider/ha_spider.cc | 1365 ++++------------------------------- 1 file changed, 140 insertions(+), 1225 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 2a49af4ee3b..140a5873034 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1387,6 +1387,58 @@ int ha_spider::index_end() DBUG_RETURN(0); } +static int spider_maybe_ping(ha_spider *spider, int link_idx, int error_num) +{ + if ( + spider->share->monitoring_kind[link_idx] && + spider->need_mons[link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + spider->wide_handler->trx, + spider->wide_handler->trx->thd, + spider->share, + link_idx, + (uint32) spider->share->monitoring_sid[link_idx], + spider->share->table_name, + spider->share->table_name_length, + spider->conn_link_idx[link_idx], + NULL, + 0, + spider->share->monitoring_kind[link_idx], + spider->share->monitoring_limit[link_idx], + spider->share->monitoring_flag[link_idx], + TRUE + ); + } + return spider->check_error_mode_eof(error_num); +} + +static int spider_maybe_ping_1(ha_spider *spider, + int link_idx, int error_num) +{ + if ( + spider->share->monitoring_kind[link_idx] && + spider->need_mons[link_idx] + ) { + error_num = spider_ping_table_mon_from_table( + spider->wide_handler->trx, + spider->wide_handler->trx->thd, + spider->share, + link_idx, + (uint32) spider->share->monitoring_sid[link_idx], + spider->share->table_name, + spider->share->table_name_length, + spider->conn_link_idx[link_idx], + NULL, + 0, + spider->share->monitoring_kind[link_idx], + spider->share->monitoring_limit[link_idx], + spider->share->monitoring_flag[link_idx], + TRUE + ); + } + return error_num; +} int ha_spider::index_read_map_internal( uchar *buf, @@ -1552,26 +1604,9 @@ int ha_spider::index_read_map_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -1596,28 +1631,7 @@ int ha_spider::index_read_map_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -1628,28 +1642,7 @@ int ha_spider::index_read_map_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -1657,26 +1650,9 @@ int ha_spider::index_read_map_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -1894,26 +1870,9 @@ int ha_spider::index_read_last_map_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -1938,28 +1897,7 @@ int ha_spider::index_read_last_map_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -1970,28 +1908,7 @@ int ha_spider::index_read_last_map_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -1999,26 +1916,9 @@ int ha_spider::index_read_last_map_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -2285,26 +2185,9 @@ int ha_spider::index_first_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -2330,28 +2213,7 @@ int ha_spider::index_first_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -2362,28 +2224,7 @@ int ha_spider::index_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -2391,26 +2232,9 @@ int ha_spider::index_first_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -2624,26 +2448,9 @@ int ha_spider::index_last_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -2669,28 +2476,7 @@ int ha_spider::index_last_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -2701,28 +2487,7 @@ int ha_spider::index_last_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -2730,26 +2495,9 @@ int ha_spider::index_last_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -3006,26 +2754,9 @@ int ha_spider::read_range_first_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -3050,28 +2781,7 @@ int ha_spider::read_range_first_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -3082,28 +2792,7 @@ int ha_spider::read_range_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -3111,26 +2800,9 @@ int ha_spider::read_range_first_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -3587,26 +3259,9 @@ int ha_spider::read_multi_range_first_internal( TRUE, FALSE, (roop_count != link_ok)); if ( error_num && - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } } else { #endif @@ -3630,27 +3285,7 @@ int ha_spider::read_multi_range_first_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); } if (!error_num) { @@ -3663,27 +3298,7 @@ int ha_spider::read_multi_range_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); } } if (!error_num) @@ -3694,26 +3309,9 @@ int ha_spider::read_multi_range_first_internal( error_num = spider_unlock_after_query_2(conn, this, roop_count, table); if ( error_num && - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } result_link_idx = link_ok; } else { @@ -4322,26 +3920,9 @@ int ha_spider::read_multi_range_first_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } break; } @@ -4368,27 +3949,7 @@ int ha_spider::read_multi_range_first_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } if ( @@ -4407,27 +3968,7 @@ int ha_spider::read_multi_range_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } spider_db_discard_multiple_result(this, roop_count, conn); @@ -4441,27 +3982,7 @@ int ha_spider::read_multi_range_first_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } connection_ids[roop_count] = conn->connection_id; @@ -4470,26 +3991,9 @@ int ha_spider::read_multi_range_first_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } break; } @@ -4916,26 +4420,9 @@ int ha_spider::read_multi_range_next( TRUE, FALSE, (roop_count != link_ok)); if ( error_num && - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } } else { #endif @@ -4959,27 +4446,7 @@ int ha_spider::read_multi_range_next( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); } if (!error_num) { @@ -4992,27 +4459,7 @@ int ha_spider::read_multi_range_next( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); } } if (!error_num) @@ -5023,26 +4470,9 @@ int ha_spider::read_multi_range_next( error_num = spider_unlock_after_query_2(conn, this, roop_count, table); if ( error_num && - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } result_link_idx = link_ok; } else { @@ -5650,26 +5080,9 @@ int ha_spider::read_multi_range_next( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } break; } @@ -5696,27 +5109,7 @@ int ha_spider::read_multi_range_next( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } if ( @@ -5735,27 +5128,7 @@ int ha_spider::read_multi_range_next( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } spider_db_discard_multiple_result(this, roop_count, conn); @@ -5769,27 +5142,7 @@ int ha_spider::read_multi_range_next( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, roop_count, error_num); break; } connection_ids[roop_count] = conn->connection_id; @@ -5798,26 +5151,9 @@ int ha_spider::read_multi_range_next( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); + error_num= spider_maybe_ping_1(this, search_link_idx, error_num); } break; } @@ -6247,26 +5583,9 @@ int ha_spider::rnd_next_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -6292,28 +5611,7 @@ int ha_spider::rnd_next_internal( roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -6324,28 +5622,7 @@ int ha_spider::rnd_next_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -6353,26 +5630,9 @@ int ha_spider::rnd_next_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -6850,26 +6110,9 @@ int ha_spider::ft_read_internal( TRUE, FALSE, (roop_count != link_ok)))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -6887,28 +6130,7 @@ int ha_spider::ft_read_internal( if ((error_num = spider_db_set_names(this, conn, roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -6919,28 +6141,7 @@ int ha_spider::ft_read_internal( &need_mons[roop_count]) ) { error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode_eof(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } connection_ids[roop_count] = conn->connection_id; if (roop_count == link_ok) @@ -6948,26 +6149,9 @@ int ha_spider::ft_read_internal( if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) { if ( - error_num != HA_ERR_END_OF_FILE && - share->monitoring_kind[roop_count] && - need_mons[roop_count] + error_num != HA_ERR_END_OF_FILE ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(spider_maybe_ping(this, roop_count, error_num)); } DBUG_RETURN(check_error_mode_eof(error_num)); } @@ -7201,27 +6385,7 @@ int ha_spider::info( flag | (share->sts_init ? 0 : HA_STATUS_AUTO))) ) { pthread_mutex_unlock(&share->sts_mutex); - if ( - share->monitoring_kind[search_link_idx] && - need_mons[search_link_idx] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - search_link_idx, - (uint32) share->monitoring_sid[search_link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[search_link_idx], - NULL, - 0, - share->monitoring_kind[search_link_idx], - share->monitoring_limit[search_link_idx], - share->monitoring_flag[search_link_idx], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, search_link_idx, error_num); if (!share->sts_init) { if ( @@ -7488,27 +6652,7 @@ ha_rows ha_spider::records_in_range( share->crd_init ? 2 : 1))) { pthread_mutex_unlock(&share->crd_mutex); - if ( - share->monitoring_kind[search_link_idx] && - need_mons[search_link_idx] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - search_link_idx, - (uint32) share->monitoring_sid[search_link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[search_link_idx], - NULL, - 0, - share->monitoring_kind[search_link_idx], - share->monitoring_limit[search_link_idx], - share->monitoring_flag[search_link_idx], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, search_link_idx, error_num); if (!share->crd_init) { if ( @@ -7796,27 +6940,7 @@ int ha_spider::check_crd() share->crd_init ? 2 : 1))) { pthread_mutex_unlock(&share->crd_mutex); - if ( - share->monitoring_kind[search_link_idx] && - need_mons[search_link_idx] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - search_link_idx, - (uint32) share->monitoring_sid[search_link_idx], - share->table_name, - share->table_name_length, - conn_link_idx[search_link_idx], - NULL, - 0, - share->monitoring_kind[search_link_idx], - share->monitoring_limit[search_link_idx], - share->monitoring_flag[search_link_idx], - TRUE - ); - } + error_num= spider_maybe_ping_1(this, search_link_idx, error_num); if (!share->crd_init) { if ( @@ -10688,7 +9812,7 @@ int ha_spider::check_ha_range_eof() int ha_spider::drop_tmp_tables() { - int error_num = 0, tmp_error_num, need_mon; + int error_num = 0, need_mon; DBUG_ENTER("ha_spider::drop_tmp_tables"); DBUG_PRINT("info",("spider this=%p", this)); if (result_list.tmp_tables_created) @@ -10723,33 +9847,13 @@ int ha_spider::drop_tmp_tables() DBUG_RETURN(error_num); } spider_lock_before_query(conn, &need_mon); - if ((tmp_error_num = spider_db_set_names(this, conn, roop_count))) + /* todo: double check the logic here w.r.t. tmp_error_num vs error_num */ + if ((error_num = spider_db_set_names(this, conn, roop_count))) { spider_unlock_after_query(conn, 0); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - tmp_error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - error_num = tmp_error_num; + error_num= spider_maybe_ping_1(this, roop_count, error_num); } - if (!tmp_error_num) + if (!error_num) { spider_conn_set_timeout_from_share(conn, roop_count, wide_handler->trx->thd, share); @@ -10759,29 +9863,8 @@ int ha_spider::drop_tmp_tables() -1, &need_mons[roop_count]) ) { - tmp_error_num= spider_unlock_after_query_1(conn); - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - tmp_error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - error_num = tmp_error_num; + error_num= spider_unlock_after_query_1(conn); + error_num= spider_maybe_ping_1(this, roop_count, error_num); } else { spider_unlock_after_query(conn, 0); } @@ -10835,37 +9918,16 @@ int ha_spider::close_opened_handler( int link_idx, bool release_conn ) { - int error_num = 0, error_num2; + int error_num = 0; DBUG_ENTER("ha_spider::close_opened_handler"); DBUG_PRINT("info",("spider this=%p", this)); if (spider_bit_is_set(m_handler_opened, link_idx)) { - if ((error_num2 = spider_db_close_handler(this, + if ((error_num = spider_db_close_handler(this, conns[link_idx], link_idx, SPIDER_CONN_KIND_MYSQL)) ) { - 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; + error_num= spider_maybe_ping_1(this, link_idx, error_num); } spider_clear_bit(m_handler_opened, link_idx); if (release_conn && !conns[link_idx]->join_trx) @@ -10914,28 +9976,7 @@ int ha_spider::index_handler_init() conns[roop_count] , roop_count)) ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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); + DBUG_RETURN(spider_maybe_ping_1(this, roop_count, error_num)); } set_handler_opened(roop_count); } @@ -11000,28 +10041,7 @@ int ha_spider::rnd_handler_init() conns[roop_count] , roop_count)) ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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); + DBUG_RETURN(spider_maybe_ping_1(this, roop_count, error_num)); } set_handler_opened(roop_count); spider_db_handler *dbton_hdl= @@ -13185,28 +12205,7 @@ int ha_spider::lock_tables() conns[roop_count], roop_count))) ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } reset_first_link_idx(); } @@ -13216,29 +12215,8 @@ int ha_spider::lock_tables() conns[roop_count]->db_conn->have_lock_table_list() && (error_num = spider_db_lock_tables(this, roop_count)) ) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } conns[roop_count]->table_lock = 0; - DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } if (conns[roop_count]->table_lock == 2) conns[roop_count]->table_lock = 1; @@ -13252,28 +12230,7 @@ int ha_spider::lock_tables() conns[roop_count]->disable_reconnect = FALSE; if ((error_num = spider_db_unlock_tables(this, roop_count))) { - if ( - share->monitoring_kind[roop_count] && - need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - wide_handler->trx, - wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - 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(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } } } @@ -13323,28 +12280,7 @@ int ha_spider::dml_init() conns[roop_count], roop_count))) ) { - if ( - share->monitoring_kind[roop_count] && - 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, - 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(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } reset_first_link_idx(); if ( @@ -13361,28 +12297,7 @@ int ha_spider::dml_init() if ((error_num = spider_check_and_set_trx_isolation( conns[roop_count], &need_mons[roop_count]))) { - if ( - share->monitoring_kind[roop_count] && - 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, - 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(check_error_mode(error_num)); + DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); } } conns[roop_count]->semi_trx_isolation = -1; From cc0faa1e3ea140135097bfc298d5a8b9d833dd9e Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 19 Jun 2024 12:05:09 +0800 Subject: [PATCH 6/9] MDEV-31788 Factor functions to reduce duplication around spider_check_and_init_casual_read in ha_spider.cc factored out static functions: - spider_prep_loop - spider_start_bg - spider_send_queries --- storage/spider/ha_spider.cc | 798 ++++++++---------------------------- 1 file changed, 160 insertions(+), 638 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 140a5873034..1eb0dc6e53f 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1440,15 +1440,117 @@ static int spider_maybe_ping_1(ha_spider *spider, return error_num; } +static void spider_prep_loop(ha_spider *spider, int *roop_start, int *roop_end, int *link_ok) +{ + int lock_mode = spider_conn_lock_mode(spider); + if (lock_mode) + { + /* "for update" or "lock in share mode" */ + *link_ok = spider_conn_link_idx_next(spider->share->link_statuses, + spider->conn_link_idx, -1, spider->share->link_count, + SPIDER_LINK_STATUS_OK); + *roop_start = spider_conn_link_idx_next(spider->share->link_statuses, + spider->conn_link_idx, -1, spider->share->link_count, + SPIDER_LINK_STATUS_RECOVERY); + *roop_end = spider->share->link_count; + } else { + *link_ok = spider->search_link_idx; + *roop_start = spider->search_link_idx; + *roop_end = spider->search_link_idx + 1; + } +} + +#ifndef WITHOUT_SPIDER_BG_SEARCH +/* Returns true if the caller should return *error_num */ +static bool spider_start_bg(ha_spider* spider, int roop_count, int roop_start, int link_ok, int *error_num) +{ + if ((*error_num = spider_check_and_init_casual_read( + spider->wide_handler->trx->thd, spider, + roop_count))) + return true; + if ((*error_num = spider_bg_conn_search(spider, roop_count, roop_start, + TRUE, FALSE, (roop_count != link_ok)))) + { + if ( + *error_num != HA_ERR_END_OF_FILE + ) { + *error_num= spider_maybe_ping(spider, roop_count, *error_num); + return true; + } + *error_num= spider->check_error_mode_eof(*error_num); + return true; + } + return false; +} +#endif + +/* Updates error_num. Returning true if the caller should return. */ +static bool spider_send_query(ha_spider *spider, TABLE *table, int link_idx, int link_ok, int *error_num) +{ + ulong sql_type; + SPIDER_CONN *conn = spider->conns[link_idx]; + if (spider->sql_kind[link_idx] == SPIDER_SQL_KIND_SQL) + { + sql_type = SPIDER_SQL_TYPE_SELECT_SQL; + } else { + sql_type = SPIDER_SQL_TYPE_HANDLER; + } + spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; + if ((*error_num = dbton_hdl->set_sql_for_exec(sql_type, link_idx))) + { + return true; + } + DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); + spider_lock_before_query(conn, &spider->need_mons[link_idx]); + if ((*error_num = spider_db_set_names(spider, conn, + link_idx))) + { + spider_unlock_after_query(conn, 0); + *error_num= spider_maybe_ping(spider, link_idx, *error_num); + return true; + } + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, spider->share); + if (dbton_hdl->execute_sql( + sql_type, + conn, + spider->result_list.quick_mode, + &spider->need_mons[link_idx]) + ) { + *error_num= spider_unlock_after_query_1(conn); + *error_num= (spider_maybe_ping(spider, link_idx, *error_num)); + return true; + } + spider->connection_ids[link_idx] = conn->connection_id; + if (link_idx == link_ok) + { + if ((*error_num = spider_unlock_after_query_2(conn, spider, link_idx, table))) + { + if ( + *error_num != HA_ERR_END_OF_FILE + ) { + *error_num= spider_maybe_ping(spider, link_idx, *error_num); + return true; + } + *error_num= spider->check_error_mode_eof(*error_num); + return true; + } + spider->result_link_idx = link_ok; + } else { + spider_db_discard_result(spider, link_idx, conn); + spider_unlock_after_query(conn, 0); + } + return false; +} + int ha_spider::index_read_map_internal( uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag ) { - int error_num, roop_count; + int error_num; key_range start_key; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::index_read_map_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -1570,24 +1672,8 @@ int ha_spider::index_read_map_internal( } } - /* Query execution */ - int roop_start, roop_end, lock_mode, link_ok; - lock_mode = spider_conn_lock_mode(this); - if (lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -1596,71 +1682,12 @@ int ha_spider::index_read_map_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -1726,7 +1753,6 @@ int ha_spider::index_read_last_map_internal( ) { int error_num; key_range start_key; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::index_read_last_map_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -1837,23 +1863,8 @@ int ha_spider::index_read_last_map_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -1862,71 +1873,12 @@ int ha_spider::index_read_last_map_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -2043,7 +1995,6 @@ int ha_spider::index_first_internal( uchar *buf ) { int error_num; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::index_first_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -2152,97 +2103,22 @@ int ha_spider::index_first_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { #ifndef WITHOUT_SPIDER_BG_SEARCH - if (result_list.bgs_phase > 0) - { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) - DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - } else { + if (result_list.bgs_phase > 0) + { + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) + DBUG_RETURN(error_num); + } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = - dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { - DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) + DBUG_RETURN(error_num); #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -2306,7 +2182,6 @@ int ha_spider::index_last_internal( uchar *buf ) { int error_num; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::index_last_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -2415,97 +2290,22 @@ int ha_spider::index_last_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { #ifndef WITHOUT_SPIDER_BG_SEARCH - if (result_list.bgs_phase > 0) - { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) - DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - } else { + if (result_list.bgs_phase > 0) + { + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) + DBUG_RETURN(error_num); + } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = - dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { - DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) + DBUG_RETURN(error_num); #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -2606,7 +2406,6 @@ int ha_spider::read_range_first_internal( bool sorted ) { int error_num; - SPIDER_CONN *conn; backup_error_status(); DBUG_ENTER("ha_spider::read_range_first_internal"); DBUG_PRINT("info",("spider this=%p", this)); @@ -2721,23 +2520,8 @@ int ha_spider::read_range_first_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -2746,71 +2530,12 @@ int ha_spider::read_range_first_internal( #ifndef WITHOUT_SPIDER_BG_SEARCH if (result_list.bgs_phase > 0) { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } } else { #endif - ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -3226,23 +2951,8 @@ int ha_spider::read_multi_range_first_internal( } } - int roop_start, roop_end, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -3886,24 +3596,8 @@ int ha_spider::read_multi_range_first_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } - + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -4387,23 +4081,8 @@ int ha_spider::read_multi_range_next( } } - int roop_start, roop_end, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -5047,23 +4726,8 @@ int ha_spider::read_multi_range_next( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, @@ -5550,97 +5214,22 @@ int ha_spider::rnd_next_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { #ifndef WITHOUT_SPIDER_BG_SEARCH - if (result_list.bgs_phase > 0) - { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) - DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - } else { + if (result_list.bgs_phase > 0) + { + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) + DBUG_RETURN(error_num); + } else { #endif - SPIDER_CONN *conn = conns[roop_count]; - ulong sql_type; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } - spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; - if ((error_num = - dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { - DBUG_RETURN(error_num); - } - DBUG_PRINT("info",("spider sql_type=%lu", sql_type)); - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, - roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) + DBUG_RETURN(error_num); #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif @@ -6077,89 +5666,22 @@ int ha_spider::ft_read_internal( } } - int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; - tmp_lock_mode = spider_conn_lock_mode(this); - if (tmp_lock_mode) - { - /* "for update" or "lock in share mode" */ - link_ok = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_OK); - roop_start = spider_conn_link_idx_next(share->link_statuses, - conn_link_idx, -1, share->link_count, - SPIDER_LINK_STATUS_RECOVERY); - roop_end = share->link_count; - } else { - link_ok = search_link_idx; - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } + int roop_start, roop_end, roop_count, link_ok; + spider_prep_loop(this, &roop_start, &roop_end, &link_ok); for (roop_count = roop_start; roop_count < roop_end; roop_count = spider_conn_link_idx_next(share->link_statuses, conn_link_idx, roop_count, share->link_count, SPIDER_LINK_STATUS_RECOVERY) ) { #ifndef WITHOUT_SPIDER_BG_SEARCH - if (result_list.bgs_phase > 0) - { - if ((error_num = spider_check_and_init_casual_read( - wide_handler->trx->thd, this, - roop_count))) - DBUG_RETURN(error_num); - if ((error_num = spider_bg_conn_search(this, roop_count, roop_start, - TRUE, FALSE, (roop_count != link_ok)))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - } else { + if (result_list.bgs_phase > 0) + { + if (spider_start_bg(this, roop_count, roop_start, link_ok, &error_num)) + DBUG_RETURN(error_num); + } else { #endif - uint dbton_id = share->sql_dbton_ids[roop_count]; - spider_db_handler *dbton_hdl = dbton_handler[dbton_id]; - SPIDER_CONN *conn = conns[roop_count]; - if ((error_num = dbton_hdl->set_sql_for_exec( - SPIDER_SQL_TYPE_SELECT_SQL, roop_count))) - { - DBUG_RETURN(error_num); - } - spider_lock_before_query(conn, &need_mons[roop_count]); - if ((error_num = spider_db_set_names(this, conn, roop_count))) - { - spider_unlock_after_query(conn, 0); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - spider_conn_set_timeout_from_share(conn, roop_count, - wide_handler->trx->thd, share); - if (dbton_hdl->execute_sql( - SPIDER_SQL_TYPE_SELECT_SQL, - conn, - result_list.quick_mode, - &need_mons[roop_count]) - ) { - error_num= spider_unlock_after_query_1(conn); - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - connection_ids[roop_count] = conn->connection_id; - if (roop_count == link_ok) - { - if ((error_num = spider_unlock_after_query_2(conn, this, roop_count, table))) - { - if ( - error_num != HA_ERR_END_OF_FILE - ) { - DBUG_RETURN(spider_maybe_ping(this, roop_count, error_num)); - } - DBUG_RETURN(check_error_mode_eof(error_num)); - } - result_link_idx = link_ok; - } else { - spider_db_discard_result(this, roop_count, conn); - spider_unlock_after_query(conn, 0); - } + if (spider_send_query(this, table, roop_count, link_ok, &error_num)) + DBUG_RETURN(error_num); #ifndef WITHOUT_SPIDER_BG_SEARCH } #endif From c6eadc40877f4b5d2d164a87db5b8b372926ea8d Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 11 Sep 2024 14:07:32 +0300 Subject: [PATCH 7/9] Fix main.order_by_join_limit on x86-debian-12: Mask the cost numbers. --- .../include/optimizer_trace_no_costs.inc | 11 ++++++++++ mysql-test/main/order_by_limit_join.result | 20 +++++++++---------- mysql-test/main/order_by_limit_join.test | 6 ++++++ 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 mysql-test/include/optimizer_trace_no_costs.inc diff --git a/mysql-test/include/optimizer_trace_no_costs.inc b/mysql-test/include/optimizer_trace_no_costs.inc new file mode 100644 index 00000000000..540ce06e685 --- /dev/null +++ b/mysql-test/include/optimizer_trace_no_costs.inc @@ -0,0 +1,11 @@ +# Mask the cost value from any field that looks like +# "xxx_cost" : double_number +# Print the +# "xxx_cost" : "REPLACED" +# instead +--replace_regex /(_cost": )[0-9.e-]+/\1"REPLACED"/ +#--replace_regex /(_cost": )[0-9.e-]+/"REPLACED"/ +#--replace_regex /[0-9]+/BBB/ + +#--replace_regex /("r_engine_stats":) {[^}]*}/\1 REPLACED/ + diff --git a/mysql-test/main/order_by_limit_join.result b/mysql-test/main/order_by_limit_join.result index 3f48aa3f65f..2b9fb6b97da 100644 --- a/mysql-test/main/order_by_limit_join.result +++ b/mysql-test/main/order_by_limit_join.result @@ -108,9 +108,9 @@ JS } ], "can_skip_filesort": true, - "full_join_cost": 46064.98442, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 97.28224614, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 972.8224614, "use_shortcut_cost": true } @@ -160,9 +160,9 @@ JS "test_if_skip_sort_order_early": [], "can_skip_filesort": false, - "full_join_cost": 46064.98442, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 2097.281246, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 20972.81246, "use_shortcut_cost": true } @@ -244,9 +244,9 @@ JS } ], "can_skip_filesort": false, - "full_join_cost": 46064.98442, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 24059.12698, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 240591.2698, "use_shortcut_cost": false } @@ -363,9 +363,9 @@ JS } ], "can_skip_filesort": true, - "full_join_cost": 47079.71684, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 98.29697856, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 982.9697856, "use_shortcut_cost": true } @@ -448,9 +448,9 @@ JS } ], "can_skip_filesort": true, - "full_join_cost": 46064.98442, + "full_join_cost": "REPLACED", "risk_ratio": 10, - "shortcut_join_cost": 97.28224614, + "shortcut_join_cost": "REPLACED", "shortcut_cost_with_risk": 972.8224614, "use_shortcut_cost": true } diff --git a/mysql-test/main/order_by_limit_join.test b/mysql-test/main/order_by_limit_join.test index da05cdc30c3..3b60581871c 100644 --- a/mysql-test/main/order_by_limit_join.test +++ b/mysql-test/main/order_by_limit_join.test @@ -68,6 +68,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -95,6 +96,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -121,6 +123,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -140,6 +143,7 @@ limit 10; set @trace=(select trace from information_schema.optimizer_trace); --echo # This will show nothing as limit shortcut code figures that --echo # it's not possible to use t1 to construct shortcuts: +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -169,6 +173,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; --echo # @@ -197,6 +202,7 @@ set optimizer_join_limit_pref_ratio=10; eval $query; set @trace=(select trace from information_schema.optimizer_trace); +--source include/optimizer_trace_no_costs.inc select json_detailed(json_extract(@trace, '$**.join_limit_shortcut_choice')) as JS; From 3ae4ecbfc5744625cba57a52d6ecc8d9af1f63b2 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 10 Sep 2024 15:52:13 +0300 Subject: [PATCH 8/9] MDEV-34867 engine S3 cause 500 error for huawei buckets Add support for removing the Content-Type header to the S3 engine. This is required for compatibility with some S3 providers. This also adds a provider option to the S3 engine which will turn on relevant compatibility options for specific providers. This was required for getting MariaDB S3 engine to work with "Huawei Cloud S3". To get Huawei S3 storage to work on has set one of the following S3 options: s3_provider=Huawei s3_ssl_no_verify=1 Author: Andrew Hutchings --- mysql-test/suite/s3/basic.result | 3 +++ mysql-test/suite/s3/my.cnf | 2 ++ mysql-test/suite/s3/slave.cnf | 2 ++ mysql-test/suite/s3/suite.pm | 13 +++++++++++++ storage/maria/aria_s3_copy.cc | 32 ++++++++++++++++++++++++++++++++ storage/maria/ha_s3.cc | 23 ++++++++++++++++++++++- storage/maria/libmarias3 | 2 +- storage/maria/s3_func.c | 23 +++++++++++++++++++++++ storage/maria/s3_func.h | 5 +++++ 9 files changed, 103 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/s3/basic.result b/mysql-test/suite/s3/basic.result index 790806ee43c..47c35d8cfbe 100644 --- a/mysql-test/suite/s3/basic.result +++ b/mysql-test/suite/s3/basic.result @@ -130,16 +130,19 @@ s3_block_size X s3_bucket X s3_debug X s3_host_name X +s3_no_content_type X s3_pagecache_age_threshold X s3_pagecache_buffer_size X s3_pagecache_division_limit X s3_pagecache_file_hash_size X s3_port X s3_protocol_version X +s3_provider X s3_region X s3_replicate_alter_as_create_select X s3_secret_key X s3_slave_ignore_updates X +s3_ssl_no_verify X s3_use_http X show variables like "s3_slave%"; Variable_name Value diff --git a/mysql-test/suite/s3/my.cnf b/mysql-test/suite/s3/my.cnf index f851aa18d6d..4f4049cf89b 100644 --- a/mysql-test/suite/s3/my.cnf +++ b/mysql-test/suite/s3/my.cnf @@ -12,6 +12,8 @@ s3-secret-key=@ENV.S3_SECRET_KEY s3-region=@ENV.S3_REGION s3-port=@ENV.S3_PORT s3-use-http=@ENV.S3_USE_HTTP +s3-ssl-no-verify=@ENV.S3_SSL_NO_VERIFY +s3-provider=@ENV.S3_PROVIDER #s3-host-name=s3.amazonaws.com #s3-protocol-version=Amazon diff --git a/mysql-test/suite/s3/slave.cnf b/mysql-test/suite/s3/slave.cnf index 4f4d3d39ac7..729a48c49eb 100644 --- a/mysql-test/suite/s3/slave.cnf +++ b/mysql-test/suite/s3/slave.cnf @@ -10,6 +10,8 @@ s3-secret-key=@ENV.S3_SECRET_KEY s3-region=@ENV.S3_REGION s3-port=@ENV.S3_PORT s3-use-http=@ENV.S3_USE_HTTP +s3-ssl-no-verify=@ENV.S3_SSL_NO_VERIFY +s3-provider=@ENV.S3_PROVIDER # You can change the following when running the tests against # your own S3 setup diff --git a/mysql-test/suite/s3/suite.pm b/mysql-test/suite/s3/suite.pm index cdefbc5e323..383bf4f7798 100644 --- a/mysql-test/suite/s3/suite.pm +++ b/mysql-test/suite/s3/suite.pm @@ -20,6 +20,8 @@ if(connect(SOCK, $paddr)) $ENV{'S3_REGION'} = ""; $ENV{'S3_PROTOCOL_VERSION'} = "Auto"; $ENV{'S3_USE_HTTP'} = "ON"; + $ENV{'S3_SSL_NO_VERIFY'} = "OFF"; + $ENV{'S3_PROVIDER'} = "Default"; } else { @@ -62,6 +64,17 @@ else { $ENV{'S3_USE_HTTP'} = "OFF"; } + + if (!$ENV{'S3_SSL_NO_VERIFY'}) + { + $ENV{'S3_SSL_NO_VERIFY'} = "OFF"; + } + + if (!$ENV{'S3_PROVIDER'}) + { + $ENV{'S3_PROVIDER'} = "Default"; + } + } bless { }; diff --git a/storage/maria/aria_s3_copy.cc b/storage/maria/aria_s3_copy.cc index b8a0f5b7921..1b0063c21f8 100644 --- a/storage/maria/aria_s3_copy.cc +++ b/storage/maria/aria_s3_copy.cc @@ -41,7 +41,10 @@ static const char *opt_database; static const char *opt_s3_bucket="MariaDB"; static my_bool opt_compression, opt_verbose, opt_force, opt_s3_debug; static my_bool opt_s3_use_http; +static my_bool opt_s3_ssl_no_verify; +static my_bool opt_s3_no_content_type; static ulong opt_operation= OP_IMPOSSIBLE, opt_protocol_version= 1; +static ulong opt_provider= 0; static ulong opt_block_size; static ulong opt_s3_port; static char **default_argv=0; @@ -73,6 +76,13 @@ static struct my_option my_long_options[] = {"s3_use_http", 'P', "If true, force use of HTTP protocol", (char**) &opt_s3_use_http, (char**) &opt_s3_use_http, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"s3_ssl_no_verify", 's', "If true, verification of the S3 endpoint SSL " + "certificate is disabled", + (char**) &opt_s3_ssl_no_verify, (char**) &opt_s3_ssl_no_verify, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"s3_no_content_type", 'n', "If true, disables the Content-Type header", + (char**) &opt_s3_no_content_type, (char**) &opt_s3_no_content_type, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'c', "Use compression", &opt_compression, &opt_compression, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"op", 'o', "Operation to execute. One of 'from_s3', 'to_s3' or " @@ -92,6 +102,10 @@ static struct my_option my_long_options[] = "Note: \"Legacy\", \"Original\" and \"Amazon\" are deprecated.", &opt_protocol_version, &opt_protocol_version, &s3_protocol_typelib, GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"s3_provider", 'R', "Enable S3 provider specific compatibility tweaks " + "\"Default\", \"Amazon\", or \"Huawei\".", + &opt_provider, &opt_provider, &s3_provider_typelib, + GET_ENUM, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Force copy even if target exists", &opt_force, &opt_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Write more information", &opt_verbose, &opt_verbose, @@ -220,6 +234,19 @@ int main(int argc, char** argv) ms3_set_option(global_s3_client, MS3_OPT_BUFFER_CHUNK_SIZE, &block_size); + /* Provider specific overrides */ + switch (opt_provider) + { + case 0: /* Default */ + break; + case 1: /* Amazon */ + opt_protocol_version = 5; + break; + case 2: /* Huawei */ + opt_s3_no_content_type = 1; + break; + } + if (opt_protocol_version > 2) { uint8_t protocol_version; @@ -245,6 +272,11 @@ int main(int argc, char** argv) if (opt_s3_use_http) ms3_set_option(global_s3_client, MS3_OPT_USE_HTTP, NULL); + if (opt_s3_ssl_no_verify) + ms3_set_option(global_s3_client, MS3_OPT_DISABLE_SSL_VERIFY, NULL); + + if (opt_s3_no_content_type) + ms3_set_option(global_s3_client, MS3_OPT_NO_CONTENT_TYPE, NULL); for (; *argv ; argv++) { diff --git a/storage/maria/ha_s3.cc b/storage/maria/ha_s3.cc index 276703cfaea..e911bdbe242 100644 --- a/storage/maria/ha_s3.cc +++ b/storage/maria/ha_s3.cc @@ -78,7 +78,7 @@ #define DEFAULT_AWS_HOST_NAME "s3.amazonaws.com" static PAGECACHE s3_pagecache; -static ulong s3_block_size, s3_protocol_version; +static ulong s3_block_size, s3_protocol_version, s3_provider; static ulong s3_pagecache_division_limit, s3_pagecache_age_threshold; static ulong s3_pagecache_file_hash_size; static ulonglong s3_pagecache_buffer_size; @@ -86,6 +86,8 @@ static char *s3_bucket, *s3_access_key=0, *s3_secret_key=0, *s3_region; static char *s3_host_name; static int s3_port; static my_bool s3_use_http; +static my_bool s3_ssl_no_verify; +static my_bool s3_no_content_type; static char *s3_tmp_access_key=0, *s3_tmp_secret_key=0; static my_bool s3_debug= 0, s3_slave_ignore_updates= 0; static my_bool s3_replicate_alter_as_create_select= 0; @@ -222,6 +224,10 @@ static MYSQL_SYSVAR_BOOL(use_http, s3_use_http, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "If true, force use of HTTP protocol", NULL /*check*/, NULL /*update*/, 0 /*default*/); +static MYSQL_SYSVAR_BOOL(ssl_no_verify, s3_ssl_no_verify, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "If true, SSL certificate verifiction for the S3 endpoint is disabled", + NULL, NULL, 0); static MYSQL_SYSVAR_STR(access_key, s3_tmp_access_key, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC, "AWS access key", @@ -234,6 +240,15 @@ static MYSQL_SYSVAR_STR(region, s3_region, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "AWS region", 0, 0, ""); +static MYSQL_SYSVAR_BOOL(no_content_type, s3_no_content_type, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "If true, disables the Content-Type header, required for some providers", + NULL, NULL, 0); +static MYSQL_SYSVAR_ENUM(provider, s3_provider, + PLUGIN_VAR_RQCMDARG, + "Enable S3 provider specific compatibility tweaks " + "\"Default\", \"Amazon\", or \"Huawei\". ", + NULL, NULL, 0, &s3_provider_typelib); ha_create_table_option s3_table_option_list[]= { @@ -319,6 +334,9 @@ static my_bool s3_info_init(S3_INFO *info) lex_string_set(&info->host_name, s3_host_name); info->port= s3_port; info->use_http= s3_use_http; + info->ssl_no_verify= s3_ssl_no_verify; + info->no_content_type = s3_no_content_type; + info->provider= s3_provider; lex_string_set(&info->access_key, s3_access_key); lex_string_set(&info->secret_key, s3_secret_key); lex_string_set(&info->region, s3_region); @@ -1120,12 +1138,15 @@ static struct st_mysql_sys_var* system_variables[]= { MYSQL_SYSVAR(host_name), MYSQL_SYSVAR(port), MYSQL_SYSVAR(use_http), + MYSQL_SYSVAR(ssl_no_verify), MYSQL_SYSVAR(bucket), MYSQL_SYSVAR(access_key), MYSQL_SYSVAR(secret_key), MYSQL_SYSVAR(region), MYSQL_SYSVAR(slave_ignore_updates), MYSQL_SYSVAR(replicate_alter_as_create_select), + MYSQL_SYSVAR(no_content_type), + MYSQL_SYSVAR(provider), NULL }; diff --git a/storage/maria/libmarias3 b/storage/maria/libmarias3 index a81724ab07b..5e6aa32f96e 160000 --- a/storage/maria/libmarias3 +++ b/storage/maria/libmarias3 @@ -1 +1 @@ -Subproject commit a81724ab07bd28e16bf431419c24b6362d5894fc +Subproject commit 5e6aa32f96ebdbcaf32b90d6182685156f8198b5 diff --git a/storage/maria/s3_func.c b/storage/maria/s3_func.c index d85dc8a0b40..b8918c48d4b 100644 --- a/storage/maria/s3_func.c +++ b/storage/maria/s3_func.c @@ -43,6 +43,9 @@ static const char *protocol_types[]= {"Auto", "Original", "Amazon", "Legacy", "P TYPELIB s3_protocol_typelib= {array_elements(protocol_types)-1,"", protocol_types, NULL}; +static const char *providers[]= {"Default", "Amazon", "Huawei", NullS}; +TYPELIB s3_provider_typelib = {array_elements(providers)-1,"",providers, NULL}; + /****************************************************************************** Allocations handler for libmarias3 To be removed when we do the init allocation in mysqld.cc @@ -154,6 +157,20 @@ ms3_st *s3_open_connection(S3_INFO *s3) errno, ms3_error(errno)); my_errno= HA_ERR_NO_SUCH_TABLE; } + + /* Provider specific overrides */ + switch (s3->provider) + { + case 0: /* Default */ + break; + case 1: /* Amazon */ + s3->protocol_version = 5; + break; + case 2: /* Huawei */ + s3->no_content_type = 1; + break; + } + if (s3->protocol_version > 2) { uint8_t protocol_version; @@ -177,6 +194,12 @@ ms3_st *s3_open_connection(S3_INFO *s3) if (s3->use_http) ms3_set_option(s3_client, MS3_OPT_USE_HTTP, NULL); + if (s3->ssl_no_verify) + ms3_set_option(s3_client, MS3_OPT_DISABLE_SSL_VERIFY, NULL); + + if (s3->no_content_type) + ms3_set_option(s3_client, MS3_OPT_NO_CONTENT_TYPE, NULL); + return s3_client; } diff --git a/storage/maria/s3_func.h b/storage/maria/s3_func.h index f73a95dea24..9c0831b158d 100644 --- a/storage/maria/s3_func.h +++ b/storage/maria/s3_func.h @@ -38,6 +38,7 @@ extern struct s3_func { } s3f; extern TYPELIB s3_protocol_typelib; +extern TYPELIB s3_provider_typelib; /* Store information about a s3 connection */ @@ -47,6 +48,8 @@ struct s3_info LEX_CSTRING access_key, secret_key, region, bucket, host_name; int port; // 0 means 'Use default' my_bool use_http; + my_bool ssl_no_verify; + my_bool no_content_type; /* Will be set by caller or by ma_open() */ LEX_CSTRING database, table; @@ -63,6 +66,8 @@ struct s3_info /* Protocol for the list bucket API call. 1 for Amazon, 2 for some others */ uint8_t protocol_version; + + uint8_t provider; }; From fafcd24e023c059b4f93453bf00d7429b76de4ce Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 10 Sep 2024 19:57:51 +0300 Subject: [PATCH 9/9] Fixed compiler warning from strncpy in mysql_plugin.c --- client/mysql_plugin.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c index 27ec0bc55e9..d025de60c62 100644 --- a/client/mysql_plugin.c +++ b/client/mysql_plugin.c @@ -738,8 +738,8 @@ static int check_options(int argc, char **argv, char *operation) { int i= 0; /* loop counter */ int num_found= 0; /* number of options found (shortcut loop) */ - char config_file[FN_REFLEN]; /* configuration file name */ - char plugin_name[FN_REFLEN]; /* plugin name */ + char config_file[FN_REFLEN+1]; /* configuration file name */ + char plugin_name[FN_REFLEN+1]; /* plugin name */ /* Form prefix strings for the options. */ const char *basedir_prefix = "--basedir="; @@ -787,8 +787,8 @@ static int check_options(int argc, char **argv, char *operation) /* read the plugin config file and check for match against argument */ else { - if (safe_strcpy_truncated(plugin_name, sizeof plugin_name, argv[i]) || - safe_strcpy_truncated(config_file, sizeof config_file, argv[i]) || + if (safe_strcpy_truncated(plugin_name, sizeof(plugin_name)-1, argv[i]) || + safe_strcpy_truncated(config_file, sizeof(config_file)-1, argv[i]) || safe_strcat(config_file, sizeof(config_file), ".ini")) { fprintf(stderr, "ERROR: argument is too long.\n");