remove ifdefs around PSI_THREAD_CALL

same change as for PSI_TABLE_CALL
This commit is contained in:
Sergei Golubchik 2018-01-03 18:51:24 +01:00 committed by Aleksey Midenkov
parent e577b5667a
commit e52a237fe9
9 changed files with 54 additions and 59 deletions

View file

@ -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.
@sa mysql_mutex_t

View file

@ -731,7 +731,7 @@ emb_transfer_connect_attrs(MYSQL *mysql)
ptr= buf= (uchar *) my_alloca(length + 9);
send_client_connect_attrs(mysql, buf);
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);
}
#endif

View file

@ -341,14 +341,12 @@ void my_thread_end(void)
tmp, pthread_self(), tmp ? (long) tmp->id : 0L);
#endif
#ifdef HAVE_PSI_INTERFACE
/*
Remove the instrumentation for this thread.
This must be done before trashing st_my_thread_var,
because the LF_HASH depends on it.
*/
PSI_THREAD_CALL(delete_current_thread)();
#endif
PSI_CALL_delete_current_thread();
/*
We need to disable DBUG early for this thread to ensure that the

View file

@ -2977,13 +2977,11 @@ static bool cache_thread(THD *thd)
DBUG_PRINT("info", ("Adding thread to cache"));
cached_thread_count++;
#ifdef HAVE_PSI_THREAD_INTERFACE
/*
Delete the instrumentation for the job that just completed,
before parking this pthread in the cache (blocked on COND_thread_cache).
*/
PSI_THREAD_CALL(delete_current_thread)();
#endif
PSI_CALL_delete_current_thread();
#ifndef DBUG_OFF
while (_db_is_pushed_())
@ -3030,15 +3028,13 @@ static bool cache_thread(THD *thd)
*/
thd->store_globals();
#ifdef HAVE_PSI_THREAD_INTERFACE
/*
Create new instrumentation for the new THD job,
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);
PSI_THREAD_CALL(set_thread)(psi);
#endif
PSI_CALL_set_thread(psi);
/* reset abort flag for the thread */
thd->mysys_var->abort= 0;
@ -3569,10 +3565,8 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
if (!abort_loop)
{
abort_loop=1; // mark abort for threads
#ifdef HAVE_PSI_THREAD_INTERFACE
/* Delete the instrumentation for the signal thread */
PSI_THREAD_CALL(delete_current_thread)();
#endif
PSI_CALL_delete_current_thread();
#ifdef USE_ONE_SIGNAL_HAND
pthread_t tmp;
if ((error= mysql_thread_create(0, /* Not instrumented */
@ -5853,8 +5847,8 @@ int mysqld_main(int argc, char **argv)
*/
init_server_psi_keys();
/* Instrument the main thread */
PSI_thread *psi= PSI_THREAD_CALL(new_thread)(key_thread_main, NULL, 0);
PSI_THREAD_CALL(set_thread)(psi);
PSI_thread *psi= PSI_CALL_new_thread(key_thread_main, NULL, 0);
PSI_CALL_set_thread(psi);
/*
Now that some instrumentation is in place,
@ -6203,13 +6197,11 @@ int mysqld_main(int argc, char **argv)
mysql_mutex_unlock(&LOCK_start_thread);
#endif /* __WIN__ */
#ifdef HAVE_PSI_THREAD_INTERFACE
/*
Disable the main thread instrumentation,
to avoid recording events during the shutdown.
*/
PSI_THREAD_CALL(delete_current_thread)();
#endif
PSI_CALL_delete_current_thread();
/* Wait until cleanup is done */
mysql_mutex_lock(&LOCK_thread_count);

View file

@ -12439,12 +12439,10 @@ read_client_connect_attrs(char **ptr, char *end, CHARSET_INFO *from_cs)
if (length > 65535)
return true;
#ifdef HAVE_PSI_THREAD_INTERFACE
if (PSI_THREAD_CALL(set_thread_connect_attrs)(*ptr, (size_t)length, from_cs) &&
if (PSI_CALL_set_thread_connect_attrs(*ptr, (size_t)length, from_cs) &&
current_thd->variables.log_warnings)
sql_print_warning("Connection attributes of length %llu were truncated",
length);
#endif
return false;
}
@ -13517,11 +13515,9 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
else
my_ok(thd);
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_THREAD_CALL(set_thread_user_host)
PSI_CALL_set_thread_user_host
(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));
#endif
/* Ready to handle queries */
DBUG_RETURN(0);

View file

@ -3376,9 +3376,7 @@ public:
start_time= secs;
start_time_sec_part= usecs;
}
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_THREAD_CALL(set_thread_start_time)(start_time);
#endif
PSI_CALL_set_thread_start_time(start_time);
}
inline void set_start_time()
{
@ -3386,9 +3384,7 @@ public:
{
start_time= hrtime_to_my_time(user_time);
start_time_sec_part= hrtime_sec_part(user_time);
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_THREAD_CALL(set_thread_start_time)(start_time);
#endif
PSI_CALL_set_thread_start_time(start_time);
}
else
set_current_time();
@ -4035,10 +4031,8 @@ public:
db_length= db ? new_db_len : 0;
bool result= new_db && !db;
mysql_mutex_unlock(&LOCK_thd_data);
#ifdef HAVE_PSI_THREAD_INTERFACE
if (result)
PSI_THREAD_CALL(set_thread_db)(new_db, (int) new_db_len);
#endif
PSI_CALL_set_thread_db(new_db, (int) new_db_len);
return result;
}
@ -4061,9 +4055,7 @@ public:
db= new_db;
db_length= new_db_len;
mysql_mutex_unlock(&LOCK_thd_data);
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_THREAD_CALL(set_thread_db)(new_db, (int) new_db_len);
#endif
PSI_CALL_set_thread_db(new_db, (int) new_db_len);
}
}
/*
@ -4282,9 +4274,7 @@ public:
set_query_inner(string_arg);
mysql_mutex_unlock(&LOCK_thd_data);
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_THREAD_CALL(set_thread_info)(query(), query_length());
#endif
PSI_CALL_set_thread_info(query(), query_length());
}
void reset_query() /* Mutex protected */
{ set_query(CSET_STRING()); }

