MXS-1379: Route conflicting queries to current shard
All conflicting queries are routed to the shard which contains the currently active database.
This commit is contained in:
@ -496,6 +496,8 @@ char* get_shard_target_name(ROUTER_INSTANCE* router,
|
|||||||
|
|
||||||
if (sz > 0)
|
if (sz > 0)
|
||||||
{
|
{
|
||||||
|
bool conflict = false;
|
||||||
|
|
||||||
for (i = 0; i < sz; i++)
|
for (i = 0; i < sz; i++)
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
@ -510,9 +512,11 @@ char* get_shard_target_name(ROUTER_INSTANCE* router,
|
|||||||
/** Warn about improper usage of the router */
|
/** Warn about improper usage of the router */
|
||||||
if (rval && strcmp(name, rval) != 0)
|
if (rval && strcmp(name, rval) != 0)
|
||||||
{
|
{
|
||||||
MXS_ERROR("Query targets databases on servers '%s' and '%s'. "
|
MXS_WARNING("Query targets databases on servers '%s' and '%s'. "
|
||||||
"Cross database queries across servers are not supported.",
|
"Cross database queries across servers are not supported. "
|
||||||
|
"Routing query to server with the current active database.",
|
||||||
rval, name);
|
rval, name);
|
||||||
|
conflict = true;
|
||||||
}
|
}
|
||||||
else if (rval == NULL)
|
else if (rval == NULL)
|
||||||
{
|
{
|
||||||
@ -525,6 +529,11 @@ char* get_shard_target_name(ROUTER_INSTANCE* router,
|
|||||||
MXS_FREE(dbnms[i]);
|
MXS_FREE(dbnms[i]);
|
||||||
}
|
}
|
||||||
MXS_FREE(dbnms);
|
MXS_FREE(dbnms);
|
||||||
|
|
||||||
|
if (conflict)
|
||||||
|
{
|
||||||
|
return (char*)hashtable_fetch(ht, client->current_db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the query is a show tables query with a specific database */
|
/* Check if the query is a show tables query with a specific database */
|
||||||
|
Reference in New Issue
Block a user