MDEV-28526 Spider: remove conn_kind member variables

The conn_kind, which stands for "connection kind", is no longer useful
because the HandlerSocket support is deleted and Spider now has only
one connection kind, SPIDER_CONN_KIND_MYSQL. Remove conn_kind and
related code.

Signed-off-by: Yuchen Pei <yuchen.pei@mariadb.com>
Reviewed-by: Nayuta Yanagisawa <nayuta.yanagisawa@mariadb.com>
This commit is contained in:
Yuchen Pei 2022-12-01 17:30:10 +11:00
parent 1128b54aa4
commit 1be861c582
No known key found for this signature in database
GPG key ID: 3DD1B35105743563
14 changed files with 58 additions and 133 deletions

View file

@ -238,7 +238,6 @@ int ha_spider::open(
DBUG_PRINT("info",("spider this=%p", this));
dup_key_idx = (uint) -1;
conn_kinds = SPIDER_CONN_KIND_MYSQL;
table->file->get_no_parts("", &part_num);
if (part_num)
{
@ -590,22 +589,7 @@ int ha_spider::check_access_kind_for_connection(
int error_num, roop_count;
DBUG_ENTER("ha_spider::check_access_kind_for_connection");
DBUG_PRINT("info",("spider this=%p", this));
conn_kinds = 0;
switch (wide_handler->sql_command)
{
case SQLCOM_UPDATE:
case SQLCOM_UPDATE_MULTI:
case SQLCOM_DELETE:
case SQLCOM_DELETE_MULTI:
default:
conn_kinds |= SPIDER_CONN_KIND_MYSQL;
for (roop_count = 0; roop_count < (int) share->link_count; roop_count++)
{
conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL;
}
break;
}
if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE)))
if ((error_num= spider_check_trx_and_get_conn(thd, this)))
{
DBUG_RETURN(error_num);
}
@ -1037,8 +1021,6 @@ int ha_spider::reset()
for (roop_count = share->link_count - 1; roop_count >= 0; roop_count--)
{
result_list.update_sqls[roop_count].length(0);
conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL;
}
result_list.bulk_update_mode = 0;
result_list.bulk_update_size = 0;
@ -1064,7 +1046,6 @@ int ha_spider::reset()
result_list.use_union = FALSE;
result_list.use_both_key = FALSE;
pt_clone_last_searcher = NULL;
conn_kinds = SPIDER_CONN_KIND_MYSQL;
use_index_merge = FALSE;
init_rnd_handler = FALSE;
if (multi_range_keys)
@ -6682,8 +6663,7 @@ int ha_spider::info(
pthread_mutex_lock(&share->sts_mutex);
if (difftime(tmp_time, share->sts_get_time) >= sts_interval)
{
if ((error_num = spider_check_trx_and_get_conn(ha_thd(), this,
FALSE)))
if ((error_num= spider_check_trx_and_get_conn(ha_thd(), this)))
{
pthread_mutex_unlock(&share->sts_mutex);
if (!share->sts_init)
@ -7268,7 +7248,7 @@ int ha_spider::check_crd()
}
if (crd_mode == 3)
crd_mode = 1;
if ((error_num = spider_check_trx_and_get_conn(ha_thd(), this, FALSE)))
if ((error_num= spider_check_trx_and_get_conn(ha_thd(), this)))
{
DBUG_RETURN(check_error_mode(error_num));
}
@ -8482,7 +8462,7 @@ int ha_spider::truncate()
DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM);
}
wide_handler->sql_command = SQLCOM_TRUNCATE;
if ((error_num = spider_check_trx_and_get_conn(thd, this, FALSE)))
if ((error_num= spider_check_trx_and_get_conn(thd, this)))
{
DBUG_RETURN(error_num);
}
@ -12057,8 +12037,7 @@ int ha_spider::append_lock_tables_list()
DBUG_PRINT("info",("spider lock_table_type=%u",
wide_handler->lock_table_type));
if ((error_num = spider_check_trx_and_get_conn(wide_handler->trx->thd, this,
FALSE)))
if ((error_num= spider_check_trx_and_get_conn(wide_handler->trx->thd, this)))
{
DBUG_RETURN(error_num);
}

View file

@ -60,8 +60,6 @@ public:
const char *mem_calc_file_name;
ulong mem_calc_line_no;
ulonglong *connection_ids;
uint conn_kinds;
uint *conn_kind;
char *conn_keys_first_ptr;
char **conn_keys;
SPIDER_CONN **conns;

View file

