有些朋友問過的問題,mysql中查詢版本號,有的是5.7.18,有的是 5.7.18-log ,有的是5.7.18-debug,如下
mysql> select @@version;
+------------------+
| @@version |
+------------------+
| 5.7.18-debug-log |
+------------------+
1 row in set (34.23 sec)
mysql> select @@version;
+------------------+
| @@version |
+------------------+
| 5.7.18-log |
+------------------+
1 row in set (1 min 27.10 sec)
mysql> select @@version;
+------------------+
| @@version |
+------------------+
| 5.7.18 |
+------------------+
1 row in set (1 min 27.10 sec)
這其實跟mysqld的編譯選項和啓動參數相關,代碼如下
main
mysqld_main(int, char**)
init_common_variables()
set_server_version()
邏輯就在函數set_server_version()
中,可以看到,在嵌入式中,還有可能是-embedded.
/*
Create version name for running mysqld version
We automaticly add suffixes -debug, -embedded, -log, -valgrind and -asan
to the version name to make the version more descriptive.
(MYSQL_SERVER_SUFFIX is set by the compilation environment)
*/
static void set_server_version(void)
{
char *end= strxmov(server_version, MYSQL_SERVER_VERSION,
MYSQL_SERVER_SUFFIX_STR, NullS);
#ifdef EMBEDDED_LIBRARY
end= my_stpcpy(end, "-embedded");
#endif
#ifndef DBUG_OFF
if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"))
end= my_stpcpy(end, "-debug");
#endif
if (opt_general_log || opt_slow_log || opt_bin_log)
end= my_stpcpy(end, "-log"); // This may slow down system
#ifdef HAVE_VALGRIND
if (SERVER_VERSION_LENGTH - (end - server_version) >
static_cast<int>(sizeof("-valgrind")))
end= my_stpcpy(end, "-valgrind");
#endif
#ifdef HAVE_ASAN
if (SERVER_VERSION_LENGTH - (end - server_version) >
static_cast<int>(sizeof("-asan")))
end= my_stpcpy(end, "-asan");
#endif
}