Active databases are only updated if they are found in the router's hashtable.

This commit is contained in:
Markus Makela 2014-12-08 16:35:47 +02:00
parent e76215bf07
commit 2ff3939ba2

View File

@ -1363,7 +1363,6 @@ void check_drop_tmp_table(
int tsize = 0, klen = 0,i;
char** tbl = NULL;
char *hkey,*dbname;
MYSQL_session* data;
ROUTER_CLIENT_SES* router_cli_ses = (ROUTER_CLIENT_SES *)router_session;
rses_property_t* rses_prop_tmp;
@ -1421,7 +1420,6 @@ skygw_query_type_t is_read_tmp_table(
int tsize = 0, klen = 0,i;
char** tbl = NULL;
char *hkey,*dbname;
MYSQL_session* data;
ROUTER_CLIENT_SES* router_cli_ses = (ROUTER_CLIENT_SES *)router_session;
skygw_query_type_t qtype = type;
@ -1500,9 +1498,7 @@ void check_create_tmp_table(
{
int klen = 0;
char *hkey,*dbname;
MYSQL_session* data;
ROUTER_CLIENT_SES* router_cli_ses = (ROUTER_CLIENT_SES *)router_session;
rses_property_t* rses_prop_tmp;
@ -1688,9 +1684,23 @@ static int routeQuery(
if(GWBUF_LENGTH(querybuf) <= MYSQL_DATABASE_MAXLEN - 5)
{
strncpy(router_cli_ses->rses_mysql_session->db,
packet + 5,
GWBUF_LENGTH(querybuf) - 5);
(char*)(packet + 5),
(int)(GWBUF_LENGTH(querybuf) - 5));
/**
* Update the session's active database only if it's in the hashtable.
* If it isn't found, send a custom error packet to the client.
*/
if(hashtable_fetch(inst->dbnames_hash,
(char*)router_cli_ses->rses_mysql_session->db) == NULL)
{
router_cli_ses->rses_mysql_session->db[0] = '\0';
/**TODO: Add error packet*/
}
}
case MYSQL_COM_REFRESH: /*< 7 - I guess this is session but not sure */