View file

@ -84,17 +84,13 @@ struct Worker_thread_context
void save()
{
#ifdef HAVE_PSI_THREAD_INTERFACE
psi_thread = PSI_THREAD_CALL(get_thread)();
#endif
psi_thread = PSI_CALL_get_thread();
mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys);
}
void restore()
{
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_THREAD_CALL(set_thread)(psi_thread);
#endif
PSI_CALL_set_thread(psi_thread);
pthread_setspecific(THR_KEY_mysys,mysys_var);
pthread_setspecific(THR_THD, 0);
}
@ -144,9 +140,7 @@ static void thread_attach(THD* thd)
pthread_setspecific(THR_KEY_mysys,thd->mysys_var);
thd->thread_stack=(char*)&thd;
thd->store_globals();
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_THREAD_CALL(set_thread)(thd->event_scheduler.m_psi);
#endif
PSI_CALL_set_thread(thd->event_scheduler.m_psi);
mysql_socket_set_thread_owner(thd->net.vio->mysql_socket);
}
@ -254,10 +248,8 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
thd->event_scheduler.data= scheduler_data;
/* Create new PSI thread for use with the THD. */
#ifdef HAVE_PSI_THREAD_INTERFACE
thd->event_scheduler.m_psi=
PSI_THREAD_CALL(new_thread)(key_thread_one_connection, thd, thd->thread_id);
#endif
PSI_CALL_new_thread(key_thread_one_connection, thd, thd->thread_id);
/* Login. */

View file

@ -611,16 +611,16 @@ extern mysql_pfs_key_t trx_rollback_clean_thread_key;
schema */
# define pfs_register_thread(key) \
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 \
PSI_THREAD_CALL(set_thread_os_id)(psi); */ \
PSI_THREAD_CALL(set_thread)(psi); \
PSI_CALL_set_thread_os_id(psi); */ \
PSI_CALL_set_thread(psi); \
} while (0)
/* This macro delist the current thread from performance schema */
# define pfs_delete_thread() \
do { \
PSI_THREAD_CALL(delete_current_thread)(); \
PSI_CALL_delete_current_thread(); \
} while (0)
# else
# define pfs_register_thread(key)

View file

@ -562,9 +562,7 @@ pthread_handler_t ma_checkpoint_background(void *arg)
DBUG_PRINT("info",("Maria background checkpoint thread starts"));
DBUG_ASSERT(interval > 0);
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_THREAD_CALL(set_thread_user_host)(0,0,0,0);
#endif
PSI_CALL_set_thread_user_host(0,0,0,0);
/*
Recovery ended with all tables closed and a checkpoint: no need to take