diff options
author | Nayuta Yanagisawa <nayuta.yanagisawa@hey.com> | 2022-02-01 13:25:56 +0900 |
---|---|---|
committer | Nayuta Yanagisawa <nayuta.yanagisawa@hey.com> | 2022-02-01 13:32:40 +0900 |
commit | 0e3beb1d86e0804f23cef6174e3e94e2d422e29a (patch) | |
tree | 20f8a1c05b355b200858e2c1ac35aafd8de8449e | |
parent | 79e3ee00fa61f809d3e230905beac1d2ae26d5d0 (diff) | |
download | mariadb-git-bb-10.9-MDEV-27659.tar.gz |
MDEV-27659 Spider: remove #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HSbb-10.9-MDEV-27659
-rw-r--r-- | storage/spider/ha_spider.cc | 470 | ||||
-rw-r--r-- | storage/spider/ha_spider.h | 152 | ||||
-rw-r--r-- | storage/spider/spd_db_conn.cc | 445 | ||||
-rw-r--r-- | storage/spider/spd_db_conn.h | 25 |
4 files changed, 7 insertions, 1085 deletions
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 4733802b8ea..085ec5cd5e2 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2008-2019 Kentoku Shiba - Copyright (C) 2019-2022 MariaDB corp + Copyright (C) 2019-2022 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -9771,136 +9771,6 @@ bool ha_spider::check_direct_update_sql_part( DBUG_RETURN(FALSE); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -#ifdef SPIDER_MDEV_16246 -int ha_spider::direct_update_rows_init( - List<Item> *update_fields, - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data -) -#else -int ha_spider::direct_update_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data -) -#endif -{ - st_select_lex *select_lex; - longlong select_limit; - longlong offset_limit; - 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); - } -#ifdef SPIDER_MDEV_16246 - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init( - update_fields, mode, ranges, range_count, sorted, new_data)); -#else - DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init( - mode, ranges, range_count, sorted, new_data)); -#endif - } -#endif - if (!dml_inited) - { - if (unlikely((error_num = dml_init()))) - { - DBUG_RETURN(error_num); - } - } - direct_update_init( - thd, - FALSE - ); - if (!condition) - cond_check = FALSE; - spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); - if ( - !range_count && - direct_update_fields - ) { - if ( -#if MYSQL_VERSION_ID < 50500 - !thd->variables.engine_condition_pushdown || -#else -#ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON -#else - !(thd->variables.optimizer_switch & - OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || -#endif -#endif - !select_lex || - select_lex->table_list.elements != 1 || - check_update_columns_sql_part() || - check_direct_update_sql_part(select_lex, select_limit, offset_limit) || - spider_db_append_condition(this, NULL, 0, TRUE) - ) { - DBUG_PRINT("info",("spider FALSE by condition")); - do_direct_update = FALSE; - DBUG_RETURN(HA_ERR_WRONG_COMMAND); - } - if (select_lex->order_list.elements) - { - ORDER *order; - for (order = (ORDER *) select_lex->order_list.first; order; - order = order->next) - { - if (check_item_type_sql((*order->item))) - { - DBUG_PRINT("info",("spider FALSE by order")); - do_direct_update = FALSE; - DBUG_RETURN(HA_ERR_WRONG_COMMAND); - } - } - result_list.direct_order_limit = TRUE; - } - wide_handler->trx->direct_update_count++; - DBUG_PRINT("info",("spider OK")); - DBUG_RETURN(0); - } - - DBUG_PRINT("info",("spider offset_limit=%lld", offset_limit)); - DBUG_PRINT("info",("spider mode=%u", mode)); - DBUG_PRINT("info",("spider sql_command=%u", sql_command)); - DBUG_PRINT("info",("spider do_direct_update=%s", - do_direct_update ? "TRUE" : "FALSE")); - if ( - ( - !offset_limit - ) && - do_direct_update - ) { - wide_handler->trx->direct_update_count++; - DBUG_PRINT("info",("spider OK")); - DBUG_RETURN(0); - } - DBUG_PRINT("info",("spider FALSE by default")); - do_direct_update = FALSE; - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} -#else #ifdef SPIDER_MDEV_16246 /** Perform initialization for a direct update request. @@ -10045,64 +9915,8 @@ int ha_spider::direct_update_rows_init() do_direct_update = FALSE; DBUG_RETURN(HA_ERR_WRONG_COMMAND); } -#endif #ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -#ifdef SPIDER_MDEV_16246 -int ha_spider::pre_direct_update_rows_init( - List<Item> *update_fields, - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data -) -#else -int ha_spider::pre_direct_update_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data -) -#endif -{ - int error_num; - DBUG_ENTER("ha_spider::pre_direct_update_rows_init"); - DBUG_PRINT("info",("spider this=%p", this)); - if (bulk_access_started) - { -#ifdef SPIDER_MDEV_16246 - error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init( - update_fields, mode, ranges, range_count, sorted, new_data); -#else - error_num = bulk_access_link_current->spider-> - pre_direct_update_rows_init( - mode, ranges, range_count, sorted, new_data); -#endif - 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); - } - } -#ifdef SPIDER_MDEV_16246 - pre_direct_init_result = direct_update_rows_init( - update_fields, mode, ranges, range_count, sorted, new_data); -#else - pre_direct_init_result = direct_update_rows_init( - mode, ranges, range_count, sorted, new_data); -#endif - DBUG_RETURN(pre_direct_init_result); -} -#else #ifdef SPIDER_MDEV_16246 /** Do initialization for performing parallel direct update @@ -10152,66 +9966,7 @@ int ha_spider::pre_direct_update_rows_init() DBUG_RETURN(pre_direct_init_result); } #endif -#endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::direct_update_rows( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data, - ha_rows *update_rows, - ha_rows *found_rows -) { - int error_num; - THD *thd = ha_thd(); - backup_error_status(); - DBUG_ENTER("ha_spider::direct_update_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - if (spider_param_read_only_mode(thd, share->read_only_mode)) - { - my_printf_error(ER_SPIDER_READ_ONLY_NUM, ER_SPIDER_READ_ONLY_STR, MYF(0), - 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())) || - (error_num = spider_db_direct_update(this, table, ranges, range_count, - update_rows, found_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 int ha_spider::direct_update_rows( ha_rows *update_rows, ha_rows *found_rows @@ -10263,24 +10018,8 @@ int ha_spider::direct_update_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; @@ -10292,7 +10031,6 @@ int ha_spider::pre_direct_update_rows() } #endif #endif -#endif bool ha_spider::start_bulk_delete( ) { @@ -10382,108 +10120,6 @@ bool ha_spider::check_direct_delete_sql_part( DBUG_RETURN(FALSE); } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int ha_spider::direct_delete_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted -) { - st_select_lex *select_lex; - longlong select_limit; - longlong offset_limit; - 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()))) - { - DBUG_RETURN(error_num); - } - } - direct_update_init( - thd, - FALSE - ); - if (!condition) - cond_check = FALSE; - spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); - if (!range_count) - { - if ( -#if MYSQL_VERSION_ID < 50500 - !thd->variables.engine_condition_pushdown || -#else -#ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON -#else - !(thd->variables.optimizer_switch & - OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || -#endif -#endif - !select_lex || - select_lex->table_list.elements != 1 || - check_direct_delete_sql_part(select_lex, select_limit, offset_limit) || - spider_db_append_condition(this, NULL, 0, TRUE) - ) { - DBUG_PRINT("info",("spider FALSE by condition")); - do_direct_update = FALSE; - DBUG_RETURN(HA_ERR_WRONG_COMMAND); - } - if (select_lex->order_list.elements) - { - ORDER *order; - for (order = (ORDER *) select_lex->order_list.first; order; - order = order->next) - { - if (check_item_type_sql((*order->item))) - { - DBUG_PRINT("info",("spider FALSE by order")); - do_direct_update = FALSE; - DBUG_RETURN(HA_ERR_WRONG_COMMAND); - } - } - result_list.direct_order_limit = TRUE; - } - wide_handler->trx->direct_delete_count++; - DBUG_PRINT("info",("spider OK")); - DBUG_RETURN(0); - } - - if ( - ( - !offset_limit - ) && - do_direct_update - ) { - wide_handler->trx->direct_delete_count++; - DBUG_PRINT("info",("spider OK")); - DBUG_RETURN(0); - } - DBUG_PRINT("info",("spider FALSE by default")); - do_direct_update = FALSE; - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} -#else int ha_spider::direct_delete_rows_init() { st_select_lex *select_lex; @@ -10562,40 +10198,8 @@ int ha_spider::direct_delete_rows_init() DBUG_PRINT("info",("spider OK")); DBUG_RETURN(0); } -#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; @@ -10620,64 +10224,7 @@ int ha_spider::pre_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( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - ha_rows *delete_rows -) { - int error_num; - THD *thd = ha_thd(); - backup_error_status(); - DBUG_ENTER("ha_spider::direct_delete_rows"); - DBUG_PRINT("info",("spider this=%p", this)); - if (spider_param_read_only_mode(thd, share->read_only_mode)) - { - my_printf_error(ER_SPIDER_READ_ONLY_NUM, ER_SPIDER_READ_ONLY_STR, MYF(0), - 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())) || - (error_num = spider_db_direct_delete(this, table, ranges, range_count, - 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 int ha_spider::direct_delete_rows( ha_rows *delete_rows ) { @@ -10728,22 +10275,8 @@ int ha_spider::direct_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; @@ -10754,7 +10287,6 @@ int ha_spider::pre_direct_delete_rows() } #endif #endif -#endif int ha_spider::delete_all_rows() { diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index cd847760bcf..0d440df4070 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -1,5 +1,5 @@ -/* Copyright (C) 2008-2019 Kentoku Shiba - Copyright (C) 2019-2022 MariaDB corp +/* Copyright (C) 2008, 2019 Kentoku Shiba + Copyright (C) 2019, 2022 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -560,35 +560,6 @@ public: longlong select_limit, longlong offset_limit ); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -#ifdef SPIDER_MDEV_16246 - inline int direct_update_rows_init( - List<Item> *update_fields - ) { - return direct_update_rows_init(update_fields, 2, NULL, 0, FALSE, NULL); - } - int direct_update_rows_init( - List<Item> *update_fields, - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data - ); -#else - inline int direct_update_rows_init() - { - return direct_update_rows_init(2, NULL, 0, FALSE, NULL); - } - int direct_update_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data - ); -#endif -#else #ifdef SPIDER_MDEV_16246 int direct_update_rows_init( List<Item> *update_fields @@ -596,37 +567,7 @@ public: #else int direct_update_rows_init(); #endif -#endif #ifdef HA_CAN_BULK_ACCESS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -#ifdef SPIDER_MDEV_16246 - inline int pre_direct_update_rows_init( - List<Item> *update_fields - ) { - return pre_direct_update_rows_init(update_fields, 2, NULL, 0, FALSE, NULL); - } - int pre_direct_update_rows_init( - List<Item> *update_fields, - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data - ); -#else - inline int pre_direct_update_rows_init() - { - return pre_direct_update_rows_init(2, NULL, 0, FALSE, NULL); - } - int pre_direct_update_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, - uchar *new_data - ); -#endif -#else #ifdef SPIDER_MDEV_16246 int pre_direct_update_rows_init( List<Item> *update_fields @@ -635,49 +576,14 @@ public: int pre_direct_update_rows_init(); #endif #endif -#endif -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int direct_update_rows(ha_rows *update_rows, ha_rows *found_rows) - { - return direct_update_rows(NULL, 0, FALSE, NULL, update_rows, found_rows); - } - int 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 direct_update_rows( ha_rows *update_rows, ha_rows *found_row ); -#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 -#endif bool start_bulk_delete(); int end_bulk_delete(); int delete_row( @@ -689,71 +595,17 @@ public: longlong select_limit, longlong offset_limit ); -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS - inline int direct_delete_rows_init() - { - return direct_delete_rows_init(2, NULL, 0, FALSE); - } - int direct_delete_rows_init( - uint mode, - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted - ); -#else int direct_delete_rows_init(); -#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) - { - return direct_delete_rows(NULL, 0, FALSE, delete_rows); - } int direct_delete_rows( - KEY_MULTI_RANGE *ranges, - uint range_count, - bool sorted, ha_rows *delete_rows ); -#else - int direct_delete_rows( - ha_rows *delete_rows - ); -#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 -#endif int delete_all_rows(); int truncate(); double scan_time(); diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 549279fb180..6eb3b1fcb91 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -1,5 +1,5 @@ -/* Copyright (C) 2008-2019 Kentoku Shiba - Copyright (C) 2019, 2020, MariaDB Corporation. +/* Copyright (C) 2008, 2019, Kentoku Shiba + Copyright (C) 2019, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -7086,245 +7086,6 @@ int spider_db_update( } #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int spider_db_direct_update( - ha_spider *spider, - TABLE *table, - KEY_MULTI_RANGE *ranges, - uint range_count, - ha_rows *update_rows, - ha_rows *found_rows -) { - int error_num, roop_count; - SPIDER_SHARE *share = spider->share; - SPIDER_CONN *conn; - SPIDER_RESULT_LIST *result_list = &spider->result_list; - bool counted = FALSE; - st_select_lex *select_lex; - longlong select_limit; - longlong offset_limit; - DBUG_ENTER("spider_db_direct_update"); - - spider_set_result_list_param(spider); - result_list->finish_flg = FALSE; - DBUG_PRINT("info", ("spider do_direct_update=%s", - spider->do_direct_update ? "TRUE" : "FALSE")); - DBUG_PRINT("info", ("spider direct_update_kinds=%u", - spider->direct_update_kinds)); - if ((error_num = spider->append_update_sql_part())) - DBUG_RETURN(error_num); - -/* - SQL access -> SQL remote access - !spider->do_direct_update && - (spider->sql_kinds & SPIDER_SQL_KIND_SQL) - - SQL access -> SQL remote access with dirct_update - spider->do_direct_update && - spider->direct_update_kinds == SPIDER_SQL_KIND_SQL && - spider->wide_handler->direct_update_fields - - Handlersocket access -> SQL remote access with dirct_update - spider->do_direct_update && - (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) - - Handlersocket access -> Handlersocket access - spider->do_direct_update && - (spider->direct_update_kinds & SPIDER_SQL_KIND_HS) -*/ - -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - if (!spider->do_direct_update) - { -#endif - if ( - (spider->sql_kinds & SPIDER_SQL_KIND_SQL) && - (error_num = spider->append_update_set_sql_part()) - ) { - DBUG_RETURN(error_num); - } -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - } else { - if ( - (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) && - (error_num = spider->append_direct_update_set_sql_part()) - ) { - DBUG_RETURN(error_num); - } - } -#endif - - result_list->desc_flg = FALSE; - result_list->sorted = TRUE; - if (spider->active_index == MAX_KEY) - result_list->key_info = NULL; - else - result_list->key_info = &table->key_info[spider->active_index]; - spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); - result_list->limit_num = - result_list->internal_limit >= select_limit ? - select_limit : result_list->internal_limit; - result_list->internal_offset += offset_limit; - if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) - { - if ( - (error_num = spider->append_key_where_sql_part( - (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, - (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, - SPIDER_SQL_TYPE_UPDATE_SQL)) || - (error_num = spider-> - append_key_order_for_direct_order_limit_with_alias_sql_part( - NULL, 0, SPIDER_SQL_TYPE_UPDATE_SQL)) || - (error_num = spider->append_limit_sql_part( - result_list->internal_offset, result_list->limit_num, - SPIDER_SQL_TYPE_UPDATE_SQL)) - ) { - DBUG_RETURN(error_num); - } - } - - 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) - ) { - ulong sql_type; - DBUG_PRINT("info", ("spider exec sql")); - 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 (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) - { - pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); - } - if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { - if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) - { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(error_num); - } - if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) - { - 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) - { - 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); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - if ( - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - spider->wide_handler->trx, - spider->wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, roop_count, - spider->wide_handler->trx->thd, - share); - if ( - (error_num = dbton_hdl->execute_sql( - sql_type, - conn, - -1, - &spider->need_mons[roop_count]) - ) && - (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); - if ( - error_num != ER_DUP_ENTRY && - error_num != ER_DUP_KEY && - error_num != HA_ERR_FOUND_DUPP_KEY && - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - spider->wide_handler->trx, - spider->wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(error_num); - } - 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; -#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); - DBUG_RETURN(0); -} -#else int spider_db_direct_update( ha_spider *spider, TABLE *table, @@ -7554,7 +7315,6 @@ int spider_db_direct_update( DBUG_RETURN(0); } #endif -#endif #ifdef HA_CAN_BULK_ACCESS int spider_db_bulk_direct_update( @@ -7711,206 +7471,6 @@ int spider_db_delete( } #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -int spider_db_direct_delete( - ha_spider *spider, - TABLE *table, - KEY_MULTI_RANGE *ranges, - uint range_count, - ha_rows *delete_rows -) { - int error_num, roop_count; - SPIDER_SHARE *share = spider->share; - SPIDER_CONN *conn; - SPIDER_RESULT_LIST *result_list = &spider->result_list; - bool counted = FALSE; - st_select_lex *select_lex; - longlong select_limit; - longlong offset_limit; - DBUG_ENTER("spider_db_direct_delete"); - - spider_set_result_list_param(spider); - result_list->finish_flg = FALSE; - result_list->desc_flg = FALSE; - result_list->sorted = TRUE; - if (spider->active_index == MAX_KEY) - result_list->key_info = NULL; - else - result_list->key_info = &table->key_info[spider->active_index]; - spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); - result_list->limit_num = - result_list->internal_limit >= select_limit ? - select_limit : result_list->internal_limit; - result_list->internal_offset += offset_limit; -/* - result_list->limit_num = - result_list->internal_limit >= result_list->split_read ? - result_list->split_read : result_list->internal_limit; -*/ - if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) - { - if ( - (error_num = spider->append_delete_sql_part()) || - (error_num = spider->append_from_sql_part(SPIDER_SQL_TYPE_DELETE_SQL)) - ) { - DBUG_RETURN(error_num); - } - spider->set_where_pos_sql(SPIDER_SQL_TYPE_DELETE_SQL); - if ( - (error_num = spider->append_key_where_sql_part( - (ranges && ranges->start_key.key) ? &ranges->start_key : NULL, - (ranges && ranges->end_key.key) ? &ranges->end_key : NULL, - SPIDER_SQL_TYPE_DELETE_SQL)) || - (error_num = spider-> - append_key_order_for_direct_order_limit_with_alias_sql_part( - NULL, 0, SPIDER_SQL_TYPE_DELETE_SQL)) || - (error_num = spider->append_limit_sql_part( - result_list->internal_offset, result_list->limit_num, - SPIDER_SQL_TYPE_DELETE_SQL)) - ) { - DBUG_RETURN(error_num); - } - } - - 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) - ) { - ulong sql_type; - DBUG_PRINT("info", ("spider exec sql")); - 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 (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) - { - pthread_mutex_lock(&conn->mta_conn_mutex); - SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos); - } - if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count))) - { - if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) - { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - } - DBUG_RETURN(error_num); - } - if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type)) - { - 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) - { - 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); - conn->mta_conn_mutex_lock_already = TRUE; - conn->mta_conn_mutex_unlock_later = TRUE; - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - if ( - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - spider->wide_handler->trx, - spider->wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(error_num); - } - spider_conn_set_timeout_from_share(conn, roop_count, - spider->wide_handler->trx->thd, - share); - if (dbton_hdl->execute_sql( - sql_type, - conn, - -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); - if ( - share->monitoring_kind[roop_count] && - spider->need_mons[roop_count] - ) { - error_num = spider_ping_table_mon_from_table( - spider->wide_handler->trx, - spider->wide_handler->trx->thd, - share, - roop_count, - (uint32) share->monitoring_sid[roop_count], - share->table_name, - share->table_name_length, - spider->conn_link_idx[roop_count], - NULL, - 0, - share->monitoring_kind[roop_count], - share->monitoring_limit[roop_count], - share->monitoring_flag[roop_count], - TRUE - ); - } - DBUG_RETURN(error_num); - } - 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; - } -#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; - if (spider->direct_update_kinds & SPIDER_SQL_KIND_SQL) - { - if ((error_num = spider->reset_sql_sql(SPIDER_SQL_TYPE_DELETE_SQL))) - error_num2 = error_num; - } - DBUG_RETURN(error_num2); -} -#else int spider_db_direct_delete( ha_spider *spider, TABLE *table, @@ -8103,7 +7663,6 @@ int spider_db_direct_delete( DBUG_RETURN(error_num2); } #endif -#endif int spider_db_delete_all_rows( ha_spider *spider diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h index f0821454f48..8d4af3c33d1 100644 --- a/storage/spider/spd_db_conn.h +++ b/storage/spider/spd_db_conn.h @@ -1,5 +1,5 @@ -/* Copyright (C) 2008-2020 Kentoku Shiba - Copyright (C) 2019-2020 MariaDB corp +/* Copyright (C) 2008, 2020, Kentoku Shiba + Copyright (C) 2019, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -803,23 +803,12 @@ int spider_db_update( ); #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int spider_db_direct_update( ha_spider *spider, TABLE *table, - KEY_MULTI_RANGE *ranges, - uint range_count, ha_rows *update_rows, ha_rows *found_rows ); -#else -int spider_db_direct_update( - ha_spider *spider, - TABLE *table, - ha_rows *update_rows, - ha_rows *found_rows -); -#endif #endif #ifdef HA_CAN_BULK_ACCESS @@ -842,21 +831,11 @@ int spider_db_delete( ); #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS int spider_db_direct_delete( ha_spider *spider, TABLE *table, - KEY_MULTI_RANGE *ranges, - uint range_count, ha_rows *delete_rows ); -#else -int spider_db_direct_delete( - ha_spider *spider, - TABLE *table, - ha_rows *delete_rows -); -#endif #endif int spider_db_delete_all_rows( |