Integrate the temporary tables into the router session
Removed the temporary table router property and moved the set of tables into the router session.
This commit is contained in:
@ -237,10 +237,6 @@ void rses_property_done(rses_property_t *prop)
|
||||
mysql_sescmd_done(&prop->rses_prop_data.sescmd);
|
||||
break;
|
||||
|
||||
case RSES_PROP_TYPE_TMPTABLES:
|
||||
// Nothing to do
|
||||
break;
|
||||
|
||||
default:
|
||||
MXS_DEBUG("%lu [rses_property_done] Unknown property type %d "
|
||||
"in property %p", pthread_self(), prop->rses_prop_type, prop);
|
||||
@ -1019,21 +1015,17 @@ static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *router_inst, MXS_SESSION *sess
|
||||
{
|
||||
ROUTER_INSTANCE* router = (ROUTER_INSTANCE*)router_inst;
|
||||
ROUTER_CLIENT_SES* client_rses = new (std::nothrow) ROUTER_CLIENT_SES;
|
||||
rses_property_t* prop = rses_property_init(RSES_PROP_TYPE_TMPTABLES);
|
||||
|
||||
if (client_rses == NULL || prop == NULL)
|
||||
if (client_rses == NULL)
|
||||
{
|
||||
delete client_rses;
|
||||
delete prop;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prop->rses_prop_rsession = client_rses;
|
||||
client_rses->rses_chk_top = CHK_NUM_ROUTER_SES;
|
||||
client_rses->rses_chk_tail = CHK_NUM_ROUTER_SES;
|
||||
client_rses->rses_closed = false;
|
||||
client_rses->rses_properties[RSES_PROP_TYPE_SESCMD] = NULL;
|
||||
client_rses->rses_properties[RSES_PROP_TYPE_TMPTABLES] = prop;
|
||||
client_rses->router = router;
|
||||
client_rses->client_dcb = session->client_dcb;
|
||||
client_rses->have_tmp_tables = false;
|
||||
|
@ -61,8 +61,7 @@ enum rses_property_type_t
|
||||
RSES_PROP_TYPE_UNDEFINED = -1,
|
||||
RSES_PROP_TYPE_SESCMD = 0,
|
||||
RSES_PROP_TYPE_FIRST = RSES_PROP_TYPE_SESCMD,
|
||||
RSES_PROP_TYPE_TMPTABLES,
|
||||
RSES_PROP_TYPE_LAST = RSES_PROP_TYPE_TMPTABLES,
|
||||
RSES_PROP_TYPE_LAST = RSES_PROP_TYPE_SESCMD,
|
||||
RSES_PROP_TYPE_COUNT = RSES_PROP_TYPE_LAST + 1
|
||||
};
|
||||
|
||||
@ -156,8 +155,6 @@ struct mysql_sescmd_t
|
||||
skygw_chk_t my_sescmd_chk_tail;
|
||||
};
|
||||
|
||||
typedef std::tr1::unordered_set<std::string> TableSet;
|
||||
|
||||
/**
|
||||
* Property structure
|
||||
*/
|
||||
@ -171,7 +168,6 @@ struct rses_property_t
|
||||
struct rses_prop_data // TODO: Remove the properties and integrate them into the session object
|
||||
{
|
||||
mysql_sescmd_t sescmd;
|
||||
TableSet temp_tables;
|
||||
} rses_prop_data;
|
||||
rses_property_t* rses_prop_next; /**< next property of same type */
|
||||
skygw_chk_t rses_prop_chk_tail;
|
||||
@ -238,6 +234,8 @@ struct rwsplit_config_t
|
||||
* been idle for too long */
|
||||
};
|
||||
|
||||
typedef std::tr1::unordered_set<std::string> TableSet;
|
||||
|
||||
/**
|
||||
* The client session structure used within this router.
|
||||
*/
|
||||
@ -261,6 +259,7 @@ struct ROUTER_CLIENT_SES
|
||||
GWBUF* query_queue; /**< Queued commands waiting to be executed */
|
||||
struct ROUTER_INSTANCE *router; /**< The router instance */
|
||||
struct ROUTER_CLIENT_SES *next;
|
||||
TableSet temp_tables; /**< Set of temporary tables */
|
||||
skygw_chk_t rses_chk_tail;
|
||||
};
|
||||
|
||||
|
@ -63,8 +63,7 @@ void check_drop_tmp_table(ROUTER_CLIENT_SES *router_cli_ses, GWBUF *querybuf)
|
||||
table += info[i].table;
|
||||
}
|
||||
|
||||
rses_property_t* prop = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES];
|
||||
prop->rses_prop_data.temp_tables.erase(table);
|
||||
router_cli_ses->temp_tables.erase(table);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,10 +103,8 @@ bool is_read_tmp_table(ROUTER_CLIENT_SES *router_cli_ses,
|
||||
table += info[i].table;
|
||||
}
|
||||
|
||||
rses_property_t* prop = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES];
|
||||
|
||||
if (prop->rses_prop_data.temp_tables.find(table) !=
|
||||
prop->rses_prop_data.temp_tables.end())
|
||||
if (router_cli_ses->temp_tables.find(table) !=
|
||||
router_cli_ses->temp_tables.end())
|
||||
{
|
||||
rval = true;
|
||||
MXS_INFO("Query targets a temporary table: %s", table.c_str());
|
||||
@ -149,8 +146,7 @@ void check_create_tmp_table(ROUTER_CLIENT_SES *router_cli_ses,
|
||||
}
|
||||
|
||||
/** Add the table to the set of temporary tables */
|
||||
rses_property_t* prop = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES];
|
||||
prop->rses_prop_data.temp_tables.insert(table);
|
||||
router_cli_ses->temp_tables.insert(table);
|
||||
|
||||
MXS_FREE(tblname);
|
||||
}
|
||||
|
Reference in New Issue
Block a user