@ -108,7 +108,6 @@ uchar *spider_conn_get_key(
) {
DBUG_ENTER("spider_conn_get_key");
*length = conn->conn_key_length;
DBUG_PRINT("info",("spider conn_kind=%u", conn->conn_kind));
#ifdef DBUG_TRACE
spider_print_keys(conn->conn_key, conn->conn_key_length);
#endif
@ -382,7 +381,6 @@ SPIDER_CONN *spider_create_conn(
ha_spider *spider,
int link_idx,
int base_link_idx,
uint conn_kind,
int *error_num
) {
int *need_mon;
@ -595,7 +593,6 @@ SPIDER_CONN *spider_create_conn(
conn->semi_trx_isolation_chk = FALSE;
conn->semi_trx_chk = FALSE;
conn->link_idx = base_link_idx;
conn->conn_kind = conn_kind;
conn->conn_need_mon = need_mon;
if (spider)
conn->need_mon = &spider->need_mons[base_link_idx];
@ -682,13 +679,11 @@ SPIDER_CONN *spider_get_conn(
ha_spider *spider,
bool another,
bool thd_chg,
uint conn_kind,
int *error_num
) {
SPIDER_CONN *conn = NULL;
int base_link_idx = link_idx;
DBUG_ENTER("spider_get_conn");
DBUG_PRINT("info",("spider conn_kind=%u", conn_kind));
if (spider)
link_idx = spider->conn_link_idx[base_link_idx];
@ -727,7 +722,8 @@ SPIDER_CONN *spider_get_conn(
pthread_mutex_unlock(&spider_conn_mutex);
if (spider_param_max_connections())
{ /* enable connection pool */
conn = spider_get_conn_from_idle_connection(share, link_idx, conn_key, spider, conn_kind, base_link_idx, error_num);
conn= spider_get_conn_from_idle_connection(
share, link_idx, conn_key, spider, base_link_idx, error_num);
/* failed get conn, goto error */
if (!conn)
goto error;
@ -736,8 +732,8 @@ SPIDER_CONN *spider_get_conn(
else
{ /* did not enable conncetion pool , create_conn */
DBUG_PRINT("info",("spider create new conn"));
if (!(conn = spider_create_conn(share, spider, link_idx,
base_link_idx, conn_kind, error_num)))
if (!(conn= spider_create_conn(share, spider, link_idx,
base_link_idx, error_num)))
goto error;
*conn->conn_key = *conn_key;
if (spider)
@ -761,8 +757,8 @@ SPIDER_CONN *spider_get_conn(
} else {
DBUG_PRINT("info",("spider create new conn"));
/* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */
if (!(conn = spider_create_conn(share, spider, link_idx, base_link_idx,
conn_kind, error_num)))
if (!(conn= spider_create_conn(share, spider, link_idx, base_link_idx,
error_num)))
goto error;
*conn->conn_key = *conn_key;
if (spider)
@ -885,13 +881,10 @@ int spider_check_and_get_casual_read_conn(
char first_byte_bak = *spider->conn_keys[link_idx];
*spider->conn_keys[link_idx] =
'0' + spider->result_list.casual_read[link_idx];
if (
!(spider->conns[link_idx] =
spider_get_conn(spider->share, link_idx,
spider->conn_keys[link_idx], spider->wide_handler->trx,
spider, FALSE, TRUE, SPIDER_CONN_KIND_MYSQL,
&error_num))
) {
if (!(spider->conns[link_idx]= spider_get_conn(
spider->share, link_idx, spider->conn_keys[link_idx],
spider->wide_handler->trx, spider, FALSE, TRUE, &error_num)))
{
*spider->conn_keys[link_idx] = first_byte_bak;
DBUG_RETURN(error_num);
}
@ -3010,9 +3003,8 @@ void *spider_bg_sts_action(
if (!conns[spider.search_link_idx])
{
spider_get_conn(share, spider.search_link_idx,
share->conn_keys[spider.search_link_idx],
trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
&error_num);
share->conn_keys[spider.search_link_idx], trx,
&spider, FALSE, FALSE, &error_num);
conns[spider.search_link_idx]->error_mode = 0;
/*
if (
@ -3335,9 +3327,8 @@ void *spider_bg_crd_action(
if (!conns[spider.search_link_idx])
{
spider_get_conn(share, spider.search_link_idx,
share->conn_keys[spider.search_link_idx],
trx, &spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
&error_num);
share->conn_keys[spider.search_link_idx], trx,
&spider, FALSE, FALSE, &error_num);
conns[spider.search_link_idx]->error_mode = 0;
/*
if (
@ -3904,7 +3895,6 @@ SPIDER_CONN* spider_get_conn_from_idle_connection(
int link_idx,
char *conn_key,
ha_spider *spider,
uint conn_kind,
int base_link_idx,
int *error_num
)
@ -3992,7 +3982,8 @@ SPIDER_CONN* spider_get_conn_from_idle_connection(
if (ip_port_conn)
pthread_mutex_unlock(&ip_port_conn->mutex);
DBUG_PRINT("info",("spider create new conn"));
if (!(conn = spider_create_conn(share, spider, link_idx, base_link_idx, conn_kind, error_num)))
if (!(conn= spider_create_conn(share, spider, link_idx, base_link_idx,
error_num)))
DBUG_RETURN(conn);
*conn->conn_key = *conn_key;
if (spider)

View file

@ -84,7 +84,6 @@ SPIDER_CONN *spider_create_conn(
ha_spider *spider,
int link_id,
int base_link_id,
uint conn_kind,
int *error_num
);
@ -96,7 +95,6 @@ SPIDER_CONN *spider_get_conn(
ha_spider *spider,
bool another,
bool thd_chg,
uint conn_kind,
int *error_num
);
@ -397,7 +395,6 @@ SPIDER_CONN* spider_get_conn_from_idle_connection
int link_idx,
char *conn_key,
ha_spider *spider,
uint conn_kind,
int base_link_idx,
int *error_num
);

View file

@ -593,11 +593,10 @@ int spider_udf_get_copy_tgt_conns(
while (table_conn)
{
share = table_conn->share;
if (
!(table_conn->conn = spider_get_conn(
share, 0, share->conn_keys[0], trx, NULL, FALSE, FALSE,
SPIDER_CONN_KIND_MYSQL, &error_num))
) {
if (!(table_conn->conn=
spider_get_conn(share, 0, share->conn_keys[0], trx, NULL,
FALSE, FALSE, &error_num)))
{
my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), share->server_names[0]);
DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE);
}

View file

@ -80,7 +80,7 @@ int spider_db_connect(
THD* thd = current_thd;
longlong connect_retry_interval;
DBUG_ENTER("spider_db_connect");
DBUG_ASSERT(conn->conn_kind != SPIDER_CONN_KIND_MYSQL || conn->need_mon);
DBUG_ASSERT(conn->need_mon);
DBUG_PRINT("info",("spider link_idx=%d", link_idx));
DBUG_PRINT("info",("spider conn=%p", conn));
@ -240,7 +240,6 @@ void spider_db_disconnect(
) {
DBUG_ENTER("spider_db_disconnect");
DBUG_PRINT("info",("spider conn=%p", conn));
DBUG_PRINT("info",("spider conn->conn_kind=%u", conn->conn_kind));
if (conn->db_conn->is_connected())
{
conn->db_conn->disconnect();

View file

@ -168,8 +168,6 @@ typedef st_spider_result SPIDER_RESULT;
#define SPIDER_SQL_LOP_CHK_PRM_PRF_STR "spider_lc_"
#define SPIDER_SQL_LOP_CHK_PRM_PRF_LEN (sizeof(SPIDER_SQL_LOP_CHK_PRM_PRF_STR) - 1)
#define SPIDER_CONN_KIND_MYSQL (1 << 0)
#define SPIDER_SQL_TYPE_SELECT_SQL (1 << 0)
#define SPIDER_SQL_TYPE_INSERT_SQL (1 << 1)
#define SPIDER_SQL_TYPE_UPDATE_SQL (1 << 2)

View file

@ -8217,10 +8217,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);

View file

@ -551,7 +551,6 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
conn->semi_trx_isolation = -2;
conn->semi_trx_isolation_chk = FALSE;
conn->semi_trx_chk = FALSE;
conn->conn_kind = SPIDER_CONN_KIND_MYSQL;
if (mysql_mutex_init(spd_key_mutex_mta_conn, &conn->mta_conn_mutex,
MY_MUTEX_INIT_FAST))
@ -697,7 +696,6 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn(
conn->queued_ping = FALSE;
DBUG_PRINT("info",("spider conn=%p", conn));
DBUG_PRINT("info",("spider conn->conn_kind=%u", conn->conn_kind));
DBUG_RETURN(conn);
error:

View file

@ -327,7 +327,6 @@ typedef struct st_spider_conn_loop_check SPIDER_CONN_LOOP_CHECK;
/* database connection */
typedef struct st_spider_conn
{
uint conn_kind;
char *conn_key;
uint conn_key_length;
my_hash_value_type conn_key_hash_value;

View file

@ -594,11 +594,9 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn(
) {
SPIDER_CONN *conn;
DBUG_ENTER("spider_get_ping_table_tgt_conn");
if (
!(conn = spider_get_conn(
share, 0, share->conn_keys[0], trx, NULL, FALSE, FALSE,
SPIDER_CONN_KIND_MYSQL, error_num))
) {
if (!(conn= spider_get_conn(share, 0, share->conn_keys[0], trx, NULL, FALSE,
FALSE, error_num)))
{
my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0),
share->server_names[0]);
*error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE;

View file

@ -4842,7 +4842,6 @@ SPIDER_SHARE *spider_get_share(
&spider->conn_link_idx, sizeof(uint) * share->link_count,
&spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size,
&spider->connection_ids, sizeof(ulonglong) * share->link_count,
&spider->conn_kind, sizeof(uint) * share->link_count,
&spider->db_request_id, sizeof(ulonglong) * share->link_count,
&spider->db_request_phase, sizeof(uchar) * share->link_bitmap_size,
&spider->need_mons, sizeof(int) * share->link_count,
@ -4875,7 +4874,6 @@ SPIDER_SHARE *spider_get_share(
tmp_name += share->conn_keys_lengths[roop_count] + 1;
result_list->upd_tmp_tbl_prms[roop_count].init();
result_list->upd_tmp_tbl_prms[roop_count].field_count = 1;
spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL;
}
spider_trx_set_link_idx_for_all(spider);
@ -4930,7 +4928,6 @@ SPIDER_SHARE *spider_get_share(
!(spider->conns[roop_count] =
spider_get_conn(share, roop_count, spider->conn_keys[roop_count],
spider->wide_handler->trx, spider, FALSE, TRUE,
SPIDER_CONN_KIND_MYSQL,
error_num))
) {
if (
@ -5297,7 +5294,6 @@ SPIDER_SHARE *spider_get_share(
&spider->conn_link_idx, sizeof(uint) * share->link_count,
&spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size,
&spider->connection_ids, sizeof(ulonglong) * share->link_count,
&spider->conn_kind, sizeof(uint) * share->link_count,
&spider->db_request_id, sizeof(ulonglong) * share->link_count,
&spider->db_request_phase, sizeof(uchar) * share->link_bitmap_size,
&spider->need_mons, sizeof(int) * share->link_count,
@ -5327,7 +5323,6 @@ SPIDER_SHARE *spider_get_share(
tmp_name += share->conn_keys_lengths[roop_count] + 1;
result_list->upd_tmp_tbl_prms[roop_count].init();
result_list->upd_tmp_tbl_prms[roop_count].field_count = 1;
spider->conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL;
}
spider_trx_set_link_idx_for_all(spider);
@ -5379,7 +5374,6 @@ SPIDER_SHARE *spider_get_share(
!(spider->conns[roop_count] =
spider_get_conn(share, roop_count, spider->conn_keys[roop_count],
spider->wide_handler->trx, spider, FALSE, TRUE,
SPIDER_CONN_KIND_MYSQL,
error_num))
) {
if (
@ -6034,11 +6028,9 @@ int spider_open_all_tables(
}
/* create conn */
if (
!(conn = spider_get_conn(
&tmp_share, 0, tmp_share.conn_keys[0], trx, NULL, FALSE, FALSE,
SPIDER_CONN_KIND_MYSQL, &error_num))
) {
if (!(conn= spider_get_conn(&tmp_share, 0, tmp_share.conn_keys[0], trx,
NULL, FALSE, FALSE, &error_num)))
{
spider_sys_index_end(table_tables);
spider_close_sys_table(thd, table_tables,
&open_tables_backup, TRUE);
@ -6149,11 +6141,9 @@ int spider_open_all_tables(
}
/* create another conn */
if (
(!(conn = spider_get_conn(
&tmp_share, 0, tmp_share.conn_keys[0], trx, spider, TRUE, FALSE,
SPIDER_CONN_KIND_MYSQL, &error_num)))
) {
if ((!(conn= spider_get_conn(&tmp_share, 0, tmp_share.conn_keys[0], trx,
spider, TRUE, FALSE, &error_num))))
{
spider_free_tmp_dbton_handler(spider);
spider_free(trx, share, MYF(0));
delete spider;
@ -9176,9 +9166,8 @@ void *spider_table_bg_sts_action(
if (!conns[spider->search_link_idx])
{
spider_get_conn(share, spider->search_link_idx,
share->conn_keys[spider->search_link_idx],
trx, spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
&error_num);
share->conn_keys[spider->search_link_idx], trx,
spider, FALSE, FALSE, &error_num);
if (conns[spider->search_link_idx])
{
conns[spider->search_link_idx]->error_mode = 0;
@ -9322,9 +9311,8 @@ void *spider_table_bg_crd_action(
if (!conns[spider->search_link_idx])
{
spider_get_conn(share, spider->search_link_idx,
share->conn_keys[spider->search_link_idx],
trx, spider, FALSE, FALSE, SPIDER_CONN_KIND_MYSQL,
&error_num);
share->conn_keys[spider->search_link_idx], trx,
spider, FALSE, FALSE, &error_num);
if (conns[spider->search_link_idx])
{
conns[spider->search_link_idx]->error_mode = 0;

View file

@ -2716,13 +2716,11 @@ int spider_internal_xa_commit_by_xid(
goto error;
}
if (
!(conn = spider_get_conn(
&tmp_share, 0, tmp_share.conn_keys[0], trx, NULL, FALSE, FALSE,
SPIDER_CONN_KIND_MYSQL, &error_num)) &&
(force_commit == 0 ||
(force_commit == 1 && error_num != ER_XAER_NOTA))
) {
if (!(conn= spider_get_conn(&tmp_share, 0, tmp_share.conn_keys[0], trx,
NULL, FALSE, FALSE, &error_num)) &&
(force_commit == 0 ||
(force_commit == 1 && error_num != ER_XAER_NOTA)))
{
spider_sys_index_end(table_xa_member);
spider_free_tmp_share_alloc(&tmp_share);
free_root(&mem_root, MYF(0));
@ -2945,13 +2943,11 @@ int spider_internal_xa_rollback_by_xid(
goto error;
}
if (
!(conn = spider_get_conn(
&tmp_share, 0, tmp_share.conn_keys[0], trx, NULL, FALSE, FALSE,
SPIDER_CONN_KIND_MYSQL, &error_num)) &&
(force_commit == 0 ||
(force_commit == 1 && error_num != ER_XAER_NOTA))
) {
if (!(conn= spider_get_conn(&tmp_share, 0, tmp_share.conn_keys[0], trx,
NULL, FALSE, FALSE, &error_num)) &&
(force_commit == 0 ||
(force_commit == 1 && error_num != ER_XAER_NOTA)))
{
spider_sys_index_end(table_xa_member);
spider_free_tmp_share_alloc(&tmp_share);
free_root(&mem_root, MYF(0));
@ -3441,11 +3437,8 @@ int spider_end_trx(
DBUG_RETURN(error_num);
}
int spider_check_trx_and_get_conn(
THD *thd,
ha_spider *spider,
bool use_conn_kind
) {
int spider_check_trx_and_get_conn(THD *thd, ha_spider *spider)
{
int error_num, roop_count, search_link_idx;
SPIDER_TRX *trx;
SPIDER_SHARE *share = spider->share;
@ -3545,22 +3538,16 @@ int spider_check_trx_and_get_conn(
spider->conn_link_idx, roop_count, share->link_count,
SPIDER_LINK_STATUS_RECOVERY)
) {
uint tgt_conn_kind = (use_conn_kind ? spider->conn_kind[roop_count] :
SPIDER_CONN_KIND_MYSQL);
if (roop_count == spider->search_link_idx)
search_link_idx_is_checked = TRUE;
if (
tgt_conn_kind == SPIDER_CONN_KIND_MYSQL &&
!spider->conns[roop_count]
) {
if (!spider->conns[roop_count])
{
*spider->conn_keys[roop_count] = first_byte;
if (
!(conn =
spider_get_conn(share, roop_count,
spider->conn_keys[roop_count], trx,
spider, FALSE, TRUE,
use_conn_kind ? spider->conn_kind[roop_count] :
SPIDER_CONN_KIND_MYSQL,
&error_num))
) {
if (
@ -3640,8 +3627,6 @@ int spider_check_trx_and_get_conn(
spider_get_conn(share, roop_count,
spider->conn_keys[roop_count], trx,
spider, FALSE, TRUE,
use_conn_kind ? spider->conn_kind[roop_count] :
SPIDER_CONN_KIND_MYSQL,
&error_num))
) {
if (

View file

@ -227,11 +227,7 @@ int spider_end_trx(
SPIDER_CONN *conn
);
int spider_check_trx_and_get_conn(
THD *thd,
ha_spider *spider,
bool use_conn_kind
);
int spider_check_trx_and_get_conn(THD *thd, ha_spider *spider);
THD *spider_create_tmp_thd();