Conflicts:
	server/modules/routing/dbshard/dbshard.c
This commit is contained in:
VilhoRaatikka 2014-12-12 21:08:21 +02:00
commit 600d29a6d1
2 changed files with 22 additions and 9 deletions

View File

@ -1448,10 +1448,11 @@ char** skygw_get_database_names(GWBUF* querybuf,int* size)
}
lex->current_select = lex->all_selects_list;
while(lex->current_select)
{
tbl = lex->current_select->join_list->head();
tbl = lex->current_select->table_list.first;
while(tbl)
{
if(strcmp(tbl->db,"skygw_virtual") != 0)

View File

@ -1865,7 +1865,19 @@ static int routeQuery(
* Find out whether the query should be routed to single server or to
* 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);
@ -1908,17 +1920,16 @@ static int routeQuery(
GWBUF *errbuff;
update_dbnames_hash(inst->servers,inst->dbnames_hash);
tname = get_shard_target_name(inst,router_cli_ses,querybuf);
if(tname == NULL &&
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
{
@ -1926,14 +1937,15 @@ static int routeQuery(
/**
* Bad shard status
*/
sprintf(errstr,"Unknown database '%s'",
router_cli_ses->rses_mysql_session->db);
errbuff = modutil_create_mysql_err_msg(1,0,1049,
"42000",
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);
}