Merge branch 'MAX-324' of https://github.com/mariadb-corporation/MaxScale into MAX-324
Conflicts: server/modules/routing/dbshard/dbshard.c
This commit is contained in:
commit
600d29a6d1
@ -1448,10 +1448,11 @@ char** skygw_get_database_names(GWBUF* querybuf,int* size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lex->current_select = lex->all_selects_list;
|
lex->current_select = lex->all_selects_list;
|
||||||
|
|
||||||
while(lex->current_select)
|
while(lex->current_select)
|
||||||
{
|
{
|
||||||
tbl = lex->current_select->join_list->head();
|
tbl = lex->current_select->table_list.first;
|
||||||
|
|
||||||
while(tbl)
|
while(tbl)
|
||||||
{
|
{
|
||||||
if(strcmp(tbl->db,"skygw_virtual") != 0)
|
if(strcmp(tbl->db,"skygw_virtual") != 0)
|
||||||
|
@ -1865,7 +1865,19 @@ static int routeQuery(
|
|||||||
* Find out whether the query should be routed to single server or to
|
* Find out whether the query should be routed to single server or to
|
||||||
* all of them.
|
* all of them.
|
||||||
*/
|
*/
|
||||||
if((tname = get_shard_target_name(inst,router_cli_ses,querybuf)) != NULL)
|
if (packet_type == MYSQL_COM_INIT_DB)
|
||||||
|
{
|
||||||
|
char dbname[MYSQL_DATABASE_MAXLEN+1];
|
||||||
|
unsigned int plen = gw_mysql_get_byte3((unsigned char*)querybuf->start) - 1;
|
||||||
|
memcpy(dbname,querybuf->start + 5,plen);
|
||||||
|
dbname[plen] = '\0';
|
||||||
|
tname = hashtable_fetch(inst->dbnames_hash,dbname);
|
||||||
|
if(tname)
|
||||||
|
{
|
||||||
|
route_target = TARGET_NAMED_SERVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((tname = get_shard_target_name(inst,router_cli_ses,querybuf)) != NULL)
|
||||||
{
|
{
|
||||||
bool shard_ok = check_shard_status(inst,tname);
|
bool shard_ok = check_shard_status(inst,tname);
|
||||||
|
|
||||||
@ -1908,17 +1920,16 @@ static int routeQuery(
|
|||||||
GWBUF *errbuff;
|
GWBUF *errbuff;
|
||||||
|
|
||||||
update_dbnames_hash(inst->servers,inst->dbnames_hash);
|
update_dbnames_hash(inst->servers,inst->dbnames_hash);
|
||||||
|
tname = get_shard_target_name(inst,router_cli_ses,querybuf);
|
||||||
|
|
||||||
if(tname == NULL &&
|
if(tname == NULL &&
|
||||||
router_cli_ses->rses_mysql_session->db[0] == '\0')
|
router_cli_ses->rses_mysql_session->db[0] == '\0')
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* No current database or databases in query.
|
* No current database or databases in query, route to all.
|
||||||
*/
|
*/
|
||||||
|
route_target = TARGET_ALL;
|
||||||
|
|
||||||
errbuff = modutil_create_mysql_err_msg(1,0,1046,
|
|
||||||
"3D000",
|
|
||||||
"No database selected");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1926,14 +1937,15 @@ static int routeQuery(
|
|||||||
/**
|
/**
|
||||||
* Bad shard status
|
* Bad shard status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sprintf(errstr,"Unknown database '%s'",
|
sprintf(errstr,"Unknown database '%s'",
|
||||||
router_cli_ses->rses_mysql_session->db);
|
router_cli_ses->rses_mysql_session->db);
|
||||||
errbuff = modutil_create_mysql_err_msg(1,0,1049,
|
errbuff = modutil_create_mysql_err_msg(1,0,1049,
|
||||||
"42000",
|
"42000",
|
||||||
errstr);
|
errstr);
|
||||||
|
gwbuf_free(querybuf);
|
||||||
|
return router_cli_ses->rses_client_dcb->func.write(router_cli_ses->rses_client_dcb,errbuff);
|
||||||
}
|
}
|
||||||
|
|
||||||
router_cli_ses->rses_client_dcb->func.write(router_cli_ses->rses_client_dcb,errbuff);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user