diff options
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r-- | sql/sys_vars.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index d6b1c76ea00..fd724bc7dd1 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3489,11 +3489,32 @@ static Sys_var_charptr Sys_version_compile_os( CMD_LINE_HELP_ONLY, IN_SYSTEM_CHARSET, DEFAULT(SYSTEM_TYPE)); +static char *guess_malloc_library() +{ + if (strcmp(MALLOC_LIBRARY, "system") == 0) + { +#ifdef HAVE_DLOPEN + typedef int (*mallctl_type)(const char*, void*, size_t*, void*, size_t); + mallctl_type mallctl_func; + mallctl_func= (mallctl_type)dlsym(RTLD_DEFAULT, "mallctl"); + if (mallctl_func) + { + static char buf[128]; + char *ver; + size_t len = sizeof(ver); + mallctl_func("version", &ver, &len, NULL, 0); + strxnmov(buf, sizeof(buf)-1, "jemalloc ", ver, NULL); + return buf; + } +#endif + } + return const_cast<char*>(MALLOC_LIBRARY); +} static char *malloc_library; static Sys_var_charptr Sys_malloc_library( "version_malloc_library", "Version of the used malloc library", READ_ONLY GLOBAL_VAR(malloc_library), CMD_LINE_HELP_ONLY, - IN_SYSTEM_CHARSET, DEFAULT(MALLOC_LIBRARY)); + IN_SYSTEM_CHARSET, DEFAULT(guess_malloc_library())); #ifdef HAVE_YASSL #include <openssl/ssl.h> |