diff options
Diffstat (limited to 'storage/spider/ha_spider.cc')
-rw-r--r-- | storage/spider/ha_spider.cc | 698 |
1 files changed, 56 insertions, 642 deletions
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 7b1b50d7d8f..b8d33e38c4e 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -81,7 +81,6 @@ ha_spider::ha_spider( ft_current = NULL; ft_count = 0; ft_init_without_index_init = FALSE; - sql_kinds = 0; error_mode = 0; use_spatial_index = FALSE; use_fields = FALSE; @@ -92,7 +91,6 @@ ha_spider::ha_spider( prev_index_rnd_init = SPD_NONE; direct_aggregate_item_first = NULL; result_link_idx = 0; - result_list.have_sql_kind_backup = FALSE; result_list.sqls = NULL; result_list.insert_sqls = NULL; result_list.update_sqls = NULL; @@ -143,7 +141,6 @@ ha_spider::ha_spider( ft_current = NULL; ft_count = 0; ft_init_without_index_init = FALSE; - sql_kinds = 0; error_mode = 0; use_spatial_index = FALSE; use_fields = FALSE; @@ -154,7 +151,6 @@ ha_spider::ha_spider( prev_index_rnd_init = SPD_NONE; direct_aggregate_item_first = NULL; result_link_idx = 0; - result_list.have_sql_kind_backup = FALSE; result_list.sqls = NULL; result_list.insert_sqls = NULL; result_list.update_sqls = NULL; @@ -486,7 +482,7 @@ error_wide_handler_alloc: int ha_spider::close() { - int error_num = 0, roop_count, error_num2; + int error_num= 0, roop_count; THD *thd = ha_thd(); backup_error_status(); DBUG_ENTER("ha_spider::close"); @@ -513,17 +509,6 @@ int ha_spider::close() spider_free(spider_current_trx, direct_aggregate_item_first, MYF(0)); direct_aggregate_item_first = direct_aggregate_item_current; } - if (is_clone) - { - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - { - if ((error_num2 = close_opened_handler(roop_count, FALSE))) - { - if (check_error_mode(error_num2)) - error_num = error_num2; - } - } - } for (roop_count = share->use_dbton_count - 1; roop_count >= 0; roop_count--) { uint dbton_id = share->use_dbton_ids[roop_count]; @@ -982,13 +967,11 @@ int ha_spider::reset() { delete direct_aggregate_item_current->item; direct_aggregate_item_current->item = NULL; -#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR if (direct_aggregate_item_current->init_mem_root) { free_root(&direct_aggregate_item_current->mem_root, MYF(0)); direct_aggregate_item_current->init_mem_root = FALSE; } -#endif } direct_aggregate_item_current = direct_aggregate_item_current->next; } @@ -1055,12 +1038,6 @@ int ha_spider::reset() { result_list.update_sqls[roop_count].length(0); - if ((error_num2 = close_opened_handler(roop_count, TRUE))) - { - if (check_error_mode(error_num2)) - error_num = error_num2; - } - conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL; } result_list.bulk_update_mode = 0; @@ -1101,10 +1078,8 @@ int ha_spider::reset() ft_current = NULL; ft_count = 0; ft_init_without_index_init = FALSE; - sql_kinds = 0; do_direct_update = FALSE; prev_index_rnd_init = SPD_NONE; - result_list.have_sql_kind_backup = FALSE; result_list.direct_order_limit = FALSE; result_list.direct_limit_offset = FALSE; result_list.set_split_read = FALSE; @@ -1263,8 +1238,7 @@ int ha_spider::index_init( set_select_column_mode(); } - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); result_list.check_direct_order_limit = FALSE; prev_index_rnd_init = SPD_INDEX; @@ -1322,8 +1296,6 @@ int ha_spider::index_read_map_internal( ) use_spatial_index = TRUE; - if ((error_num = index_handler_init())) - DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -1336,8 +1308,7 @@ int ha_spider::index_read_map_internal( start_key.key = key; start_key.keypart_map = keypart_map; start_key.flag = find_flag; - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -1385,7 +1356,6 @@ int ha_spider::index_read_map_internal( result_list.split_read)); DBUG_PRINT("info",("spider result_list.limit_num=%lld", result_list.limit_num)); - if (sql_kinds & SPIDER_SQL_KIND_SQL) { if (result_list.direct_order_limit) { @@ -1412,16 +1382,6 @@ int ha_spider::index_read_map_internal( DBUG_RETURN(error_num); } } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - if ((error_num = append_limit_sql_part( - result_list.internal_offset, - result_list.limit_num, - SPIDER_SQL_TYPE_HANDLER))) - { - DBUG_RETURN(error_num); - } - } int roop_start, roop_end, lock_mode, link_ok; lock_mode = spider_conn_lock_mode(this); @@ -1480,13 +1440,8 @@ int ha_spider::index_read_map_internal( } } else { 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; - } + conn= conns[roop_count]; + sql_type= SPIDER_SQL_TYPE_SELECT_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -1694,8 +1649,6 @@ int ha_spider::index_read_last_map_internal( DBUG_RETURN(ER_QUERY_INTERRUPTED); } do_direct_update = FALSE; - if ((error_num = index_handler_init())) - DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -1716,8 +1669,7 @@ int ha_spider::index_read_last_map_internal( start_key.key = key; start_key.keypart_map = keypart_map; start_key.flag = HA_READ_KEY_EXACT; - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -1753,7 +1705,6 @@ int ha_spider::index_read_last_map_internal( &start_key, NULL, this)) ) DBUG_RETURN(error_num); - if (sql_kinds & SPIDER_SQL_KIND_SQL) { if (result_list.direct_order_limit) { @@ -1780,16 +1731,6 @@ int ha_spider::index_read_last_map_internal( DBUG_RETURN(error_num); } } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - if ((error_num = append_limit_sql_part( - result_list.internal_offset, - result_list.limit_num, - SPIDER_SQL_TYPE_HANDLER))) - { - DBUG_RETURN(error_num); - } - } int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; tmp_lock_mode = spider_conn_lock_mode(this); @@ -1848,13 +1789,8 @@ int ha_spider::index_read_last_map_internal( } } else { 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; - } + conn= conns[roop_count]; + sql_type= SPIDER_SQL_TYPE_SELECT_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -2113,25 +2049,20 @@ int ha_spider::index_first_internal( DBUG_RETURN(ER_QUERY_INTERRUPTED); } do_direct_update = FALSE; - if ((error_num = index_handler_init())) - DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", pt_clone_source_handler)); pt_clone_source_handler->pt_clone_last_searcher = this; } - if ( - sql_is_empty(SPIDER_SQL_TYPE_HANDLER) || - sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL) - ) { -/* - spider_db_free_one_result_for_start_next(this); -*/ + if (sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL)) + { + /* + spider_db_free_one_result_for_start_next(this); + */ if ((error_num = spider_db_free_result(this, FALSE))) DBUG_RETURN(error_num); - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); check_direct_order_limit(); @@ -2170,7 +2101,6 @@ int ha_spider::index_first_internal( NULL, NULL, this)) ) DBUG_RETURN(error_num); - if (sql_kinds & SPIDER_SQL_KIND_SQL) { if (result_list.direct_order_limit) { @@ -2197,16 +2127,6 @@ int ha_spider::index_first_internal( DBUG_RETURN(error_num); } } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - if ((error_num = append_limit_sql_part( - result_list.internal_offset, - result_list.limit_num, - SPIDER_SQL_TYPE_HANDLER))) - { - DBUG_RETURN(error_num); - } - } int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; tmp_lock_mode = spider_conn_lock_mode(this); @@ -2265,13 +2185,8 @@ int ha_spider::index_first_internal( } } else { 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; - } + conn= conns[roop_count]; + sql_type= SPIDER_SQL_TYPE_SELECT_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -2478,25 +2393,20 @@ int ha_spider::index_last_internal( DBUG_RETURN(ER_QUERY_INTERRUPTED); } do_direct_update = FALSE; - if ((error_num = index_handler_init())) - DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", pt_clone_source_handler)); pt_clone_source_handler->pt_clone_last_searcher = this; } - if ( - sql_is_empty(SPIDER_SQL_TYPE_HANDLER) || - sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL) - ) { -/* - spider_db_free_one_result_for_start_next(this); -*/ + if (sql_is_empty(SPIDER_SQL_TYPE_SELECT_SQL)) + { + /* + spider_db_free_one_result_for_start_next(this); + */ if ((error_num = spider_db_free_result(this, FALSE))) DBUG_RETURN(error_num); - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); check_direct_order_limit(); @@ -2535,7 +2445,6 @@ int ha_spider::index_last_internal( NULL, NULL, this)) ) DBUG_RETURN(error_num); - if (sql_kinds & SPIDER_SQL_KIND_SQL) { if (result_list.direct_order_limit) { @@ -2562,16 +2471,6 @@ int ha_spider::index_last_internal( DBUG_RETURN(error_num); } } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - if ((error_num = append_limit_sql_part( - result_list.internal_offset, - result_list.limit_num, - SPIDER_SQL_TYPE_HANDLER))) - { - DBUG_RETURN(error_num); - } - } int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; tmp_lock_mode = spider_conn_lock_mode(this); @@ -2630,13 +2529,8 @@ int ha_spider::index_last_internal( } } else { 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; - } + conn= conns[roop_count]; + sql_type= SPIDER_SQL_TYPE_SELECT_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -2895,8 +2789,6 @@ int ha_spider::read_range_first_internal( } range_key_part = table->key_info[active_index].key_part; - if ((error_num = index_handler_init())) - DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -2905,8 +2797,7 @@ int ha_spider::read_range_first_internal( } spider_db_free_one_result_for_start_next(this); check_direct_order_limit(); - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); @@ -2943,7 +2834,6 @@ int ha_spider::read_range_first_internal( start_key, eq_range ? NULL : end_key, this)) ) DBUG_RETURN(error_num); - if (sql_kinds & SPIDER_SQL_KIND_SQL) { if (result_list.direct_order_limit) { @@ -2970,16 +2860,6 @@ int ha_spider::read_range_first_internal( DBUG_RETURN(error_num); } } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - if ((error_num = append_limit_sql_part( - result_list.internal_offset, - result_list.limit_num, - SPIDER_SQL_TYPE_HANDLER))) - { - DBUG_RETURN(error_num); - } - } int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; tmp_lock_mode = spider_conn_lock_mode(this); @@ -3038,13 +2918,8 @@ int ha_spider::read_range_first_internal( } } else { 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; - } + conn= conns[roop_count]; + sql_type= SPIDER_SQL_TYPE_SELECT_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -3227,12 +3102,12 @@ int ha_spider::read_range_first( use_pre_call = FALSE; if ((error_num = read_range_next())) DBUG_RETURN(error_num); - DBUG_RETURN(check_ha_range_eof()); + DBUG_RETURN(0); } if ((error_num = read_range_first_internal(table->record[0], start_key, end_key, eq_range, sorted))) DBUG_RETURN(error_num); - DBUG_RETURN(check_ha_range_eof()); + DBUG_RETURN(0); } int ha_spider::read_range_next() @@ -3263,7 +3138,7 @@ int ha_spider::read_range_next() if ((error_num = spider_db_seek_next(table->record[0], this, search_link_idx, table))) DBUG_RETURN(check_error_mode_eof(error_num)); - DBUG_RETURN(check_ha_range_eof()); + DBUG_RETURN(0); } void ha_spider::reset_no_where_cond() @@ -3440,8 +3315,6 @@ int ha_spider::multi_range_read_next_first( DBUG_RETURN(ER_QUERY_INTERRUPTED); } do_direct_update = FALSE; - if ((error_num = index_handler_init())) - DBUG_RETURN(check_error_mode_eof(error_num)); if (is_clone) { DBUG_PRINT("info",("spider set pt_clone_last_searcher to %p", @@ -3457,17 +3330,13 @@ int ha_spider::multi_range_read_next_first( DBUG_PRINT("info",("spider result_list.finish_flg = FALSE")); result_list.finish_flg = FALSE; result_list.record_num = 0; - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); result_list.desc_flg = FALSE; result_list.sorted = mrr_is_output_sorted; result_list.key_info = &table->key_info[active_index]; - if ( - multi_range_num == 1 || - result_list.multi_split_read <= 1 || - (sql_kinds & SPIDER_SQL_KIND_HANDLER) - ) { + if (multi_range_num == 1 || result_list.multi_split_read <= 1) + { if (wide_handler->keyread) result_list.keyread = TRUE; else @@ -3502,7 +3371,6 @@ int ha_spider::multi_range_read_next_first( NULL : &mrr_cur_range.end_key, this)) ) DBUG_RETURN(error_num); - if (sql_kinds & SPIDER_SQL_KIND_SQL) { if (result_list.direct_order_limit) { @@ -3529,16 +3397,6 @@ int ha_spider::multi_range_read_next_first( DBUG_RETURN(error_num); } } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - if ((error_num = append_limit_sql_part( - result_list.internal_offset + result_list.record_num, - result_list.limit_num, - SPIDER_SQL_TYPE_HANDLER))) - { - DBUG_RETURN(error_num); - } - } int roop_start, roop_end, tmp_lock_mode, link_ok; tmp_lock_mode = spider_conn_lock_mode(this); @@ -3595,13 +3453,8 @@ int ha_spider::multi_range_read_next_first( } } else { 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; - } + conn= conns[roop_count]; + sql_type= SPIDER_SQL_TYPE_SELECT_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -3771,7 +3624,7 @@ int ha_spider::multi_range_read_next_first( if (!(error_num = spider_db_fetch(table->record[0], this, table))) { *range_info = (char *) mrr_cur_range.ptr; - DBUG_RETURN(check_ha_range_eof()); + DBUG_RETURN(0); } if ( error_num != HA_ERR_END_OF_FILE && @@ -3799,7 +3652,6 @@ int ha_spider::multi_range_read_next_first( DBUG_RETURN(check_error_mode_eof(0)); } set_where_to_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); - set_where_to_pos_sql(SPIDER_SQL_TYPE_HANDLER); } DBUG_PRINT("info",("spider range_res2=%d", range_res)); if (error_num) @@ -3910,34 +3762,11 @@ int ha_spider::multi_range_read_next_first( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL))) DBUG_RETURN(error_num); - if ((sql_kinds & SPIDER_SQL_KIND_SQL)) - { - for (roop_count = 0; roop_count < (int) share->link_count; - roop_count++) - { - result_list.sql_kind_backup[roop_count] = sql_kind[roop_count]; - sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; - } - result_list.sql_kinds_backup = sql_kinds; - sql_kinds = SPIDER_SQL_KIND_SQL; - result_list.have_sql_kind_backup = TRUE; - } } memset(result_list.tmp_table_join_first, 0xFF, share->link_bitmap_size); } else { result_list.tmp_table_join = FALSE; - if (result_list.have_sql_kind_backup) - { - for (roop_count = 0; roop_count < (int) share->link_count; - roop_count++) - { - sql_kind[roop_count] = - result_list.sql_kind_backup[roop_count]; - } - sql_kinds = result_list.sql_kinds_backup; - result_list.have_sql_kind_backup = FALSE; - } } result_list.tmp_table_join_break_after_get_next = FALSE; @@ -4252,13 +4081,8 @@ int ha_spider::multi_range_read_next_first( } } else { ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } + conn= conns[roop_count]; + sql_type= SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -4532,8 +4356,7 @@ int ha_spider::multi_range_read_next_first( DBUG_RETURN(check_error_mode_eof(0)); } multi_range_cnt = 0; - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); } while (!error_num); } @@ -4606,11 +4429,8 @@ int ha_spider::multi_range_read_next_next( pt_clone_source_handler)); pt_clone_source_handler->pt_clone_last_searcher = this; } - if ( - multi_range_num == 1 || - result_list.multi_split_read <= 1 || - (sql_kinds & SPIDER_SQL_KIND_HANDLER) - ) { + if (multi_range_num == 1 || result_list.multi_split_read <= 1) + { if (!(error_num = spider_db_seek_next(table->record[0], this, search_link_idx, table))) { @@ -4650,7 +4470,6 @@ int ha_spider::multi_range_read_next_next( DBUG_RETURN(check_error_mode_eof(0)); } set_where_to_pos_sql(SPIDER_SQL_TYPE_SELECT_SQL); - set_where_to_pos_sql(SPIDER_SQL_TYPE_HANDLER); result_list.limit_num = result_list.internal_limit - result_list.record_num >= result_list.split_read ? @@ -4663,7 +4482,6 @@ int ha_spider::multi_range_read_next_next( NULL : &mrr_cur_range.end_key, this)) ) DBUG_RETURN(error_num); - if (sql_kinds & SPIDER_SQL_KIND_SQL) { if (result_list.direct_order_limit) { @@ -4690,16 +4508,6 @@ int ha_spider::multi_range_read_next_next( DBUG_RETURN(error_num); } } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - if ((error_num = append_limit_sql_part( - result_list.internal_offset + result_list.record_num, - result_list.limit_num, - SPIDER_SQL_TYPE_HANDLER))) - { - DBUG_RETURN(error_num); - } - } int roop_start, roop_end, tmp_lock_mode, link_ok; tmp_lock_mode = spider_conn_lock_mode(this); @@ -4756,13 +4564,8 @@ int ha_spider::multi_range_read_next_next( } } else { 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; - } + conn= conns[roop_count]; + sql_type= SPIDER_SQL_TYPE_SELECT_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -4931,7 +4734,7 @@ int ha_spider::multi_range_read_next_next( if (!(error_num = spider_db_fetch(table->record[0], this, table))) { *range_info = (char *) mrr_cur_range.ptr; - DBUG_RETURN(check_ha_range_eof()); + DBUG_RETURN(0); } if ( error_num != HA_ERR_END_OF_FILE && @@ -5034,8 +4837,7 @@ int ha_spider::multi_range_read_next_next( } result_list.record_num = 0; - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); bool tmp_high_priority = wide_handler->high_priority; @@ -5076,34 +4878,11 @@ int ha_spider::multi_range_read_next_next( if ((error_num = reset_sql_sql( SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL))) DBUG_RETURN(error_num); - if ((sql_kinds & SPIDER_SQL_KIND_SQL)) - { - for (roop_count = 0; roop_count < (int) share->link_count; - roop_count++) - { - result_list.sql_kind_backup[roop_count] = sql_kind[roop_count]; - sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; - } - result_list.sql_kinds_backup = sql_kinds; - sql_kinds = SPIDER_SQL_KIND_SQL; - result_list.have_sql_kind_backup = TRUE; - } } memset(result_list.tmp_table_join_first, 0xFF, share->link_bitmap_size); } else { result_list.tmp_table_join = FALSE; - if (result_list.have_sql_kind_backup) - { - for (roop_count = 0; roop_count < (int) share->link_count; - roop_count++) - { - sql_kind[roop_count] = - result_list.sql_kind_backup[roop_count]; - } - sql_kinds = result_list.sql_kinds_backup; - result_list.have_sql_kind_backup = FALSE; - } } if (result_list.tmp_table_join) @@ -5406,13 +5185,8 @@ int ha_spider::multi_range_read_next_next( } } else { ulong sql_type; - conn = conns[roop_count]; - if (sql_kind[roop_count] == SPIDER_SQL_KIND_SQL) - { - sql_type = SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL; - } else { - sql_type = SPIDER_SQL_TYPE_HANDLER; - } + conn= conns[roop_count]; + sql_type= SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_TMP_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -5684,8 +5458,7 @@ int ha_spider::multi_range_read_next_next( DBUG_RETURN(check_error_mode_eof(0)); } multi_range_cnt = 0; - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); } while (!error_num); } @@ -5790,8 +5563,7 @@ int ha_spider::rnd_init( result_list.keyread = FALSE; init_rnd_handler = FALSE; - if ((error_num = reset_sql_sql( - SPIDER_SQL_TYPE_SELECT_SQL | SPIDER_SQL_TYPE_HANDLER))) + if ((error_num= reset_sql_sql(SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); result_list.check_direct_order_limit = FALSE; } @@ -5847,8 +5619,6 @@ int ha_spider::rnd_next_internal( { if ((error_num = spider_set_conn_bg_param(this))) DBUG_RETURN(error_num); - if ((error_num = rnd_handler_init())) - DBUG_RETURN(check_error_mode_eof(error_num)); check_direct_order_limit(); check_select_column(TRUE); @@ -5921,7 +5691,6 @@ int ha_spider::rnd_next_internal( result_list.limit_num = result_list.internal_limit >= result_list.split_read ? result_list.split_read : result_list.internal_limit; - if (sql_kinds & SPIDER_SQL_KIND_SQL) { if ((error_num = append_limit_sql_part( result_list.internal_offset, @@ -5937,16 +5706,6 @@ int ha_spider::rnd_next_internal( DBUG_RETURN(error_num); } } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - if ((error_num = append_limit_sql_part( - result_list.internal_offset, - result_list.limit_num, - SPIDER_SQL_TYPE_HANDLER))) - { - DBUG_RETURN(error_num); - } - } int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; tmp_lock_mode = spider_conn_lock_mode(this); @@ -6006,12 +5765,7 @@ int ha_spider::rnd_next_internal( } else { 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; - } + sql_type= SPIDER_SQL_TYPE_SELECT_SQL; spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id]; pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) @@ -6367,7 +6121,7 @@ _ft_vft spider_ft_vft = { int ha_spider::ft_init() { - int roop_count, error_num; + int error_num; DBUG_ENTER("ha_spider::ft_init"); DBUG_PRINT("info",("spider this=%p", this)); if (store_error_num) @@ -6403,9 +6157,6 @@ int ha_spider::ft_init() ft_init_and_first = TRUE; - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; - sql_kinds = SPIDER_SQL_KIND_SQL; DBUG_RETURN(0); } @@ -6548,7 +6299,6 @@ int ha_spider::ft_read_internal( append_group_by_sql_part(NULL, 0, SPIDER_SQL_TYPE_SELECT_SQL))) DBUG_RETURN(error_num); } - if (sql_kinds & SPIDER_SQL_KIND_SQL) { if ((error_num = append_limit_sql_part( result_list.internal_offset, @@ -6564,16 +6314,6 @@ int ha_spider::ft_read_internal( DBUG_RETURN(error_num); } } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - if ((error_num = append_limit_sql_part( - result_list.internal_offset, - result_list.limit_num, - SPIDER_SQL_TYPE_HANDLER))) - { - DBUG_RETURN(error_num); - } - } int roop_start, roop_end, roop_count, tmp_lock_mode, link_ok; tmp_lock_mode = spider_conn_lock_mode(this); @@ -8417,7 +8157,6 @@ bool ha_spider::check_direct_update_sql_part( DBUG_RETURN(FALSE); } -#ifdef SPIDER_MDEV_16246 /** Perform initialization for a direct update request. @@ -8430,9 +8169,6 @@ bool ha_spider::check_direct_update_sql_part( int ha_spider::direct_update_rows_init( List<Item> *update_fields ) -#else -int ha_spider::direct_update_rows_init() -#endif { st_select_lex *select_lex; longlong select_limit; @@ -8549,11 +8285,8 @@ int ha_spider::direct_update_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } - if ( - (active_index != MAX_KEY && (error_num = index_handler_init())) || - (active_index == MAX_KEY && (error_num = rnd_handler_init())) || - (error_num = spider_db_direct_update(this, table, update_rows, found_rows)) - ) + if ((error_num= + spider_db_direct_update(this, table, update_rows, found_rows))) DBUG_RETURN(check_error_mode(error_num)); DBUG_RETURN(0); @@ -8695,11 +8428,7 @@ int ha_spider::direct_delete_rows( table_share->db.str, table_share->table_name.str); DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } - if ( - (active_index != MAX_KEY && (error_num = index_handler_init())) || - (active_index == MAX_KEY && (error_num = rnd_handler_init())) || - (error_num = spider_db_direct_delete(this, table, delete_rows)) - ) + if ((error_num= spider_db_direct_delete(this, table, delete_rows))) DBUG_RETURN(check_error_mode(error_num)); DBUG_RETURN(0); @@ -8708,7 +8437,7 @@ int ha_spider::direct_delete_rows( int ha_spider::delete_all_rows() { - int error_num, roop_count; + int error_num; THD *thd = ha_thd(); backup_error_status(); DBUG_ENTER("ha_spider::delete_all_rows"); @@ -8722,9 +8451,6 @@ int ha_spider::delete_all_rows() DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM); } do_direct_update = FALSE; - sql_kinds = SPIDER_SQL_KIND_SQL; - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; if ((error_num = spider_db_delete_all_rows(this))) DBUG_RETURN(check_error_mode(error_num)); if (wide_handler->sql_command == SQLCOM_TRUNCATE && @@ -8746,7 +8472,7 @@ int ha_spider::delete_all_rows() int ha_spider::truncate() { - int error_num, roop_count; + int error_num; THD *thd = ha_thd(); backup_error_status(); DBUG_ENTER("ha_spider::truncate"); @@ -8763,9 +8489,6 @@ int ha_spider::truncate() DBUG_RETURN(error_num); } do_direct_update = FALSE; - sql_kinds = SPIDER_SQL_KIND_SQL; - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; if ((error_num = spider_db_delete_all_rows(this))) DBUG_RETURN(check_error_mode(error_num)); if (wide_handler->sql_command == SQLCOM_TRUNCATE && @@ -10107,7 +9830,6 @@ uint ha_spider::check_partitioned() void ha_spider::check_direct_order_limit() { - int roop_count; DBUG_ENTER("ha_spider::check_direct_order_limit"); DBUG_PRINT("info",("spider this=%p", this)); if (!result_list.check_direct_order_limit) @@ -10115,9 +9837,6 @@ void ha_spider::check_direct_order_limit() if (spider_check_direct_order_limit(this)) { result_list.direct_order_limit = TRUE; - sql_kinds = SPIDER_SQL_KIND_SQL; - for (roop_count = 0; roop_count < (int) share->link_count; roop_count++) - sql_kind[roop_count] = SPIDER_SQL_KIND_SQL; } else result_list.direct_order_limit = FALSE; @@ -10203,35 +9922,6 @@ bool ha_spider::is_sole_projection_field( DBUG_RETURN( TRUE ); } -int ha_spider::check_ha_range_eof() -{ - DBUG_ENTER("ha_spider::check_ha_range_eof"); - DBUG_PRINT("info",("spider this=%p", this)); - const key_range *end_key = result_list.end_key; - DBUG_PRINT("info",("spider use_both_key=%s", - result_list.use_both_key ? "TRUE" : "FALSE")); - DBUG_PRINT("info",("spider sql_kind[%u]=%u", - search_link_idx, sql_kind[search_link_idx])); - DBUG_PRINT("info",("spider sql_command=%u", wide_handler->sql_command)); - if ( - result_list.use_both_key && - (sql_kind[search_link_idx] & SPIDER_SQL_KIND_HANDLER) && - wide_handler->sql_command != SQLCOM_HA_READ - ) { - int cmp_result = key_cmp(result_list.key_info->key_part, - end_key->key, end_key->length); - DBUG_PRINT("info",("spider cmp_result=%d", cmp_result)); - if ( - cmp_result > 0 || - (end_key->flag == HA_READ_BEFORE_KEY && !cmp_result) - ) { - table->status = STATUS_NOT_FOUND; - DBUG_RETURN(HA_ERR_END_OF_FILE); - } - } - DBUG_RETURN(0); -} - int ha_spider::drop_tmp_tables() { int error_num = 0, tmp_error_num, need_mon; @@ -10377,262 +10067,6 @@ int ha_spider::drop_tmp_tables() DBUG_RETURN(error_num); } -bool ha_spider::handler_opened( - int link_idx, - uint tgt_conn_kind -) { - DBUG_ENTER("ha_spider::handler_opened"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_PRINT("info",("spider link_idx=%d", link_idx)); - DBUG_PRINT("info",("spider tgt_conn_kind=%u", tgt_conn_kind)); - if ( - spider_bit_is_set(m_handler_opened, link_idx) - ) { - DBUG_PRINT("info",("spider TRUE")); - DBUG_RETURN(TRUE); - } - DBUG_PRINT("info",("spider FALSE")); - DBUG_RETURN(FALSE); -} - -void ha_spider::set_handler_opened( - int link_idx -) { - DBUG_ENTER("ha_spider::set_handler_opened"); - DBUG_PRINT("info",("spider this=%p", this)); - spider_set_bit(m_handler_opened, link_idx); - DBUG_VOID_RETURN; -} - -void ha_spider::clear_handler_opened( - int link_idx, - uint tgt_conn_kind -) { - DBUG_ENTER("ha_spider::clear_handler_opened"); - DBUG_PRINT("info",("spider this=%p", this)); - spider_clear_bit(m_handler_opened, link_idx); - DBUG_VOID_RETURN; -} - -int ha_spider::close_opened_handler( - int link_idx, - bool release_conn -) { - int error_num = 0, error_num2; - 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, - 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; - } - spider_clear_bit(m_handler_opened, link_idx); - if (release_conn && !conns[link_idx]->join_trx) - { - spider_free_conn_from_trx(wide_handler->trx, conns[link_idx], - FALSE, FALSE, NULL); - conns[link_idx] = NULL; - } - } - DBUG_RETURN(error_num); -} - -int ha_spider::index_handler_init() -{ - int lock_mode, error_num; - int roop_start, roop_end, roop_count; - DBUG_ENTER("ha_spider::index_handler_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!init_index_handler) - { - init_index_handler = TRUE; - lock_mode = spider_conn_lock_mode(this); - if (lock_mode) - { - /* "for update" or "lock in share mode" */ - 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 { - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } - sql_kinds = 0; - direct_update_kinds = 0; - 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) - ) { - if ( - spider_conn_use_handler(this, lock_mode, roop_count) && - spider_conn_need_open_handler(this, active_index, roop_count) - ) { - if ((error_num = spider_db_open_handler(this, - 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); - } - set_handler_opened(roop_count); - } - } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - st_select_lex *select_lex; - longlong select_limit; - longlong offset_limit; - spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); - DBUG_PRINT("info",("spider SPIDER_SQL_KIND_HANDLER")); - result_list.semi_split_read = 1; - result_list.semi_split_read_limit = 9223372036854775807LL; - if (select_limit == 9223372036854775807LL) - { - DBUG_PRINT("info",("spider set limit to 1")); - result_list.semi_split_read_base = 1; - result_list.split_read = 1; - } else { - DBUG_PRINT("info",("spider set limit to %lld", select_limit)); - result_list.semi_split_read_base = select_limit; - result_list.split_read = select_limit; - } - } - } - DBUG_RETURN(0); -} - -int ha_spider::rnd_handler_init() -{ - int error_num, lock_mode; - int roop_start, roop_end, roop_count; - DBUG_ENTER("ha_spider::rnd_handler_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (!init_rnd_handler) - { - init_rnd_handler = TRUE; - lock_mode = spider_conn_lock_mode(this); - if (lock_mode) - { - /* "for update" or "lock in share mode" */ - 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 { - roop_start = search_link_idx; - roop_end = search_link_idx + 1; - } - sql_kinds = 0; - direct_update_kinds = 0; - 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) - ) { - if ( - spider_conn_use_handler(this, lock_mode, roop_count) && - spider_conn_need_open_handler(this, MAX_KEY, roop_count) - ) { - if ((error_num = spider_db_open_handler(this, - 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); - } - set_handler_opened(roop_count); - } - } - if (sql_kinds & SPIDER_SQL_KIND_HANDLER) - { - st_select_lex *select_lex; - longlong select_limit; - longlong offset_limit; - spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); - DBUG_PRINT("info",("spider SPIDER_SQL_KIND_HANDLER")); - result_list.semi_split_read = 1; - result_list.semi_split_read_limit = 9223372036854775807LL; - if (select_limit == 9223372036854775807LL) - { - DBUG_PRINT("info",("spider set limit to 1")); - result_list.semi_split_read_base = 1; - result_list.split_read = 1; - } else { - DBUG_PRINT("info",("spider set limit to %lld", select_limit)); - result_list.semi_split_read_base = select_limit; - result_list.split_read = select_limit; - } - } - } - DBUG_RETURN(0); -} - void ha_spider::set_error_mode() { THD *thd = ha_thd(); @@ -12578,26 +12012,6 @@ int ha_spider::print_item_type( DBUG_RETURN(0); } -bool ha_spider::support_use_handler_sql( - int use_handler -) { - uint roop_count, dbton_id; - spider_db_handler *dbton_hdl; - DBUG_ENTER("ha_spider::support_use_handler_sql"); - for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) - { - dbton_id = share->use_sql_dbton_ids[roop_count]; - dbton_hdl = dbton_handler[dbton_id]; - if ( - dbton_hdl->first_link_idx >= 0 && - !dbton_hdl->support_use_handler(use_handler) - ) { - DBUG_RETURN(FALSE); - } - } - DBUG_RETURN(TRUE); -} - int ha_spider::init_union_table_name_pos_sql() { int error_num; |