Skip to content

Commit e52a237

Browse files
vuvovamidenok
authored andcommitted
remove ifdefs around PSI_THREAD_CALL
same change as for PSI_TABLE_CALL
1 parent e577b56 commit e52a237

File tree

9 files changed

+54
-59
lines changed

9 files changed

+54
-59
lines changed

include/mysql/psi/mysql_thread.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,35 @@
6262
@{
6363
*/
6464

65+
#ifdef HAVE_PSI_THREAD_INTERFACE
66+
#define PSI_CALL_delete_current_thread PSI_THREAD_CALL(delete_current_thread)
67+
#define PSI_CALL_get_thread PSI_THREAD_CALL(get_thread)
68+
#define PSI_CALL_new_thread PSI_THREAD_CALL(new_thread)
69+
#define PSI_CALL_register_thread PSI_THREAD_CALL(register_thread)
70+
#define PSI_CALL_set_thread PSI_THREAD_CALL(set_thread)
71+
#define PSI_CALL_set_thread_connect_attrs PSI_THREAD_CALL(set_thread_connect_attrs)
72+
#define PSI_CALL_set_thread_db PSI_THREAD_CALL(set_thread_db)
73+
#define PSI_CALL_set_thread_id PSI_THREAD_CALL(set_thread_id)
74+
#define PSI_CALL_set_thread_info PSI_THREAD_CALL(set_thread_info)
75+
#define PSI_CALL_set_thread_start_time PSI_THREAD_CALL(set_thread_start_time)
76+
#define PSI_CALL_set_thread_user_host PSI_THREAD_CALL(set_thread_user_host)
77+
#define PSI_CALL_spawn_thread PSI_THREAD_CALL(spawn_thread)
78+
#else
79+
#define PSI_CALL_delete_current_thread() do { } while(0)
80+
#define PSI_CALL_get_thread() NULL
81+
#define PSI_CALL_new_thread(A1,A2,A3) NULL
82+
#define PSI_CALL_register_thread(A1,A2,A3) do { } while(0)
83+
#define PSI_CALL_set_thread(A1) do { } while(0)
84+
#define PSI_CALL_set_thread_connect_attrs(A1,A2,A3) 0
85+
#define PSI_CALL_set_thread_db(A1,A2) do { } while(0)
86+
#define PSI_CALL_set_thread_id(A1,A2) do { } while(0)
87+
#define PSI_CALL_set_thread_info(A1, A2) do { } while(0)
88+
#define PSI_CALL_set_thread_start_time(A1) do { } while(0)
89+
#define PSI_CALL_set_thread_user_host(A1, A2, A3, A4) do { } while(0)
90+
#define PSI_CALL_spawn_thread(A1, A2, A3, A4, A5) 0
91+
#endif
92+
93+
6594
/**
6695
An instrumented mutex structure.
6796
@sa mysql_mutex_t

libmysqld/lib_sql.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ emb_transfer_connect_attrs(MYSQL *mysql)
731731
ptr= buf= (uchar *) my_alloca(length + 9);
732732
send_client_connect_attrs(mysql, buf);
733733
net_field_length_ll(&ptr);
734-
PSI_THREAD_CALL(set_thread_connect_attrs)((char *) ptr, length, thd->charset());
734+
PSI_CALL_set_thread_connect_attrs((char *) ptr, length, thd->charset());
735735
my_afree(buf);
736736
}
737737
#endif

mysys/my_thr_init.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,12 @@ void my_thread_end(void)
341341
tmp, pthread_self(), tmp ? (long) tmp->id : 0L);
342342
#endif
343343

344-
#ifdef HAVE_PSI_INTERFACE
345344
/*
346345
Remove the instrumentation for this thread.
347346
This must be done before trashing st_my_thread_var,
348347
because the LF_HASH depends on it.
349348
*/
350-
PSI_THREAD_CALL(delete_current_thread)();
351-
#endif
349+
PSI_CALL_delete_current_thread();
352350

353351
/*
354352
We need to disable DBUG early for this thread to ensure that the

sql/mysqld.cc

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,13 +2977,11 @@ static bool cache_thread(THD *thd)
29772977
DBUG_PRINT("info", ("Adding thread to cache"));
29782978
cached_thread_count++;
29792979

2980-
#ifdef HAVE_PSI_THREAD_INTERFACE
29812980
/*
29822981
Delete the instrumentation for the job that just completed,
29832982
before parking this pthread in the cache (blocked on COND_thread_cache).
29842983
*/
2985-
PSI_THREAD_CALL(delete_current_thread)();
2986-
#endif
2984+
PSI_CALL_delete_current_thread();
29872985

29882986
#ifndef DBUG_OFF
29892987
while (_db_is_pushed_())
@@ -3030,15 +3028,13 @@ static bool cache_thread(THD *thd)
30303028
*/
30313029
thd->store_globals();
30323030

3033-
#ifdef HAVE_PSI_THREAD_INTERFACE
30343031
/*
30353032
Create new instrumentation for the new THD job,
30363033
and attach it to this running pthread.
30373034
*/
3038-
PSI_thread *psi= PSI_THREAD_CALL(new_thread)(key_thread_one_connection,
3035+
PSI_thread *psi= PSI_CALL_new_thread(key_thread_one_connection,
30393036
thd, thd->thread_id);
3040-
PSI_THREAD_CALL(set_thread)(psi);
3041-
#endif
3037+
PSI_CALL_set_thread(psi);
30423038

30433039
/* reset abort flag for the thread */
30443040
thd->mysys_var->abort= 0;
@@ -3569,10 +3565,8 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
35693565
if (!abort_loop)
35703566
{
35713567
abort_loop=1; // mark abort for threads
3572-
#ifdef HAVE_PSI_THREAD_INTERFACE
35733568
/* Delete the instrumentation for the signal thread */
3574-
PSI_THREAD_CALL(delete_current_thread)();
3575-
#endif
3569+
PSI_CALL_delete_current_thread();
35763570
#ifdef USE_ONE_SIGNAL_HAND
35773571
pthread_t tmp;
35783572
if ((error= mysql_thread_create(0, /* Not instrumented */
@@ -5853,8 +5847,8 @@ int mysqld_main(int argc, char **argv)
58535847
*/
58545848
init_server_psi_keys();
58555849
/* Instrument the main thread */
5856-
PSI_thread *psi= PSI_THREAD_CALL(new_thread)(key_thread_main, NULL, 0);
5857-
PSI_THREAD_CALL(set_thread)(psi);
5850+
PSI_thread *psi= PSI_CALL_new_thread(key_thread_main, NULL, 0);
5851+
PSI_CALL_set_thread(psi);
58585852

58595853
/*
58605854
Now that some instrumentation is in place,
@@ -6203,13 +6197,11 @@ int mysqld_main(int argc, char **argv)
62036197
mysql_mutex_unlock(&LOCK_start_thread);
62046198
#endif /* __WIN__ */
62056199

6206-
#ifdef HAVE_PSI_THREAD_INTERFACE
62076200
/*
62086201
Disable the main thread instrumentation,
62096202
to avoid recording events during the shutdown.
62106203
*/
6211-
PSI_THREAD_CALL(delete_current_thread)();
6212-
#endif
6204+
PSI_CALL_delete_current_thread();
62136205

62146206
/* Wait until cleanup is done */
62156207
mysql_mutex_lock(&LOCK_thread_count);

sql/sql_acl.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12439,12 +12439,10 @@ read_client_connect_attrs(char **ptr, char *end, CHARSET_INFO *from_cs)
1243912439
if (length > 65535)
1244012440
return true;
1244112441

12442-
#ifdef HAVE_PSI_THREAD_INTERFACE
12443-
if (PSI_THREAD_CALL(set_thread_connect_attrs)(*ptr, (size_t)length, from_cs) &&
12442+
if (PSI_CALL_set_thread_connect_attrs(*ptr, (size_t)length, from_cs) &&
1244412443
current_thd->variables.log_warnings)
1244512444
sql_print_warning("Connection attributes of length %llu were truncated",
1244612445
length);
12447-
#endif
1244812446
return false;
1244912447
}
1245012448

@@ -13517,11 +13515,9 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
1351713515
else
1351813516
my_ok(thd);
1351913517

13520-
#ifdef HAVE_PSI_THREAD_INTERFACE
13521-
PSI_THREAD_CALL(set_thread_user_host)
13518+
PSI_CALL_set_thread_user_host
1352213519
(thd->main_security_ctx.user, strlen(thd->main_security_ctx.user),
1352313520
thd->main_security_ctx.host_or_ip, strlen(thd->main_security_ctx.host_or_ip));
13524-
#endif
1352513521

1352613522
/* Ready to handle queries */
1352713523
DBUG_RETURN(0);

sql/sql_class.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,19 +3376,15 @@ class THD :public Statement,
33763376
start_time= secs;
33773377
start_time_sec_part= usecs;
33783378
}
3379-
#ifdef HAVE_PSI_THREAD_INTERFACE
3380-
PSI_THREAD_CALL(set_thread_start_time)(start_time);
3381-
#endif
3379+
PSI_CALL_set_thread_start_time(start_time);
33823380
}
33833381
inline void set_start_time()
33843382
{
33853383
if (user_time.val)
33863384
{
33873385
start_time= hrtime_to_my_time(user_time);
33883386
start_time_sec_part= hrtime_sec_part(user_time);
3389-
#ifdef HAVE_PSI_THREAD_INTERFACE
3390-
PSI_THREAD_CALL(set_thread_start_time)(start_time);
3391-
#endif
3387+
PSI_CALL_set_thread_start_time(start_time);
33923388
}
33933389
else
33943390
set_current_time();
@@ -4035,10 +4031,8 @@ class THD :public Statement,
40354031
db_length= db ? new_db_len : 0;
40364032
bool result= new_db && !db;
40374033
mysql_mutex_unlock(&LOCK_thd_data);
4038-
#ifdef HAVE_PSI_THREAD_INTERFACE
40394034
if (result)
4040-
PSI_THREAD_CALL(set_thread_db)(new_db, (int) new_db_len);
4041-
#endif
4035+
PSI_CALL_set_thread_db(new_db, (int) new_db_len);
40424036
return result;
40434037
}
40444038

@@ -4061,9 +4055,7 @@ class THD :public Statement,
40614055
db= new_db;
40624056
db_length= new_db_len;
40634057
mysql_mutex_unlock(&LOCK_thd_data);
4064-
#ifdef HAVE_PSI_THREAD_INTERFACE
4065-
PSI_THREAD_CALL(set_thread_db)(new_db, (int) new_db_len);
4066-
#endif
4058+
PSI_CALL_set_thread_db(new_db, (int) new_db_len);
40674059
}
40684060
}
40694061
/*
@@ -4282,9 +4274,7 @@ class THD :public Statement,
42824274
set_query_inner(string_arg);
42834275
mysql_mutex_unlock(&LOCK_thd_data);
42844276

4285-
#ifdef HAVE_PSI_THREAD_INTERFACE
4286-
PSI_THREAD_CALL(set_thread_info)(query(), query_length());
4287-
#endif
4277+
PSI_CALL_set_thread_info(query(), query_length());
42884278
}
42894279
void reset_query() /* Mutex protected */
42904280
{ set_query(CSET_STRING()); }

sql/threadpool_common.cc

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,13 @@ struct Worker_thread_context
8484

8585
void save()
8686
{
87-
#ifdef HAVE_PSI_THREAD_INTERFACE
88-
psi_thread = PSI_THREAD_CALL(get_thread)();
89-
#endif
87+
psi_thread = PSI_CALL_get_thread();
9088
mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys);
9189
}
9290

9391
void restore()
9492
{
95-
#ifdef HAVE_PSI_THREAD_INTERFACE
96-
PSI_THREAD_CALL(set_thread)(psi_thread);
97-
#endif
93+
PSI_CALL_set_thread(psi_thread);
9894
pthread_setspecific(THR_KEY_mysys,mysys_var);
9995
pthread_setspecific(THR_THD, 0);
10096
}
@@ -144,9 +140,7 @@ static void thread_attach(THD* thd)
144140
pthread_setspecific(THR_KEY_mysys,thd->mysys_var);
145141
thd->thread_stack=(char*)&thd;
146142
thd->store_globals();
147-
#ifdef HAVE_PSI_THREAD_INTERFACE
148-
PSI_THREAD_CALL(set_thread)(thd->event_scheduler.m_psi);
149-
#endif
143+
PSI_CALL_set_thread(thd->event_scheduler.m_psi);
150144
mysql_socket_set_thread_owner(thd->net.vio->mysql_socket);
151145
}
152146

