diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-01 18:15:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-01 18:15:00 +0000 |
commit | a2a2e32c02643a0cec111511220227703fda1cd5 (patch) | |
tree | 69cc2b631234c2a8e026b9cd4d72676c61c594df /storage/spider/spd_db_mysql.cc | |
parent | Releasing progress-linux version 1:10.11.8-1~progress7.99u1. (diff) | |
download | mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.tar.xz mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.zip |
Merging upstream version 1:11.4.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'storage/spider/spd_db_mysql.cc')
-rw-r--r-- | storage/spider/spd_db_mysql.cc | 1039 |
1 files changed, 331 insertions, 708 deletions
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 450e1a02..8ff45022 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -307,6 +307,7 @@ bool spider_mariadb_support_direct_join( DBUG_RETURN(TRUE); } +/** Available `SPIDER_DBTON`s */ SPIDER_DBTON spider_dbton_mysql = { 0, SPIDER_DB_WRAPPER_MYSQL, @@ -806,6 +807,7 @@ SPIDER_DB_ROW *spider_db_mbase_result::fetch_row_from_tmp_table( DBUG_RETURN((SPIDER_DB_ROW *) &row); } +/* Fetches table status into `stat` */ int spider_db_mbase_result::fetch_table_status( int mode, ha_statistics &stat @@ -1907,12 +1909,10 @@ int spider_db_mbase::connect( mysql_options(db_conn, MYSQL_OPT_SSL_CA, conn->tgt_ssl_ca); mysql_options(db_conn, MYSQL_OPT_SSL_CAPATH, conn->tgt_ssl_capath); mysql_options(db_conn, MYSQL_OPT_SSL_CIPHER, conn->tgt_ssl_cipher); - if (conn->tgt_ssl_vsc) - { - my_bool verify_flg = TRUE; - mysql_options(db_conn, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, - &verify_flg); - } + } + { + my_bool verify_flg = conn->tgt_ssl_vsc != 0; + mysql_options(db_conn, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify_flg); } if (conn->tgt_default_file) @@ -5204,6 +5204,7 @@ int spider_db_mbase_util::append_sql_mode( DBUG_RETURN(0); } +/** Append `set session time_zone = ...` to a query string */ int spider_db_mbase_util::append_time_zone( spider_string *str, Time_zone *time_zone @@ -5222,6 +5223,14 @@ int spider_db_mbase_util::append_time_zone( DBUG_RETURN(0); } +/** + Append a query for self-referencing check + + The query is setting a user variable `@spider_lc$target_table_path` + to the value of `"$spider_unique_id$spider_table_path-"`, where + $target_table_path is the path to the data node table ("to"), and + $spider_table_path the path to the spider table ("from") +*/ int spider_db_mbase_util::append_loop_check( spider_string *str, SPIDER_CONN *conn @@ -7955,10 +7964,10 @@ int spider_mbase_share::discover_table_structure( SPIDER_CONN *conn; int need_mon; - if (!(conn = spider_get_conn( - spider_share, 0, spider_share->conn_keys[roop_count], trx, NULL, FALSE, - FALSE, SPIDER_CONN_KIND_MYSQL, &error_num)) - ) { + if (!(conn= spider_get_conn(spider_share, 0, + spider_share->conn_keys[roop_count], trx, NULL, + FALSE, FALSE, &error_num))) + { DBUG_RETURN(error_num); } pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); @@ -12012,23 +12021,14 @@ int spider_mbase_handler::append_from( DBUG_RETURN(0); } -int spider_mbase_handler::append_flush_tables_part( - ulong sql_type, - int link_idx, - bool lock -) { +int spider_mbase_handler::append_flush_tables_part(int link_idx, bool lock) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_flush_tables_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_flush_tables(str, link_idx, lock); DBUG_RETURN(error_num); } @@ -12056,22 +12056,14 @@ int spider_mbase_handler::append_flush_tables( DBUG_RETURN(0); } -int spider_mbase_handler::append_optimize_table_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_optimize_table_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_optimize_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_optimize_table(str, link_idx); DBUG_RETURN(error_num); } @@ -12102,22 +12094,14 @@ int spider_mbase_handler::append_optimize_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_analyze_table_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_analyze_table_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_analyze_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_analyze_table(str, link_idx); DBUG_RETURN(error_num); } @@ -12148,23 +12132,15 @@ int spider_mbase_handler::append_analyze_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_repair_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt -) { +int spider_mbase_handler::append_repair_table_part(int link_idx, + HA_CHECK_OPT *check_opt) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_repair_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_repair_table(str, link_idx, check_opt); DBUG_RETURN(error_num); } @@ -12214,23 +12190,15 @@ int spider_mbase_handler::append_repair_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_check_table_part( - ulong sql_type, - int link_idx, - HA_CHECK_OPT* check_opt -) { +int spider_mbase_handler::append_check_table_part(int link_idx, + HA_CHECK_OPT *check_opt) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_check_table_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_check_table(str, link_idx, check_opt); DBUG_RETURN(error_num); } @@ -12279,22 +12247,14 @@ int spider_mbase_handler::append_check_table( DBUG_RETURN(0); } -int spider_mbase_handler::append_enable_keys_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_enable_keys_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_enable_keys_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_enable_keys(str, link_idx); DBUG_RETURN(error_num); } @@ -12320,22 +12280,14 @@ int spider_mbase_handler::append_enable_keys( DBUG_RETURN(0); } -int spider_mbase_handler::append_disable_keys_part( - ulong sql_type, - int link_idx -) { +int spider_mbase_handler::append_disable_keys_part(int link_idx) +{ int error_num; spider_string *str; DBUG_ENTER("spider_mbase_handler::append_disable_keys_part"); DBUG_PRINT("info",("spider this=%p", this)); - switch (sql_type) - { - case SPIDER_SQL_TYPE_OTHER_SQL: - str = &spider->result_list.sqls[link_idx]; - break; - default: - DBUG_RETURN(0); - } + + str= &spider->result_list.sqls[link_idx]; error_num = append_disable_keys(str, link_idx); DBUG_RETURN(error_num); } @@ -12692,14 +12644,9 @@ int spider_mbase_handler::mk_bulk_tmp_table_and_bulk_start() DBUG_PRINT("info",("spider this=%p", this)); if (!upd_tmp_tbl) { -#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor LEX_CSTRING field_name = {STRING_WITH_LEN("a")}; if (!(upd_tmp_tbl = spider_mk_sys_tmp_table( thd, table, &upd_tmp_tbl_prm, &field_name, update_sql.charset()))) -#else - if (!(upd_tmp_tbl = spider_mk_sys_tmp_table( - thd, table, &upd_tmp_tbl_prm, "a", update_sql.charset()))) -#endif { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } @@ -13176,6 +13123,90 @@ int spider_mbase_handler::sts_mode_exchange( DBUG_RETURN(sts_mode); } +/** Set the session lock wait time out */ +static int spider_set_lock_wait_timeout(uint seconds, SPIDER_CONN *conn, + int *need_mon) +{ + char query[512]; + int error_num; + DBUG_ENTER("spider_db_set_lock_wait_timeout"); + size_t query_len = + my_snprintf(query, sizeof(query), + "set @old_lock_wait_timeout=@@session.lock_wait_timeout;" + "set session lock_wait_timeout=%d;", + seconds); + DEBUG_SYNC(conn->thd, "spider_set_lock_wait_timeout_before_query"); + if (spider_db_query(conn, query, query_len, -1, need_mon)) + DBUG_RETURN(spider_db_errorno(conn)); + spider_db_result *result; + do { + st_spider_db_request_key request_key= {1, 1, NULL, 1, NULL}; + if ((result = conn->db_conn->store_result(NULL, &request_key, + &error_num))) + { + result->free_result(); + delete result; + } else if ((error_num = conn->db_conn->get_errno())) + break; + } while (!(error_num = conn->db_conn->next_result())); + DBUG_RETURN(0); +} + +/** Reset the session lock wait time out */ +int spider_db_mbase::reset_lock_wait_timeout() +{ + const LEX_CSTRING query = {STRING_WITH_LEN( + "set session lock_wait_timeout=@old_lock_wait_timeout;")}; + int error_num; + DBUG_ENTER("spider_db_set_lock_wait_timeout"); + if ((error_num = exec_query(query.str, query.length, -1))) + DBUG_RETURN(error_num); + spider_db_result *result; + do { + st_spider_db_request_key request_key= {1, 1, NULL, 1, NULL}; + if ((result = conn->db_conn->store_result(NULL, &request_key, + &error_num))) + { + result->free_result(); + delete result; + } else if ((error_num = conn->db_conn->get_errno())) + break; + } while (!(error_num= conn->db_conn->next_result())); + DBUG_RETURN(0); +} + +/** FIXME: refactor more functions to use spider_setup_for_query() and +spider_teardown_after_query(). */ +void spider_setup_for_query(ha_spider *spider, SPIDER_CONN *conn, int link_idx) +{ + 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); + conn->mta_conn_mutex_lock_already= TRUE; + conn->mta_conn_mutex_unlock_later= TRUE; + conn->disable_connect_retry= TRUE; +} + +int spider_teardown_after_query(SPIDER_CONN *conn, int error_num, bool clear) +{ + 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 (clear) + { + SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); + pthread_mutex_unlock(&conn->mta_conn_mutex); + } + return error_num; +} +/** + Executes show table status query and stores results in share->stat +*/ int spider_mbase_handler::show_table_status( int link_idx, int sts_mode, @@ -13185,329 +13216,137 @@ 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]); + const 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) + spider_setup_for_query(spider, conn, link_idx); + 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)) || + (error_num = spider_set_lock_wait_timeout( + 1, conn, &spider->need_mons[link_idx])) || + /* Executes the `show table status` query */ + (spider_db_query( + conn, + 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)))) { - 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); - 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[0 + pos].ptr(), - mysql_share->show_table_status[0 + 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 + 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_RETURN(spider_teardown_after_query(conn, error_num, true)); + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + DBUG_RETURN(spider_teardown_after_query(conn, error_num, true)); + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, + share); + if ((error_num = + spider_set_lock_wait_timeout(1, conn, &spider->need_mons[link_idx]))) + DBUG_RETURN(spider_teardown_after_query(conn, error_num, true)); + if (spider_db_query( + conn, + mysql_share->show_table_status[pos].ptr(), + mysql_share->show_table_status[pos].length(), + -1, + &spider->need_mons[link_idx]) ) { - /* 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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[0 + pos].ptr(), - mysql_share->show_table_status[0 + 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); + spider_teardown_after_query(conn, 0, false); + DBUG_RETURN(spider_db_errorno(conn)); } - } - 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()) - { - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); - } - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + } else + DBUG_RETURN(spider_teardown_after_query(conn, error_num, true)); + } + st_spider_db_request_key request_key = { + spider->wide_handler->trx->spider_thread_id, + spider->wide_handler->trx->thd->query_id, spider, 1, NULL}; + if (spider_param_dry_access()) + DBUG_RETURN(spider_teardown_after_query(conn, 0, true)); + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + { + if (sts_mode == 1) /* get from status table */ { - 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) - { - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(error_num); - } - else if ((error_num = spider_db_errorno(conn))) + DBUG_RETURN(spider_teardown_after_query(conn, error_num, true)); + spider_teardown_after_query(conn, 0, false); + if ((error_num = spider_db_errorno(conn))) DBUG_RETURN(error_num); - else { - my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM, + else + { + 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()); + mysql_share->table_names_str[spider->conn_link_idx[link_idx]].ptr()); DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_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; - 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, - 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); - } - } 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); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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()) - { - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - pthread_mutex_unlock(&conn->mta_conn_mutex); - DBUG_RETURN(0); - } - if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num))) + } else /* get from information schema */ { - 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))) + spider_teardown_after_query(conn, error_num, false); + if (error_num || (error_num= spider_db_errorno(conn))) DBUG_RETURN(error_num); else DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE); } - 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; - 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, - share->stat - ); - auto_increment_value = share->stat.auto_increment_value; - res->free_result(); - delete res; - if (error_num) + } + spider_teardown_after_query(conn, 0, true); + /* Fetches query results into share->stat. */ + 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) { - 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); + 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))) { + ((spider_db_mbase *) conn->db_conn)->reset_lock_wait_timeout(); + if (error_num == ER_LOCK_WAIT_TIMEOUT) + { + error_num = ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_NUM; + my_printf_error( + ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_NUM, + ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_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(error_num); } + if ((error_num = + ((spider_db_mbase *) conn->db_conn)->reset_lock_wait_timeout())) + 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; @@ -13534,314 +13373,105 @@ int spider_mbase_handler::show_index( SPIDER_SHARE *share = spider->share; TABLE *table = spider->get_table(); SPIDER_DB_RESULT *res; - int roop_count; - longlong *tmp_cardinality; - uint pos = (2 * spider->conn_link_idx[link_idx]); + int field; + longlong *tmp_crd; + const 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) + spider_setup_for_query(spider, conn, link_idx); + 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)) || + (error_num = + spider_set_lock_wait_timeout(1, conn, &spider->need_mons[link_idx])) || + (spider_db_query( + conn, + mysql_share->show_index[pos].ptr(), + mysql_share->show_index[pos].length(), + -1, + &spider->need_mons[link_idx]) && + (error_num = spider_db_errorno(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); - 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[0 + pos].ptr(), - mysql_share->show_index[0 + 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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[0 + pos].ptr(), - mysql_share->show_index[0 + 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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 (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM && + !conn->disable_reconnect) { - 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); - } - } 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); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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; - SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos); - 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)) + /* retry */ + if ((error_num = spider_db_ping(spider, conn, link_idx))) + DBUG_RETURN(spider_teardown_after_query(conn, error_num, true)); + if ((error_num = spider_db_set_names(spider, conn, link_idx))) + DBUG_RETURN(spider_teardown_after_query(conn, error_num, true)); + spider_conn_set_timeout_from_share(conn, link_idx, + spider->wide_handler->trx->thd, + share); + if ((error_num = + spider_set_lock_wait_timeout(1, conn, &spider->need_mons[link_idx]))) + DBUG_RETURN(spider_teardown_after_query(conn, error_num, true)); + if (spider_db_query( + conn, + mysql_share->show_index[pos].ptr(), + mysql_share->show_index[pos].length(), + -1, + &spider->need_mons[link_idx])) { - DBUG_PRINT("info", - ("spider uninitialized column cardinality id=%d", roop_count)); - *tmp_cardinality = -1; + spider_teardown_after_query(conn, 0, false); + DBUG_RETURN(spider_db_errorno(conn)); } - } - if (res) - { - res->free_result(); - delete res; - } - if (error_num) + } else + DBUG_RETURN(spider_teardown_after_query(conn, error_num, true)); + } + st_spider_db_request_key request_key = { + spider->wide_handler->trx->spider_thread_id, + spider->wide_handler->trx->thd->query_id, spider, 1, NULL}; + /* no record is ok */ + if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)) && + (error_num || (error_num = spider_db_errorno(conn)))) + DBUG_RETURN(spider_teardown_after_query(conn, error_num, true)); + spider_teardown_after_query(conn, 0, true); + if (res) + error_num = res->fetch_table_cardinality( + crd_mode, table, share->cardinality, share->cardinality_upd, + share->bitmap_size); + for (field = 0, tmp_crd = share->cardinality; + field < (int) table->s->fields; + field++, tmp_crd++) + { + if (!spider_bit_is_set(share->cardinality_upd, field)) { - 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_PRINT("info", + ("spider uninitialized column cardinality id=%d", field)); + *tmp_crd = -1; } } - DBUG_RETURN(0); + if (res) + { + res->free_result(); + delete res; + } + 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; + } + if (!error_num) + error_num = ((spider_db_mbase *) conn->db_conn)->reset_lock_wait_timeout(); + else + ((spider_db_mbase *) conn->db_conn)->reset_lock_wait_timeout(); + DBUG_RETURN(error_num); } int spider_mbase_handler::simple_action( @@ -14345,8 +13975,7 @@ int spider_mbase_handler::disable_keys( DBUG_ENTER("spider_mbase_handler::disable_keys"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_disable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_disable_keys_part(link_idx))) { DBUG_RETURN(error_num); } @@ -14404,8 +14033,7 @@ int spider_mbase_handler::enable_keys( DBUG_ENTER("spider_mbase_handler::enable_keys"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_enable_keys_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_enable_keys_part(link_idx))) { DBUG_RETURN(error_num); } @@ -14464,8 +14092,7 @@ int spider_mbase_handler::check_table( DBUG_ENTER("spider_mbase_handler::check_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_check_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx, check_opt))) + if ((error_num= append_check_table_part(link_idx, check_opt))) { DBUG_RETURN(error_num); } @@ -14524,8 +14151,7 @@ int spider_mbase_handler::repair_table( DBUG_ENTER("spider_mbase_handler::repair_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_repair_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx, check_opt))) + if ((error_num= append_repair_table_part(link_idx, check_opt))) { DBUG_RETURN(error_num); } @@ -14583,8 +14209,7 @@ int spider_mbase_handler::analyze_table( DBUG_ENTER("spider_mbase_handler::analyze_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_analyze_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_analyze_table_part(link_idx))) { DBUG_RETURN(error_num); } @@ -14642,8 +14267,7 @@ int spider_mbase_handler::optimize_table( DBUG_ENTER("spider_mbase_handler::optimize_table"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_optimize_table_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx))) + if ((error_num= append_optimize_table_part(link_idx))) { DBUG_RETURN(error_num); } @@ -14702,8 +14326,7 @@ int spider_mbase_handler::flush_tables( DBUG_ENTER("spider_mbase_handler::flush_tables"); DBUG_PRINT("info",("spider this=%p", this)); str->length(0); - if ((error_num = append_flush_tables_part(SPIDER_SQL_TYPE_OTHER_HS, - link_idx, lock))) + if ((error_num= append_flush_tables_part(link_idx, lock))) { DBUG_RETURN(error_num); } |