Commit ca23272e authored by Sergei Golubchik's avatar Sergei Golubchik

proc_info_hook, mysys access to thd->proc_info

include/my_global.h:
  move __func__ definition to my_global.h
include/my_sys.h:
  proc_info_hook
mysys/my_static.c:
  proc_info_hook
sql/mysqld.cc:
  proc_info_hook
sql/sql_class.cc:
  support thd==0 in set_thd_proc_info
sql/sql_profile.cc:
  move __func__ definition to my_global.h
sql/sql_profile.h:
  move __func__ definition to my_global.h
parent e2219ec9
...@@ -1531,4 +1531,23 @@ inline void operator delete[](void*, void*) { /* Do nothing */ } ...@@ -1531,4 +1531,23 @@ inline void operator delete[](void*, void*) { /* Do nothing */ }
#define bool In_C_you_should_use_my_bool_instead() #define bool In_C_you_should_use_my_bool_instead()
#endif #endif
/* Provide __func__ macro definition for platforms that miss it. */
#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
# else
# define __func__ "<unknown>"
# endif
#elif defined(_MSC_VER)
# if _MSC_VER < 1300
# define __func__ "<unknown>"
# else
# define __func__ __FUNCTION__
# endif
#elif defined(__BORLANDC__)
# define __func__ __FUNC__
#else
# define __func__ "<unknown>"
#endif
#endif /* my_global_h */ #endif /* my_global_h */
...@@ -220,6 +220,9 @@ extern int (*fatal_error_handler_hook)(uint my_err, const char *str, ...@@ -220,6 +220,9 @@ extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
extern uint my_file_limit; extern uint my_file_limit;
extern ulong my_thread_stack_size; extern ulong my_thread_stack_size;
extern const char *(*proc_info_hook)(void *, const char *, const char *,
const char *, const unsigned int);
#ifdef HAVE_LARGE_PAGES #ifdef HAVE_LARGE_PAGES
extern my_bool my_use_large_pages; extern my_bool my_use_large_pages;
extern uint my_large_page_size; extern uint my_large_page_size;
......
...@@ -92,6 +92,15 @@ int (*error_handler_hook)(uint error,const char *str,myf MyFlags)= ...@@ -92,6 +92,15 @@ int (*error_handler_hook)(uint error,const char *str,myf MyFlags)=
int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)= int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)=
my_message_no_curses; my_message_no_curses;
static const char *proc_info_dummy(void *a, const char *b, const char *c,
const char *d, const unsigned int e)
{
return 0;
}
const char *(*proc_info_hook)(void *, const char *, const char *, const char *,
const unsigned int)= proc_info_dummy;
#ifdef __WIN__ #ifdef __WIN__
/* from my_getsystime.c */ /* from my_getsystime.c */
ulonglong query_performance_frequency, query_performance_offset; ulonglong query_performance_frequency, query_performance_offset;
......
...@@ -3709,6 +3709,9 @@ static int init_server_components() ...@@ -3709,6 +3709,9 @@ static int init_server_components()
/* set up the hook before initializing plugins which may use it */ /* set up the hook before initializing plugins which may use it */
error_handler_hook= my_message_sql; error_handler_hook= my_message_sql;
proc_info_hook= (const char *(*)(void *, const char *, const char *,
const char *, const unsigned int))
set_thd_proc_info;
if (xid_cache_init()) if (xid_cache_init())
{ {
......
...@@ -253,6 +253,9 @@ const char *set_thd_proc_info(THD *thd, const char *info, ...@@ -253,6 +253,9 @@ const char *set_thd_proc_info(THD *thd, const char *info,
const char *calling_file, const char *calling_file,
const unsigned int calling_line) const unsigned int calling_line)
{ {
if (!thd)
thd= current_thd;
const char *old_info= thd->proc_info; const char *old_info= thd->proc_info;
DBUG_PRINT("proc_info", ("%s:%d %s", calling_file, calling_line, DBUG_PRINT("proc_info", ("%s:%d %s", calling_file, calling_line,
(info != NULL) ? info : "(null)")); (info != NULL) ? info : "(null)"));
......
...@@ -38,9 +38,6 @@ ...@@ -38,9 +38,6 @@
#define MAX_QUERY_LENGTH 300 #define MAX_QUERY_LENGTH 300
/* Reserved for systems that can't record the function name in source. */
const char * const _unknown_func_ = "<unknown>";
/** /**
Connects Information_Schema and Profiling. Connects Information_Schema and Profiling.
*/ */
......
...@@ -16,27 +16,6 @@ ...@@ -16,27 +16,6 @@
#ifndef _SQL_PROFILE_H #ifndef _SQL_PROFILE_H
#define _SQL_PROFILE_H #define _SQL_PROFILE_H
#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
# else
# define __func__ _unknown_func_
extern const char * const _unknown_func_;
# endif
#elif defined(_MSC_VER)
# if _MSC_VER < 1300
# define __func__ _unknown_func_
extern const char * const _unknown_func_;
# else
# define __func__ __FUNCTION__
# endif
#elif defined(__BORLANDC__)
# define __func__ __FUNC__
#else
# define __func__ _unknown_func_
extern const char * const _unknown_func_;
#endif
extern ST_FIELD_INFO query_profile_statistics_info[]; extern ST_FIELD_INFO query_profile_statistics_info[];
int fill_query_profile_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond); int fill_query_profile_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table); int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
......
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