diff --git a/system-test/maxtest/include/maxtest/mariadb_nodes.hh b/system-test/maxtest/include/maxtest/mariadb_nodes.hh index e2337b81a..cd03754b6 100644 --- a/system-test/maxtest/include/maxtest/mariadb_nodes.hh +++ b/system-test/maxtest/include/maxtest/mariadb_nodes.hh @@ -535,8 +535,14 @@ public: */ std::string cnf_server_name; -private: +protected: + /** + * @returns SELECT that returns anonymous users in such a way that each returned row + * can directly be given as argument to DROP USER. + */ + virtual std::string anonymous_users_query() const; +private: bool check_master_node(MYSQL* conn); bool bad_slave_thread_status(MYSQL* conn, const char* field, int node); }; diff --git a/system-test/maxtest/include/maxtest/xpand_nodes.hh b/system-test/maxtest/include/maxtest/xpand_nodes.hh index c723524ce..06bff4bc6 100644 --- a/system-test/maxtest/include/maxtest/xpand_nodes.hh +++ b/system-test/maxtest/include/maxtest/xpand_nodes.hh @@ -59,4 +59,7 @@ public: std::string block_command(int node) const override; std::string unblock_command(int node) const override; + +private: + std::string anonymous_users_query() const override; }; diff --git a/system-test/maxtest/src/mariadb_nodes.cc b/system-test/maxtest/src/mariadb_nodes.cc index 93b67f865..20078f3d6 100644 --- a/system-test/maxtest/src/mariadb_nodes.cc +++ b/system-test/maxtest/src/mariadb_nodes.cc @@ -1028,6 +1028,11 @@ std::vector Mariadb_nodes::get_all_server_ids() return rval; } +std::string Mariadb_nodes::anonymous_users_query() const +{ + return "SELECT CONCAT('\\'', user, '\\'@\\'', host, '\\'') FROM mysql.user WHERE user = ''"; +} + bool Mariadb_nodes::prepare_for_test(MYSQL* conn) { int local_result = 0; @@ -1047,9 +1052,7 @@ bool Mariadb_nodes::prepare_for_test(MYSQL* conn) local_result++; } - if (mysql_query(conn, - "SELECT CONCAT('\\'', user, '\\'@\\'', host, '\\'') FROM mysql.user WHERE user = ''") - == 0) + if (mysql_query(conn, anonymous_users_query().c_str()) == 0) { MYSQL_RES* res = mysql_store_result(conn); diff --git a/system-test/maxtest/src/xpand_nodes.cpp b/system-test/maxtest/src/xpand_nodes.cpp index 129568169..c76594fb9 100644 --- a/system-test/maxtest/src/xpand_nodes.cpp +++ b/system-test/maxtest/src/xpand_nodes.cpp @@ -275,3 +275,8 @@ std::string Xpand_nodes::unblock_command(int node) const return command; } + +std::string Xpand_nodes::anonymous_users_query() const +{ + return "SELECT CONCAT('\\'', user, '\\'@\\'', host, '\\'') FROM system.users WHERE user = ''"; +}