@@ -254,10 +248,8 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
254248
thd->event_scheduler.data= scheduler_data;
255249

256250
/* Create new PSI thread for use with the THD. */
257-
#ifdef HAVE_PSI_THREAD_INTERFACE
258251
thd->event_scheduler.m_psi=
259-
PSI_THREAD_CALL(new_thread)(key_thread_one_connection, thd, thd->thread_id);
260-
#endif
252+
PSI_CALL_new_thread(key_thread_one_connection, thd, thd->thread_id);
261253

262254

263255
/* Login. */

storage/innobase/include/srv0srv.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,16 +611,16 @@ extern mysql_pfs_key_t trx_rollback_clean_thread_key;
611611
schema */
612612
# define pfs_register_thread(key) \
613613
do { \
614-
struct PSI_thread* psi = PSI_THREAD_CALL(new_thread)(key, NULL, 0);\
614+
struct PSI_thread* psi = PSI_CALL_new_thread(key, NULL, 0);\
615615
/* JAN: TODO: MYSQL 5.7 PSI \
616-
PSI_THREAD_CALL(set_thread_os_id)(psi); */ \
617-
PSI_THREAD_CALL(set_thread)(psi); \
616+
PSI_CALL_set_thread_os_id(psi); */ \
617+
PSI_CALL_set_thread(psi); \
618618
} while (0)
619619

620620
/* This macro delist the current thread from performance schema */
621621
# define pfs_delete_thread() \
622622
do { \
623-
PSI_THREAD_CALL(delete_current_thread)(); \
623+
PSI_CALL_delete_current_thread(); \
624624
} while (0)
625625
# else
626626
# define pfs_register_thread(key)

storage/maria/ma_checkpoint.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,7 @@ pthread_handler_t ma_checkpoint_background(void *arg)
562562
DBUG_PRINT("info",("Maria background checkpoint thread starts"));
563563
DBUG_ASSERT(interval > 0);
564564

565-
#ifdef HAVE_PSI_THREAD_INTERFACE
566-
PSI_THREAD_CALL(set_thread_user_host)(0,0,0,0);
567-
#endif
565+
PSI_CALL_set_thread_user_host(0,0,0,0);
568566

569567
/*
570568
Recovery ended with all tables closed and a checkpoint: no need to take

0 commit comments

Comments
 (0)