Skip to content

Commit d8e9f3d

Browse files
MDEV-31673 MDEV-29502 Remove spider_db_handler::need_lock_before_set_sql_for_exec
This function trivially returns false
1 parent 1407f99 commit d8e9f3d

File tree

7 files changed

+56
-471
lines changed

7 files changed

+56
-471
lines changed

storage/spider/ha_spider.cc

Lines changed: 24 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,25 +2332,12 @@ int ha_spider::index_read_map_internal(
23322332
#endif
23332333
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
23342334
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
2335-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
2336-
{
2337-
pthread_mutex_lock(&conn->mta_conn_mutex);
2338-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
2339-
}
23402335
if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
23412336
{
2342-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
2343-
{
2344-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
2345-
pthread_mutex_unlock(&conn->mta_conn_mutex);
2346-
}
23472337
DBUG_RETURN(error_num);
23482338
}
2349-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
2350-
{
2351-
pthread_mutex_lock(&conn->mta_conn_mutex);
2352-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
2353-
}
2339+
pthread_mutex_lock(&conn->mta_conn_mutex);
2340+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
23542341
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
23552342
#ifdef HA_CAN_BULK_ACCESS
23562343
if (
@@ -2842,25 +2829,12 @@ int ha_spider::index_read_last_map_internal(
28422829
#endif
28432830
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
28442831
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
2845-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
2846-
{
2847-
pthread_mutex_lock(&conn->mta_conn_mutex);
2848-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
2849-
}
28502832
if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
28512833
{
2852-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
2853-
{
2854-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
2855-
pthread_mutex_unlock(&conn->mta_conn_mutex);
2856-
}
28572834
DBUG_RETURN(error_num);
28582835
}
2859-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
2860-
{
2861-
pthread_mutex_lock(&conn->mta_conn_mutex);
2862-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
2863-
}
2836+
pthread_mutex_lock(&conn->mta_conn_mutex);
2837+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
28642838
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
28652839
#ifdef HA_CAN_BULK_ACCESS
28662840
if (is_bulk_access_clone)
@@ -3326,26 +3300,13 @@ int ha_spider::index_first_internal(
33263300
#endif
33273301
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
33283302
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
3329-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
3330-
{
3331-
pthread_mutex_lock(&conn->mta_conn_mutex);
3332-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
3333-
}
33343303
if ((error_num =
33353304
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
33363305
{
3337-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
3338-
{
3339-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
3340-
pthread_mutex_unlock(&conn->mta_conn_mutex);
3341-
}
33423306
DBUG_RETURN(error_num);
33433307
}
3344-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
3345-
{
3346-
pthread_mutex_lock(&conn->mta_conn_mutex);
3347-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
3348-
}
3308+
pthread_mutex_lock(&conn->mta_conn_mutex);
3309+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
33493310
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
33503311
#ifdef HA_CAN_BULK_ACCESS
33513312
if (is_bulk_access_clone)
@@ -3728,26 +3689,13 @@ int ha_spider::index_last_internal(
37283689
#endif
37293690
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
37303691
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
3731-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
3732-
{
3733-
pthread_mutex_lock(&conn->mta_conn_mutex);
3734-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
3735-
}
37363692
if ((error_num =
37373693
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
37383694
{
3739-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
3740-
{
3741-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
3742-
pthread_mutex_unlock(&conn->mta_conn_mutex);
3743-
}
37443695
DBUG_RETURN(error_num);
37453696
}
3746-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
3747-
{
3748-
pthread_mutex_lock(&conn->mta_conn_mutex);
3749-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
3750-
}
3697+
pthread_mutex_lock(&conn->mta_conn_mutex);
3698+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
37513699
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
37523700
#ifdef HA_CAN_BULK_ACCESS
37533701
if (is_bulk_access_clone)
@@ -4190,25 +4138,12 @@ int ha_spider::read_range_first_internal(
41904138
#endif
41914139
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
41924140
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
4193-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
4194-
{
4195-
pthread_mutex_lock(&conn->mta_conn_mutex);
4196-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
4197-
}
41984141
if ((error_num = dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
41994142
{
4200-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
4201-
{
4202-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
4203-
pthread_mutex_unlock(&conn->mta_conn_mutex);
4204-
}
42054143
DBUG_RETURN(error_num);
42064144
}
4207-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
4208-
{
4209-
pthread_mutex_lock(&conn->mta_conn_mutex);
4210-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
4211-
}
4145+
pthread_mutex_lock(&conn->mta_conn_mutex);
4146+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
42124147
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
42134148
#ifdef HA_CAN_BULK_ACCESS
42144149
if (is_bulk_access_clone)
@@ -4893,26 +4828,13 @@ int ha_spider::read_multi_range_first_internal(
48934828
#endif
48944829
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
48954830
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
4896-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
4897-
{
4898-
pthread_mutex_lock(&conn->mta_conn_mutex);
4899-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
4900-
}
49014831
if ((error_num =
49024832
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
49034833
{
4904-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
4905-
{
4906-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
4907-
pthread_mutex_unlock(&conn->mta_conn_mutex);
4908-
}
49094834
DBUG_RETURN(error_num);
49104835
}
4911-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
4912-
{
4913-
pthread_mutex_lock(&conn->mta_conn_mutex);
4914-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
4915-
}
4836+
pthread_mutex_lock(&conn->mta_conn_mutex);
4837+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
49164838
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
49174839
#ifdef HA_CAN_BULK_ACCESS
49184840
if (is_bulk_access_clone)
@@ -5717,26 +5639,13 @@ int ha_spider::read_multi_range_first_internal(
57175639
#endif
57185640
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
57195641
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
5720-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
5721-
{
5722-
pthread_mutex_lock(&conn->mta_conn_mutex);
5723-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
5724-
}
57255642
if ((error_num =
57265643
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
57275644
{
5728-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
5729-
{
5730-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
5731-
pthread_mutex_unlock(&conn->mta_conn_mutex);
5732-
}
57335645
DBUG_RETURN(error_num);
57345646
}
5735-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
5736-
{
5737-
pthread_mutex_lock(&conn->mta_conn_mutex);
5738-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
5739-
}
5647+
pthread_mutex_lock(&conn->mta_conn_mutex);
5648+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
57405649
sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL;
57415650
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
57425651
#ifdef HA_CAN_BULK_ACCESS
@@ -6393,26 +6302,13 @@ int ha_spider::read_multi_range_next(
63936302
#endif
63946303
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
63956304
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
6396-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
6397-
{
6398-
pthread_mutex_lock(&conn->mta_conn_mutex);
6399-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
6400-
}
64016305
if ((error_num =
64026306
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
64036307
{
6404-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
6405-
{
6406-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
6407-
pthread_mutex_unlock(&conn->mta_conn_mutex);
6408-
}
64096308
DBUG_RETURN(error_num);
64106309
}
6411-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
6412-
{
6413-
pthread_mutex_lock(&conn->mta_conn_mutex);
6414-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
6415-
}
6310+
pthread_mutex_lock(&conn->mta_conn_mutex);
6311+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
64166312
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
64176313
#ifdef HA_CAN_BULK_ACCESS
64186314
if (is_bulk_access_clone)
@@ -7212,26 +7108,13 @@ int ha_spider::read_multi_range_next(
72127108
#endif
72137109
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
72147110
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
7215-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
7216-
{
7217-
pthread_mutex_lock(&conn->mta_conn_mutex);
7218-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
7219-
}
72207111
if ((error_num =
72217112
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
72227113
{
7223-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
7224-
{
7225-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
7226-
pthread_mutex_unlock(&conn->mta_conn_mutex);
7227-
}
72287114
DBUG_RETURN(error_num);
72297115
}
7230-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
7231-
{
7232-
pthread_mutex_lock(&conn->mta_conn_mutex);
7233-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
7234-
}
7116+
pthread_mutex_lock(&conn->mta_conn_mutex);
7117+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
72357118
sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL;
72367119
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
72377120
#ifdef HA_CAN_BULK_ACCESS
@@ -7894,26 +7777,13 @@ int ha_spider::rnd_next_internal(
78947777
}
78957778
spider_db_handler *dbton_hdl = dbton_handler[conn->dbton_id];
78967779
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
7897-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
7898-
{
7899-
pthread_mutex_lock(&conn->mta_conn_mutex);
7900-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
7901-
}
79027780
if ((error_num =
79037781
dbton_hdl->set_sql_for_exec(sql_type, roop_count)))
79047782
{
7905-
if (dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
7906-
{
7907-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
7908-
pthread_mutex_unlock(&conn->mta_conn_mutex);
7909-
}
79107783
DBUG_RETURN(error_num);
79117784
}
7912-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(sql_type))
7913-
{
7914-
pthread_mutex_lock(&conn->mta_conn_mutex);
7915-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
7916-
}
7785+
pthread_mutex_lock(&conn->mta_conn_mutex);
7786+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
79177787
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
79187788
conn->need_mon = &need_mons[roop_count];
79197789
DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
@@ -8524,29 +8394,13 @@ int ha_spider::ft_read_internal(
85248394
spider_db_handler *dbton_hdl = dbton_handler[dbton_id];
85258395
SPIDER_CONN *conn = conns[roop_count];
85268396
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
8527-
if (dbton_hdl->need_lock_before_set_sql_for_exec(
8528-
SPIDER_SQL_TYPE_SELECT_SQL))
8529-
{
8530-
pthread_mutex_lock(&conn->mta_conn_mutex);
8531-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
8532-
}
85338397
if ((error_num = dbton_hdl->set_sql_for_exec(
85348398
SPIDER_SQL_TYPE_SELECT_SQL, roop_count)))
85358399
{
8536-
if (dbton_hdl->need_lock_before_set_sql_for_exec(
8537-
SPIDER_SQL_TYPE_SELECT_SQL))
8538-
{
8539-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
8540-
pthread_mutex_unlock(&conn->mta_conn_mutex);
8541-
}
85428400
DBUG_RETURN(error_num);
85438401
}
8544-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(
8545-
SPIDER_SQL_TYPE_SELECT_SQL))
8546-
{
8547-
pthread_mutex_lock(&conn->mta_conn_mutex);
8548-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
8549-
}
8402+
pthread_mutex_lock(&conn->mta_conn_mutex);
8403+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
85508404
conn->need_mon = &need_mons[roop_count];
85518405
DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
85528406
DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
@@ -13313,29 +13167,13 @@ int ha_spider::drop_tmp_tables()
1331313167
spider_db_handler *dbton_hdl = dbton_handler[dbton_id];
1331413168
SPIDER_CONN *conn = conns[roop_count];
1331513169
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
13316-
if (dbton_hdl->need_lock_before_set_sql_for_exec(
13317-
SPIDER_SQL_TYPE_TMP_SQL))
13318-
{
13319-
pthread_mutex_lock(&conn->mta_conn_mutex);
13320-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
13321-
}
1332213170
if ((error_num = dbton_hdl->set_sql_for_exec(
1332313171
SPIDER_SQL_TYPE_TMP_SQL, roop_count)))
1332413172
{
13325-
if (dbton_hdl->need_lock_before_set_sql_for_exec(
13326-
SPIDER_SQL_TYPE_TMP_SQL))
13327-
{
13328-
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
13329-
pthread_mutex_unlock(&conn->mta_conn_mutex);
13330-
}
1333113173
DBUG_RETURN(error_num);
1333213174
}
13333-
if (!dbton_hdl->need_lock_before_set_sql_for_exec(
13334-
SPIDER_SQL_TYPE_TMP_SQL))
13335-
{
13336-
pthread_mutex_lock(&conn->mta_conn_mutex);
13337-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
13338-
}
13175+
pthread_mutex_lock(&conn->mta_conn_mutex);
13176+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
1333913177
conn->need_mon = &need_mon;
1334013178
DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
1334113179
DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);

storage/spider/spd_conn.cc

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,11 +2636,6 @@ void *spider_bg_conn_action(
26362636
}
26372637
#endif
26382638
pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
2639-
if (dbton_handler->need_lock_before_set_sql_for_exec(sql_type))
2640-
{
2641-
pthread_mutex_lock(&conn->mta_conn_mutex);
2642-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
2643-
}
26442639
if (spider->use_fields)
26452640
{
26462641
if ((error_num = dbton_handler->set_sql_for_exec(sql_type,
@@ -2659,11 +2654,8 @@ void *spider_bg_conn_action(
26592654
strmov(result_list->bgs_error_msg, spider_stmt_da_message(thd));
26602655
}
26612656
}
2662-
if (!dbton_handler->need_lock_before_set_sql_for_exec(sql_type))
2663-
{
2664-
pthread_mutex_lock(&conn->mta_conn_mutex);
2665-
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
2666-
}
2657+
pthread_mutex_lock(&conn->mta_conn_mutex);
2658+
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
26672659
sql_type &= ~SPIDER_SQL_TYPE_TMP_SQL;
26682660
DBUG_PRINT("info",("spider sql_type=%lu", sql_type));
26692661
#ifdef HA_CAN_BULK_ACCESS

0 commit comments

Comments
 (0)