diff options
-rw-r--r-- | include/my_global.h | 21 | ||||
-rw-r--r-- | include/my_sys.h | 3 | ||||
-rw-r--r-- | mysys/my_static.c | 9 | ||||
-rw-r--r-- | sql/mysqld.cc | 3 | ||||
-rw-r--r-- | sql/sql_class.cc | 11 | ||||
-rw-r--r-- | sql/sql_profile.cc | 3 | ||||
-rw-r--r-- | sql/sql_profile.h | 21 |
7 files changed, 42 insertions, 29 deletions
diff --git a/include/my_global.h b/include/my_global.h index 34b5a21beb2..6970fa5a0b6 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1518,7 +1518,7 @@ inline void operator delete[](void*, void*) { /* Do nothing */ } #if !defined(max) #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) -#endif +#endif /* Only Linux is known to need an explicit sync of the directory to make sure a file creation/deletion/renaming in(from,to) this directory durable. @@ -1531,4 +1531,23 @@ inline void operator delete[](void*, void*) { /* Do nothing */ } #define bool In_C_you_should_use_my_bool_instead() #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 */ diff --git a/include/my_sys.h b/include/my_sys.h index 12eb157a2b6..f8f941bbb0c 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -220,6 +220,9 @@ extern int (*fatal_error_handler_hook)(uint my_err, const char *str, extern uint my_file_limit; 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 extern my_bool my_use_large_pages; extern uint my_large_page_size; diff --git a/mysys/my_static.c b/mysys/my_static.c index ef25a89bad9..4dc965e8a20 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -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)= 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__ /* from my_getsystime.c */ ulonglong query_performance_frequency, query_performance_offset; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8906c4f3c09..730cabc4bda 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3709,6 +3709,9 @@ static int init_server_components() /* set up the hook before initializing plugins which may use it */ 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()) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 9f20ab242b3..7116c2bf71e 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -248,13 +248,16 @@ int thd_tablespace_op(const THD *thd) extern "C" -const char *set_thd_proc_info(THD *thd, const char *info, - const char *calling_function, - const char *calling_file, +const char *set_thd_proc_info(THD *thd, const char *info, + const char *calling_function, + const char *calling_file, const unsigned int calling_line) { + if (!thd) + thd= current_thd; + 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)")); #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER) thd->profiling.status_change(info, calling_function, calling_file, calling_line); diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index c62cf6401ba..6f234a2a626 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -38,9 +38,6 @@ #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. */ diff --git a/sql/sql_profile.h b/sql/sql_profile.h index b5537487d26..3ddec4e3811 100644 --- a/sql/sql_profile.h +++ b/sql/sql_profile.h @@ -16,27 +16,6 @@ #ifndef _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[]; 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); |