Commit e52a237f authored by Sergei Golubchik's avatar Sergei Golubchik Committed by Aleksey Midenkov

remove ifdefs around PSI_THREAD_CALL

same change as for PSI_TABLE_CALL
parent e577b566
...@@ -62,6 +62,35 @@ ...@@ -62,6 +62,35 @@
@{ @{
*/ */
#ifdef HAVE_PSI_THREAD_INTERFACE
#define PSI_CALL_delete_current_thread PSI_THREAD_CALL(delete_current_thread)
#define PSI_CALL_get_thread PSI_THREAD_CALL(get_thread)
#define PSI_CALL_new_thread PSI_THREAD_CALL(new_thread)
#define PSI_CALL_register_thread PSI_THREAD_CALL(register_thread)
#define PSI_CALL_set_thread PSI_THREAD_CALL(set_thread)
#define PSI_CALL_set_thread_connect_attrs PSI_THREAD_CALL(set_thread_connect_attrs)
#define PSI_CALL_set_thread_db PSI_THREAD_CALL(set_thread_db)
#define PSI_CALL_set_thread_id PSI_THREAD_CALL(set_thread_id)
#define PSI_CALL_set_thread_info PSI_THREAD_CALL(set_thread_info)
#define PSI_CALL_set_thread_start_time PSI_THREAD_CALL(set_thread_start_time)
#define PSI_CALL_set_thread_user_host PSI_THREAD_CALL(set_thread_user_host)
#define PSI_CALL_spawn_thread PSI_THREAD_CALL(spawn_thread)
#else
#define PSI_CALL_delete_current_thread() do { } while(0)
#define PSI_CALL_get_thread() NULL
#define PSI_CALL_new_thread(A1,A2,A3) NULL
#define PSI_CALL_register_thread(A1,A2,A3) do { } while(0)
#define PSI_CALL_set_thread(A1) do { } while(0)
#define PSI_CALL_set_thread_connect_attrs(A1,A2,A3) 0
#define PSI_CALL_set_thread_db(A1,A2) do { } while(0)
#define PSI_CALL_set_thread_id(A1,A2) do { } while(0)
#define PSI_CALL_set_thread_info(A1, A2) do { } while(0)
#define PSI_CALL_set_thread_start_time(A1) do { } while(0)
#define PSI_CALL_set_thread_user_host(A1, A2, A3, A4) do { } while(0)
#define PSI_CALL_spawn_thread(A1, A2, A3, A4, A5) 0
#endif
/** /**
An instrumented mutex structure. An instrumented mutex structure.
@sa mysql_mutex_t @sa mysql_mutex_t
......
...@@ -731,7 +731,7 @@ emb_transfer_connect_attrs(MYSQL *mysql) ...@@ -731,7 +731,7 @@ emb_transfer_connect_attrs(MYSQL *mysql)
ptr= buf= (uchar *) my_alloca(length + 9); ptr= buf= (uchar *) my_alloca(length + 9);
send_client_connect_attrs(mysql, buf); send_client_connect_attrs(mysql, buf);
net_field_length_ll(&ptr); net_field_length_ll(&ptr);
PSI_THREAD_CALL(set_thread_connect_attrs)((char *) ptr, length, thd->charset()); PSI_CALL_set_thread_connect_attrs((char *) ptr, length, thd->charset());
my_afree(buf); my_afree(buf);
} }
#endif #endif
......
...@@ -341,14 +341,12 @@ void my_thread_end(void) ...@@ -341,14 +341,12 @@ void my_thread_end(void)
tmp, pthread_self(), tmp ? (long) tmp->id : 0L); tmp, pthread_self(), tmp ? (long) tmp->id : 0L);
#endif #endif
#ifdef HAVE_PSI_INTERFACE
/* /*
Remove the instrumentation for this thread. Remove the instrumentation for this thread.
This must be done before trashing st_my_thread_var, This must be done before trashing st_my_thread_var,
because the LF_HASH depends on it. because the LF_HASH depends on it.
*/ */
PSI_THREAD_CALL(delete_current_thread)(); PSI_CALL_delete_current_thread();
#endif
/* /*
We need to disable DBUG early for this thread to ensure that the We need to disable DBUG early for this thread to ensure that the
......
...@@ -2977,13 +2977,11 @@ static bool cache_thread(THD *thd) ...@@ -2977,13 +2977,11 @@ static bool cache_thread(THD *thd)
DBUG_PRINT("info", ("Adding thread to cache")); DBUG_PRINT("info", ("Adding thread to cache"));
cached_thread_count++; cached_thread_count++;
#ifdef HAVE_PSI_THREAD_INTERFACE
/* /*
Delete the instrumentation for the job that just completed, Delete the instrumentation for the job that just completed,
before parking this pthread in the cache (blocked on COND_thread_cache). before parking this pthread in the cache (blocked on COND_thread_cache).
*/ */
PSI_THREAD_CALL(delete_current_thread)(); PSI_CALL_delete_current_thread();
#endif
#ifndef DBUG_OFF #ifndef DBUG_OFF
while (_db_is_pushed_()) while (_db_is_pushed_())
...@@ -3030,15 +3028,13 @@ static bool cache_thread(THD *thd) ...@@ -3030,15 +3028,13 @@ static bool cache_thread(THD *thd)
*/ */
thd->store_globals(); thd->store_globals();
#ifdef HAVE_PSI_THREAD_INTERFACE
/* /*
Create new instrumentation for the new THD job, Create new instrumentation for the new THD job,
and attach it to this running pthread. and attach it to this running pthread.
*/ */
PSI_thread *psi= PSI_THREAD_CALL(new_thread)(key_thread_one_connection, PSI_thread *psi= PSI_CALL_new_thread(key_thread_one_connection,
thd, thd->thread_id); thd, thd->thread_id);
PSI_THREAD_CALL(set_thread)(psi); PSI_CALL_set_thread(psi);
#endif
/* reset abort flag for the thread */ /* reset abort flag for the thread */
thd->mysys_var->abort= 0; thd->mysys_var->abort= 0;
...@@ -3569,10 +3565,8 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) ...@@ -3569,10 +3565,8 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
if (!abort_loop) if (!abort_loop)
{ {
abort_loop=1; // mark abort for threads abort_loop=1; // mark abort for threads
#ifdef HAVE_PSI_THREAD_INTERFACE
/* Delete the instrumentation for the signal thread */ /* Delete the instrumentation for the signal thread */
PSI_THREAD_CALL(delete_current_thread)(); PSI_CALL_delete_current_thread();
#endif
#ifdef USE_ONE_SIGNAL_HAND #ifdef USE_ONE_SIGNAL_HAND
pthread_t tmp; pthread_t tmp;
if ((error= mysql_thread_create(0, /* Not instrumented */ if ((error= mysql_thread_create(0, /* Not instrumented */
...@@ -5853,8 +5847,8 @@ int mysqld_main(int argc, char **argv) ...@@ -5853,8 +5847,8 @@ int mysqld_main(int argc, char **argv)
*/ */
init_server_psi_keys(); init_server_psi_keys();
/* Instrument the main thread */ /* Instrument the main thread */
PSI_thread *psi= PSI_THREAD_CALL(new_thread)(key_thread_main, NULL, 0); PSI_thread *psi= PSI_CALL_new_thread(key_thread_main, NULL, 0);
PSI_THREAD_CALL(set_thread)(psi); PSI_CALL_set_thread(psi);
/* /*
Now that some instrumentation is in place, Now that some instrumentation is in place,
...@@ -6203,13 +6197,11 @@ int mysqld_main(int argc, char **argv) ...@@ -6203,13 +6197,11 @@ int mysqld_main(int argc, char **argv)
mysql_mutex_unlock(&LOCK_start_thread); mysql_mutex_unlock(&LOCK_start_thread);
#endif /* __WIN__ */ #endif /* __WIN__ */
#ifdef HAVE_PSI_THREAD_INTERFACE
/* /*
Disable the main thread instrumentation, Disable the main thread instrumentation,
to avoid recording events during the shutdown. to avoid recording events during the shutdown.
*/ */
PSI_THREAD_CALL(delete_current_thread)(); PSI_CALL_delete_current_thread();
#endif
/* Wait until cleanup is done */ /* Wait until cleanup is done */
mysql_mutex_lock(&LOCK_thread_count); mysql_mutex_lock(&LOCK_thread_count);
......
...@@ -12439,12 +12439,10 @@ read_client_connect_attrs(char **ptr, char *end, CHARSET_INFO *from_cs) ...@@ -12439,12 +12439,10 @@ read_client_connect_attrs(char **ptr, char *end, CHARSET_INFO *from_cs)
if (length > 65535) if (length > 65535)
return true; return true;
#ifdef HAVE_PSI_THREAD_INTERFACE if (PSI_CALL_set_thread_connect_attrs(*ptr, (size_t)length, from_cs) &&
if (PSI_THREAD_CALL(set_thread_connect_attrs)(*ptr, (size_t)length, from_cs) &&
current_thd->variables.log_warnings) current_thd->variables.log_warnings)
sql_print_warning("Connection attributes of length %llu were truncated", sql_print_warning("Connection attributes of length %llu were truncated",
length); length);
#endif
return false; return false;
} }
...@@ -13517,11 +13515,9 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len) ...@@ -13517,11 +13515,9 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
else else
my_ok(thd); my_ok(thd);
#ifdef HAVE_PSI_THREAD_INTERFACE PSI_CALL_set_thread_user_host
PSI_THREAD_CALL(set_thread_user_host)
(thd->main_security_ctx.user, strlen(thd->main_security_ctx.user), (thd->main_security_ctx.user, strlen(thd->main_security_ctx.user),
thd->main_security_ctx.host_or_ip, strlen(thd->main_security_ctx.host_or_ip)); thd->main_security_ctx.host_or_ip, strlen(thd->main_security_ctx.host_or_ip));
#endif
/* Ready to handle queries */ /* Ready to handle queries */
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -3376,9 +3376,7 @@ class THD :public Statement, ...@@ -3376,9 +3376,7 @@ class THD :public Statement,
start_time= secs; start_time= secs;
start_time_sec_part= usecs; start_time_sec_part= usecs;
} }
#ifdef HAVE_PSI_THREAD_INTERFACE PSI_CALL_set_thread_start_time(start_time);
PSI_THREAD_CALL(set_thread_start_time)(start_time);
#endif
} }
inline void set_start_time() inline void set_start_time()
{ {
...@@ -3386,9 +3384,7 @@ class THD :public Statement, ...@@ -3386,9 +3384,7 @@ class THD :public Statement,
{ {
start_time= hrtime_to_my_time(user_time); start_time= hrtime_to_my_time(user_time);
start_time_sec_part= hrtime_sec_part(user_time); start_time_sec_part= hrtime_sec_part(user_time);
#ifdef HAVE_PSI_THREAD_INTERFACE PSI_CALL_set_thread_start_time(start_time);
PSI_THREAD_CALL(set_thread_start_time)(start_time);
#endif
} }
else else
set_current_time(); set_current_time();
...@@ -4035,10 +4031,8 @@ class THD :public Statement, ...@@ -4035,10 +4031,8 @@ class THD :public Statement,
db_length= db ? new_db_len : 0; db_length= db ? new_db_len : 0;
bool result= new_db && !db; bool result= new_db && !db;
mysql_mutex_unlock(&LOCK_thd_data); mysql_mutex_unlock(&LOCK_thd_data);
#ifdef HAVE_PSI_THREAD_INTERFACE
if (result) if (result)
PSI_THREAD_CALL(set_thread_db)(new_db, (int) new_db_len); PSI_CALL_set_thread_db(new_db, (int) new_db_len);
#endif
return result; return result;
} }
...@@ -4061,9 +4055,7 @@ class THD :public Statement, ...@@ -4061,9 +4055,7 @@ class THD :public Statement,
db= new_db; db= new_db;
db_length= new_db_len; db_length= new_db_len;
mysql_mutex_unlock(&LOCK_thd_data); mysql_mutex_unlock(&LOCK_thd_data);
#ifdef HAVE_PSI_THREAD_INTERFACE PSI_CALL_set_thread_db(new_db, (int) new_db_len);
PSI_THREAD_CALL(set_thread_db)(new_db, (int) new_db_len);
#endif
} }
} }
/* /*
...@@ -4282,9 +4274,7 @@ class THD :public Statement, ...@@ -4282,9 +4274,7 @@ class THD :public Statement,
set_query_inner(string_arg); set_query_inner(string_arg);
mysql_mutex_unlock(&LOCK_thd_data); mysql_mutex_unlock(&LOCK_thd_data);
#ifdef HAVE_PSI_THREAD_INTERFACE PSI_CALL_set_thread_info(query(), query_length());
PSI_THREAD_CALL(set_thread_info)(query(), query_length());
#endif
} }
void reset_query() /* Mutex protected */ void reset_query() /* Mutex protected */
{ set_query(CSET_STRING()); } { set_query(CSET_STRING()); }
......
...@@ -84,17 +84,13 @@ struct Worker_thread_context ...@@ -84,17 +84,13 @@ struct Worker_thread_context
void save() void save()
{ {
#ifdef HAVE_PSI_THREAD_INTERFACE psi_thread = PSI_CALL_get_thread();
psi_thread = PSI_THREAD_CALL(get_thread)();
#endif
mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys); mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys);
} }
void restore() void restore()
{ {
#ifdef HAVE_PSI_THREAD_INTERFACE PSI_CALL_set_thread(psi_thread);
PSI_THREAD_CALL(set_thread)(psi_thread);
#endif
pthread_setspecific(THR_KEY_mysys,mysys_var); pthread_setspecific(THR_KEY_mysys,mysys_var);
pthread_setspecific(THR_THD, 0); pthread_setspecific(THR_THD, 0);
} }
...@@ -144,9 +140,7 @@ static void thread_attach(THD* thd) ...@@ -144,9 +140,7 @@ static void thread_attach(THD* thd)
pthread_setspecific(THR_KEY_mysys,thd->mysys_var); pthread_setspecific(THR_KEY_mysys,thd->mysys_var);
thd->thread_stack=(char*)&thd; thd->thread_stack=(char*)&thd;
thd->store_globals(); thd->store_globals();
#ifdef HAVE_PSI_THREAD_INTERFACE PSI_CALL_set_thread(thd->event_scheduler.m_psi);
PSI_THREAD_CALL(set_thread)(thd->event_scheduler.m_psi);
#endif
mysql_socket_set_thread_owner(thd->net.vio->mysql_socket); mysql_socket_set_thread_owner(thd->net.vio->mysql_socket);
} }
...@@ -254,10 +248,8 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data) ...@@ -254,10 +248,8 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
thd->event_scheduler.data= scheduler_data; thd->event_scheduler.data= scheduler_data;
/* Create new PSI thread for use with the THD. */ /* Create new PSI thread for use with the THD. */
#ifdef HAVE_PSI_THREAD_INTERFACE
thd->event_scheduler.m_psi= thd->event_scheduler.m_psi=
PSI_THREAD_CALL(new_thread)(key_thread_one_connection, thd, thd->thread_id); PSI_CALL_new_thread(key_thread_one_connection, thd, thd->thread_id);
#endif
/* Login. */ /* Login. */
......
...@@ -611,16 +611,16 @@ extern mysql_pfs_key_t trx_rollback_clean_thread_key; ...@@ -611,16 +611,16 @@ extern mysql_pfs_key_t trx_rollback_clean_thread_key;
schema */ schema */
# define pfs_register_thread(key) \ # define pfs_register_thread(key) \
do { \ do { \
struct PSI_thread* psi = PSI_THREAD_CALL(new_thread)(key, NULL, 0);\ struct PSI_thread* psi = PSI_CALL_new_thread(key, NULL, 0);\
/* JAN: TODO: MYSQL 5.7 PSI \ /* JAN: TODO: MYSQL 5.7 PSI \
PSI_THREAD_CALL(set_thread_os_id)(psi); */ \ PSI_CALL_set_thread_os_id(psi); */ \
PSI_THREAD_CALL(set_thread)(psi); \ PSI_CALL_set_thread(psi); \
} while (0) } while (0)
/* This macro delist the current thread from performance schema */ /* This macro delist the current thread from performance schema */
# define pfs_delete_thread() \ # define pfs_delete_thread() \
do { \ do { \
PSI_THREAD_CALL(delete_current_thread)(); \ PSI_CALL_delete_current_thread(); \
} while (0) } while (0)
# else # else
# define pfs_register_thread(key) # define pfs_register_thread(key)
......
...@@ -562,9 +562,7 @@ pthread_handler_t ma_checkpoint_background(void *arg) ...@@ -562,9 +562,7 @@ pthread_handler_t ma_checkpoint_background(void *arg)
DBUG_PRINT("info",("Maria background checkpoint thread starts")); DBUG_PRINT("info",("Maria background checkpoint thread starts"));
DBUG_ASSERT(interval > 0); DBUG_ASSERT(interval > 0);
#ifdef HAVE_PSI_THREAD_INTERFACE PSI_CALL_set_thread_user_host(0,0,0,0);
PSI_THREAD_CALL(set_thread_user_host)(0,0,0,0);
#endif
/* /*
Recovery ended with all tables closed and a checkpoint: no need to take Recovery ended with all tables closed and a checkpoint: no need to take
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment