summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2016-08-26 16:39:32 +0400
committerSergey Vojtovich <svoj@mariadb.org>2016-09-01 12:29:53 +0400
commitdd31e5c6ab0abc695099417bf015b6b661985b41 (patch)
treecda2a59e3f33035a5ba450241549e88ee40ba4c0
parent670760d504bebdf542df890f4d40f4cd3ff7a2c8 (diff)
downloadmariadb-git-dd31e5c6ab0abc695099417bf015b6b661985b41.tar.gz
MDEV-9593 - Print the real version in the error log
-rw-r--r--sql/mysqld.cc50
-rw-r--r--sql/mysqld.h2
-rw-r--r--sql/signal_handler.cc1
3 files changed, 30 insertions, 23 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 28e91e208e7..ea7bb2b5dcf 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4340,11 +4340,23 @@ static int init_common_variables()
if (get_options(&remaining_argc, &remaining_argv))
return 1;
- set_server_version();
+ if (IS_SYSVAR_AUTOSIZE(&server_version_ptr))
+ set_server_version(server_version, sizeof(server_version));
if (!opt_abort)
- sql_print_information("%s (mysqld %s) starting as process %lu ...",
- my_progname, server_version, (ulong) getpid());
+ {
+ if (IS_SYSVAR_AUTOSIZE(&server_version_ptr))
+ sql_print_information("%s (mysqld %s) starting as process %lu ...",
+ my_progname, server_version, (ulong) getpid());
+ else
+ {
+ char real_server_version[SERVER_VERSION_LENGTH];
+ set_server_version(real_server_version, sizeof(real_server_version));
+ sql_print_information("%s (mysqld %s as %s) starting as process %lu ...",
+ my_progname, real_server_version, server_version,
+ (ulong) getpid());
+ }
+ }
#ifndef EMBEDDED_LIBRARY
if (opt_abort && !opt_verbose)
@@ -8571,7 +8583,8 @@ static bool add_many_options(DYNAMIC_ARRAY *options, my_option *list,
#ifndef EMBEDDED_LIBRARY
static void print_version(void)
{
- set_server_version();
+ if (IS_SYSVAR_AUTOSIZE(&server_version_ptr))
+ set_server_version(server_version, sizeof(server_version));
printf("%s Ver %s for %s on %s (%s)\n",my_progname,
server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT);
@@ -9680,24 +9693,17 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
(MYSQL_SERVER_SUFFIX is set by the compilation environment)
*/
-void set_server_version(void)
-{
- if (!IS_SYSVAR_AUTOSIZE(&server_version_ptr))
- return;
- char *version_end= server_version+sizeof(server_version)-1;
- char *end= strxnmov(server_version, sizeof(server_version)-1,
- MYSQL_SERVER_VERSION,
- MYSQL_SERVER_SUFFIX_STR, NullS);
-#ifdef EMBEDDED_LIBRARY
- end= strnmov(end, "-embedded", (version_end-end));
-#endif
-#ifndef DBUG_OFF
- if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"))
- end= strnmov(end, "-debug", (version_end-end));
-#endif
- if (opt_log || global_system_variables.sql_log_slow || opt_bin_log)
- strnmov(end, "-log", (version_end-end)); // This may slow down system
- *end= 0;
+void set_server_version(char *buf, size_t size)
+{
+ bool is_log= opt_log || global_system_variables.sql_log_slow || opt_bin_log;
+ bool is_debug= IF_DBUG(!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"), 0);
+ strxnmov(buf, size - 1,
+ MYSQL_SERVER_VERSION,
+ MYSQL_SERVER_SUFFIX_STR,
+ IF_EMBEDDED("-embedded", ""),
+ is_debug ? "-debug" : "",
+ is_log ? "-log" : "",
+ NullS);
}
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 846a01a9427..602cc258943 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -774,7 +774,7 @@ inline void dec_thread_running()
thread_safe_decrement32(&thread_running);
}
-extern void set_server_version(void);
+extern void set_server_version(char *buf, size_t size);
#if defined(MYSQL_DYNAMIC_PLUGIN) && defined(_WIN32)
extern "C" THD *_current_thd_noinline();
diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc
index bbe714fc5b4..ae49e65bb1d 100644
--- a/sql/signal_handler.cc
+++ b/sql/signal_handler.cc
@@ -107,6 +107,7 @@ extern "C" sig_handler handle_fatal_signal(int sig)
"diagnose the problem, but since we have already crashed, \n"
"something is definitely wrong and this may fail.\n\n");
+ set_server_version(server_version, sizeof(server_version));
my_safe_printf_stderr("Server version: %s\n", server_version);
if (dflt_key_cache)