Commit 9d5c9379 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-7780 - Support for faking server version

Added --version=str (optional argument sets server version string).
parent cc8e8633
......@@ -1124,7 +1124,8 @@ The following options may be given as the first argument:
CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS
tables in the INFORMATION_SCHEMA
-v, --verbose Used with --help option for detailed help.
-V, --version Output version information and exit.
-V, --version[=name]
Output version information and exit.
--wait-timeout=# The number of seconds the server waits for activity on a
connection before closing it
......
SELECT @@version;
@@version
my_favorite_version
1
--version="my_favorite_version"
SELECT @@version;
perl;
$cnt= grep /my_favorite_version/, `$ENV{MYSQL} -e status`;
print "$cnt\n";
EOF
......@@ -631,7 +631,7 @@ DATE_TIME_FORMAT global_date_format, global_datetime_format, global_time_format;
Time_zone *default_tz;
const char *mysql_real_data_home_ptr= mysql_real_data_home;
char server_version[SERVER_VERSION_LENGTH];
char server_version[SERVER_VERSION_LENGTH], *server_version_ptr;
char *mysqld_unix_port, *opt_mysql_tmpdir;
ulong thread_handling;
......@@ -7604,8 +7604,8 @@ struct my_option my_long_options[]=
0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Used with --help option for detailed help.",
&opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0},
{"plugin-load", OPT_PLUGIN_LOAD,
"Semicolon-separated list of plugins to load, where each plugin is "
"specified as ether a plugin_name=library_file pair or only a library_file. "
......@@ -8947,8 +8947,16 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument)
#include <sslopt-case.h>
#ifndef EMBEDDED_LIBRARY
case 'V':
print_version();
opt_abort= 1; // Abort after parsing all options
if (argument)
{
strmake(server_version, argument, sizeof(server_version) - 1);
set_sys_var_value_origin(&server_version_ptr, sys_var::CONFIG);
}
else
{
print_version();
opt_abort= 1; // Abort after parsing all options
}
break;
#endif /*EMBEDDED_LIBRARY*/
case 'W':
......@@ -9641,6 +9649,8 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
void set_server_version(void)
{
if (!IS_SYSVAR_AUTOSIZE(&server_version_ptr))
return;
char *end= strxmov(server_version, MYSQL_SERVER_VERSION,
MYSQL_SERVER_SUFFIX_STR, NullS);
#ifdef EMBEDDED_LIBRARY
......
......@@ -534,6 +534,7 @@ extern uint mysql_real_data_home_len;
extern const char *mysql_real_data_home_ptr;
extern ulong thread_handling;
extern "C" MYSQL_PLUGIN_IMPORT char server_version[SERVER_VERSION_LENGTH];
extern char *server_version_ptr;
extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[];
extern char mysql_unpacked_real_data_home[];
extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables;
......
......@@ -3368,7 +3368,6 @@ static Sys_var_mybool Sys_timed_mutexes(
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), ON_UPDATE(NULL),
DEPRECATED(""));
static char *server_version_ptr;
static Sys_var_charptr Sys_version(
"version", "Server version",
READ_ONLY GLOBAL_VAR(server_version_ptr),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment