[Commits] bffe83c: MDEV-7780 - Support for faking server version

Sergey Vojtovich svoj at mariadb.org
Tue Nov 24 17:57:58 EET 2015


revision-id: bffe83ce480705192bbfd4b85a68b8aad37394f7 (mariadb-10.1.8-74-gbffe83c)
parent(s): 2c29e85eafbf5bafe9c431accea9c25db7699eeb
committer: Sergey Vojtovich
timestamp: 2015-11-24 19:55:52 +0400
message:

MDEV-7780 - Support for faking server version

Added --version=str (optional argument sets server version string).

---
 mysql-test/suite/sys_vars/r/version.result |  3 +++
 mysql-test/suite/sys_vars/t/version.opt    |  1 +
 mysql-test/suite/sys_vars/t/version.test   |  1 +
 sql/mysqld.cc                              | 15 +++++++++++----
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/mysql-test/suite/sys_vars/r/version.result b/mysql-test/suite/sys_vars/r/version.result
new file mode 100644
index 0000000..86449d1
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/version.result
@@ -0,0 +1,3 @@
+SELECT @@version;
+@@version
+my_favorite_version
diff --git a/mysql-test/suite/sys_vars/t/version.opt b/mysql-test/suite/sys_vars/t/version.opt
new file mode 100644
index 0000000..9b6be9b
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/version.opt
@@ -0,0 +1 @@
+--version="my_favorite_version"
diff --git a/mysql-test/suite/sys_vars/t/version.test b/mysql-test/suite/sys_vars/t/version.test
new file mode 100644
index 0000000..3bc3f2b
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/version.test
@@ -0,0 +1 @@
+SELECT @@version;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 2559e07..e32ddf6 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -7600,8 +7600,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. "
@@ -8943,8 +8943,13 @@ 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)
+      strmov(server_version, argument);
+    else
+    {
+      print_version();
+      opt_abort= 1;                    // Abort after parsing all options
+    }
     break;
 #endif /*EMBEDDED_LIBRARY*/
   case 'W':
@@ -9637,6 +9642,8 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
 
 void set_server_version(void)
 {
+  if (*server_version)
+    return;
   char *end= strxmov(server_version, MYSQL_SERVER_VERSION,
                      MYSQL_SERVER_SUFFIX_STR, NullS);
 #ifdef EMBEDDED_LIBRARY


More information about the commits mailing list