MXS-1310: Route implicit table queries to the current shard

When a query that implicitly uses the current database is detected, it
will be routed to the shard which has the current database.
This commit is contained in:
Markus Mäkelä
2017-07-04 23:04:27 +03:00
parent 374c204a04
commit c6b579619a
2 changed files with 40 additions and 11 deletions

View File

@ -13,6 +13,8 @@
#include "shard_map.hh"
#include <algorithm>
#include <maxscale/alloc.h>
Shard::Shard():
@ -26,12 +28,14 @@ Shard::~Shard()
bool Shard::add_location(std::string db, SERVER* target)
{
std::transform(db.begin(), db.end(), db.begin(), ::tolower);
return m_map.insert(std::make_pair(db, target)).second;
}
SERVER* Shard::get_location(std::string db)
{
SERVER* rval = NULL;
std::transform(db.begin(), db.end(), db.begin(), ::tolower);
ServerMap::iterator iter = m_map.find(db);
if (iter != m_map.end())