有些朋友问过的问题,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
}