Skip to content

Commit

Permalink
MDEV-28526 Spider: remove conn_kind member variables
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mariadb-YuchenPei committed Dec 23, 2022
1 parent 1128b54 commit 1be861c
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 133 deletions.
31 changes: 5 additions & 26 deletions storage/spider/ha_spider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions storage/spider/ha_spider.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class ha_spider final : public handler
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;
Expand Down
41 changes: 16 additions & 25 deletions storage/spider/spd_conn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions storage/spider/spd_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand All @@ -96,7 +95,6 @@ SPIDER_CONN *spider_get_conn(
ha_spider *spider,
bool another,
bool thd_chg,
uint conn_kind,
int *error_num
);

Expand Down Expand Up @@ -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
);
Expand Down
9 changes: 4 additions & 5 deletions storage/spider/spd_copy_tables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions storage/spider/spd_db_conn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions storage/spider/spd_db_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions storage/spider/spd_db_mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions storage/spider/spd_direct_sql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion storage/spider/spd_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions storage/spider/spd_ping_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 1be861c

Please sign in to comment.