summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-01-03 18:51:24 +0100
committerAleksey Midenkov <midenok@gmail.com>2018-01-09 14:21:20 +0300
commite52a237fe9a8884ce6da18436a4cf50cfd9dbd45 (patch)
tree39bcab699be37e557b456926f5ce52c9685c60ec
parente577b5667a3b3c6be030680d62e69ff539b97199 (diff)
downloadmariadb-git-e52a237fe9a8884ce6da18436a4cf50cfd9dbd45.tar.gz
remove ifdefs around PSI_THREAD_CALL
same change as for PSI_TABLE_CALL
-rw-r--r--include/mysql/psi/mysql_thread.h29
-rw-r--r--libmysqld/lib_sql.cc2
-rw-r--r--mysys/my_thr_init.c4
-rw-r--r--sql/mysqld.cc22
-rw-r--r--sql/sql_acl.cc8
-rw-r--r--sql/sql_class.h20
-rw-r--r--sql/threadpool_common.cc16
-rw-r--r--storage/innobase/include/srv0srv.h8
-rw-r--r--storage/maria/ma_checkpoint.c4
9 files changed, 54 insertions, 59 deletions
diff --git a/include/mysql/psi/mysql_thread.h b/include/mysql/psi/mysql_thread.h
index 54a0eaabef7..258e283afe6 100644
--- a/include/mysql/psi/mysql_thread.h
+++ b/include/mysql/psi/mysql_thread.h
@@ -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
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 25ef6e9b18e..53506de96ad 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -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
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 678bfc459c7..42d144b3856 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -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
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index afbde520f7c..b58440ed729 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -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);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 12ed22f6f32..f402892e18e 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -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);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index dbc300ab52f..5c8079f6b77 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -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()); }
diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc
index fb9e61f9a05..e5ac4b49a2a 100644
--- a/sql/threadpool_common.cc
+++ b/sql/threadpool_common.cc
@@ -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. */
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 580a660cedc..4c47ea393f5 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -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)
diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c
index 0933ca7d736..06d48569b2a 100644
--- a/storage/maria/ma_checkpoint.c
+++ b/storage/maria/ma_checkpoint.c
@@ -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