Skip to content

Commit

Permalink
Merge branch '2.4' into 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Wikman committed Nov 18, 2020
2 parents 9015bcd + 5fc7364 commit 3d6ce65
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions include/maxscale/server.hh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public:
UNKNOWN, /**< Not connected yet */
MYSQL, /**< MySQL 5.5 or later. */
MARIADB, /**< MariaDB 5.5 or later */
CLUSTRIX, /**< Clustrix node */
XPAND, /**< Xpand node */
BLR /**< Binlog router */
};

Expand Down Expand Up @@ -251,7 +251,7 @@ public:
virtual void set_replication_lag(int64_t lag) = 0;

// TODO: Don't expose this to the modules and instead destroy the server
// via ServerManager (currently needed by clustrixmon)
// via ServerManager (currently needed by xpandmon)
virtual void deactivate() = 0;

/**
Expand Down
6 changes: 3 additions & 3 deletions server/core/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -848,15 +848,15 @@ void Server::VersionInfo::set(uint64_t version, const std::string& version_str)
auto version_strz = version_str.c_str();
if (strcasestr(version_strz, "xpand") || strcasestr(version_strz, "clustrix"))
{
new_type = Type::CLUSTRIX;
new_type = Type::XPAND;
}
else if (strcasestr(version_strz, "binlogrouter"))
{
new_type = Type::BLR;
}
else if (strcasestr(version_strz, "mariadb"))
{
// Needs to be after Clustrix and BLR as their version strings may include "mariadb".
// Needs to be after Xpand and BLR as their version strings may include "mariadb".
new_type = Type::MARIADB;
}
else if (!version_str.empty())
Expand Down Expand Up @@ -895,7 +895,7 @@ const char* Server::VersionInfo::version_string() const
bool SERVER::VersionInfo::is_database() const
{
auto t = m_type;
return t == Type::MARIADB || t == Type::CLUSTRIX || t == Type::MYSQL;
return t == Type::MARIADB || t == Type::XPAND || t == Type::MYSQL;
}

const SERVER::VersionInfo& Server::info() const
Expand Down
8 changes: 4 additions & 4 deletions server/modules/authenticator/MariaDBAuth/dbusers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ static const char mysqlauth_skip_auth_query[] =
" WHERE user = '%s' AND (anydb = '1' OR '%s' IN ('', 'information_schema') OR '%s' LIKE db)"
" LIMIT 1";

const char* clustrix_users_query_format =
const char* xpand_users_query_format =
"SELECT u.username AS user, u.host, a.dbname AS db, "
" IF(a.privileges & 1048576, 'Y', 'N') AS select_priv, u.password "
"FROM system.users AS u LEFT JOIN system.user_acl AS a ON (u.user = a.role) "
"WHERE u.plugin IN ('', 'mysql_native_password') %s";

static char* get_clustrix_users_query(bool include_root)
static char* get_xpand_users_query(bool include_root)
{
const char* with_root;

Expand All @@ -64,10 +64,10 @@ static char* get_clustrix_users_query(bool include_root)
with_root = "AND u.username <> 'root'";
}

size_t n_bytes = snprintf(NULL, 0, clustrix_users_query_format, with_root);
size_t n_bytes = snprintf(NULL, 0, xpand_users_query_format, with_root);
char* rval = static_cast<char*>(MXS_MALLOC(n_bytes + 1));
MXS_ABORT_IF_NULL(rval);
snprintf(rval, n_bytes + 1, clustrix_users_query_format, with_root);
snprintf(rval, n_bytes + 1, xpand_users_query_format, with_root);

return rval;
}
26 changes: 13 additions & 13 deletions server/modules/protocol/MariaDB/user_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const string my_grants_query = "SHOW GRANTS;";
const string current_user_query = "SELECT current_user();";
}

namespace clustrix_queries
namespace xpand_queries
{
const string users_query = "SELECT * FROM system.users;";
const string db_grants_query = "SELECT u.username, u.host, a.dbname, a.privileges FROM system.user_acl AS a "
Expand Down Expand Up @@ -339,8 +339,8 @@ bool MariaDBUserManager::update_users()
load_result = load_users_mariadb(con, srv, &temp_userdata);
break;

case ServerType::CLUSTRIX:
load_result = load_users_clustrix(con, srv, &temp_userdata);
case ServerType::XPAND:
load_result = load_users_xpand(con, srv, &temp_userdata);
break;

case ServerType::UNKNOWN:
Expand Down Expand Up @@ -453,10 +453,10 @@ MariaDBUserManager::load_users_mariadb(mxq::MariaDB& con, SERVER* srv, UserDatab
}

MariaDBUserManager::LoadResult
MariaDBUserManager::load_users_clustrix(mxq::MariaDB& con, SERVER* srv, UserDatabase* output)
MariaDBUserManager::load_users_xpand(mxq::MariaDB& con, SERVER* srv, UserDatabase* output)
{
using std::move;
vector<string> multiquery = {clustrix_queries::users_query, clustrix_queries::db_grants_query,
vector<string> multiquery = {xpand_queries::users_query, xpand_queries::db_grants_query,
mariadb_queries::db_names_query};
auto rval = LoadResult::QUERY_FAILED;
auto multiq_result = con.multiquery(multiquery);
Expand All @@ -467,9 +467,9 @@ MariaDBUserManager::load_users_clustrix(mxq::MariaDB& con, SERVER* srv, UserData
QResult dbs_res = move(multiq_result[2]);

rval = LoadResult::INVALID_DATA;
if (read_users_clustrix(move(users_res), output))
if (read_users_xpand(move(users_res), output))
{
read_db_privs_clustrix(move(acl_res), output);
read_db_privs_xpand(move(acl_res), output);
read_databases(move(dbs_res), output);
rval = LoadResult::SUCCESS;
}
Expand All @@ -478,7 +478,7 @@ MariaDBUserManager::load_users_clustrix(mxq::MariaDB& con, SERVER* srv, UserData
}

/**
* Read user fetch results from MariaDB or MySQL server. Clustrix is handled by a different function.
* Read user fetch results from MariaDB or MySQL server. Xpand is handled by a different function.
*
* @param users Results from query
* @param srv_info Server version info
Expand Down Expand Up @@ -638,9 +638,9 @@ void MariaDBUserManager::read_databases(MariaDBUserManager::QResult dbs, UserDat
}
}

bool MariaDBUserManager::read_users_clustrix(QResult users, UserDatabase* output)
bool MariaDBUserManager::read_users_xpand(QResult users, UserDatabase* output)
{
// Clustrix users are listed different from MariaDB/MySQL. The users-table does not have privilege
// Xpand users are listed different from MariaDB/MySQL. The users-table does not have privilege
// information and may have multiple rows for the same username&host. Multiple rows with the same
// username&host need to be combined with the matching rows in the user_acl-table (with the
// "user"-column) to get all database grants for a given user account. Also, privileges are coded into
Expand All @@ -665,7 +665,7 @@ bool MariaDBUserManager::read_users_clustrix(QResult users, UserDatabase* output
auto existing_entry = output->find_mutable_entry_equal(username, host);
if (existing_entry)
{
// Entry exists, but password may be empty due to how Clustrix handles user data.
// Entry exists, but password may be empty due to how Xpand handles user data.
if (existing_entry->password.empty() && !pw.empty())
{
existing_entry->password = pw;
Expand All @@ -687,7 +687,7 @@ bool MariaDBUserManager::read_users_clustrix(QResult users, UserDatabase* output
return has_required_fields;
}

void MariaDBUserManager::read_db_privs_clustrix(QResult acl, UserDatabase* output)
void MariaDBUserManager::read_db_privs_xpand(QResult acl, UserDatabase* output)
{
auto ind_user = acl->get_col_index("username");
auto ind_host = acl->get_col_index("host");
Expand Down Expand Up @@ -881,7 +881,7 @@ void UserDatabase::add_entry(const std::string& username, UserEntry&& entry)
{
auto& entrylist = m_users[username];
// Find the correct spot to insert. If the hostname pattern already exists, do nothing. Copies should
// only exist when summing users from all servers or when processing Clustrix users.
// only exist when summing users from all servers or when processing Xpand users.
auto low_bound = std::lower_bound(entrylist.begin(), entrylist.end(), entry,
UserEntry::host_pattern_is_more_specific);
// lower_bound is the first valid (not "smaller") position to insert. It can be equal to the new element.
Expand Down
6 changes: 3 additions & 3 deletions server/modules/protocol/MariaDB/user_data.hh
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private:

bool update_users();
LoadResult load_users_mariadb(mxq::MariaDB& conn, SERVER* srv, UserDatabase* output);
LoadResult load_users_clustrix(mxq::MariaDB& con, SERVER* srv, UserDatabase* output);
LoadResult load_users_xpand(mxq::MariaDB& con, SERVER* srv, UserDatabase* output);

void updater_thread_function();

Expand All @@ -231,8 +231,8 @@ private:
void read_proxy_grants(QResult proxies, UserDatabase* output);
void read_databases(QResult dbs, UserDatabase* output);

bool read_users_clustrix(QResult users, UserDatabase* output);
void read_db_privs_clustrix(QResult acl, UserDatabase* output);
bool read_users_xpand(QResult users, UserDatabase* output);
void read_db_privs_xpand(QResult acl, UserDatabase* output);

void check_show_dbs_priv(mxq::MariaDB& con, const UserDatabase& userdata,
const char* servername);
Expand Down

0 comments on commit 3d6ce65

Please sign in to comment.