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:
Markus Mäkelä
2017-06-13 12:46:32 +03:00
parent dfc1d0a413
commit 1ffe04571c
3 changed files with 9 additions and 22 deletions

View File

@ -237,10 +237,6 @@ void rses_property_done(rses_property_t *prop)
mysql_sescmd_done(&prop->rses_prop_data.sescmd); mysql_sescmd_done(&prop->rses_prop_data.sescmd);
break; break;
case RSES_PROP_TYPE_TMPTABLES:
// Nothing to do
break;
default: default:
MXS_DEBUG("%lu [rses_property_done] Unknown property type %d " MXS_DEBUG("%lu [rses_property_done] Unknown property type %d "
"in property %p", pthread_self(), prop->rses_prop_type, prop); "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_INSTANCE* router = (ROUTER_INSTANCE*)router_inst;
ROUTER_CLIENT_SES* client_rses = new (std::nothrow) ROUTER_CLIENT_SES; 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 client_rses;
delete prop;
return NULL; return NULL;
} }
prop->rses_prop_rsession = client_rses;
client_rses->rses_chk_top = CHK_NUM_ROUTER_SES; client_rses->rses_chk_top = CHK_NUM_ROUTER_SES;
client_rses->rses_chk_tail = CHK_NUM_ROUTER_SES; client_rses->rses_chk_tail = CHK_NUM_ROUTER_SES;
client_rses->rses_closed = false; client_rses->rses_closed = false;
client_rses->rses_properties[RSES_PROP_TYPE_SESCMD] = NULL; client_rses->rses_properties[RSES_PROP_TYPE_SESCMD] = NULL;
client_rses->rses_properties[RSES_PROP_TYPE_TMPTABLES] = prop;
client_rses->router = router; client_rses->router = router;
client_rses->client_dcb = session->client_dcb; client_rses->client_dcb = session->client_dcb;
client_rses->have_tmp_tables = false; client_rses->have_tmp_tables = false;

View File

@ -61,8 +61,7 @@ enum rses_property_type_t
RSES_PROP_TYPE_UNDEFINED = -1, RSES_PROP_TYPE_UNDEFINED = -1,
RSES_PROP_TYPE_SESCMD = 0, RSES_PROP_TYPE_SESCMD = 0,
RSES_PROP_TYPE_FIRST = RSES_PROP_TYPE_SESCMD, RSES_PROP_TYPE_FIRST = RSES_PROP_TYPE_SESCMD,
RSES_PROP_TYPE_TMPTABLES, RSES_PROP_TYPE_LAST = RSES_PROP_TYPE_SESCMD,
RSES_PROP_TYPE_LAST = RSES_PROP_TYPE_TMPTABLES,
RSES_PROP_TYPE_COUNT = RSES_PROP_TYPE_LAST + 1 RSES_PROP_TYPE_COUNT = RSES_PROP_TYPE_LAST + 1
}; };
@ -156,8 +155,6 @@ struct mysql_sescmd_t
skygw_chk_t my_sescmd_chk_tail; skygw_chk_t my_sescmd_chk_tail;
}; };
typedef std::tr1::unordered_set<std::string> TableSet;
/** /**
* Property structure * 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 struct rses_prop_data // TODO: Remove the properties and integrate them into the session object
{ {
mysql_sescmd_t sescmd; mysql_sescmd_t sescmd;
TableSet temp_tables;
} rses_prop_data; } rses_prop_data;
rses_property_t* rses_prop_next; /**< next property of same type */ rses_property_t* rses_prop_next; /**< next property of same type */
skygw_chk_t rses_prop_chk_tail; skygw_chk_t rses_prop_chk_tail;
@ -238,6 +234,8 @@ struct rwsplit_config_t
* been idle for too long */ * been idle for too long */
}; };
typedef std::tr1::unordered_set<std::string> TableSet;
/** /**
* The client session structure used within this router. * 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 */ GWBUF* query_queue; /**< Queued commands waiting to be executed */
struct ROUTER_INSTANCE *router; /**< The router instance */ struct ROUTER_INSTANCE *router; /**< The router instance */
struct ROUTER_CLIENT_SES *next; struct ROUTER_CLIENT_SES *next;
TableSet temp_tables; /**< Set of temporary tables */
skygw_chk_t rses_chk_tail; skygw_chk_t rses_chk_tail;
}; };

View File

@ -63,8 +63,7 @@ void check_drop_tmp_table(ROUTER_CLIENT_SES *router_cli_ses, GWBUF *querybuf)
table += info[i].table; table += info[i].table;
} }
rses_property_t* prop = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES]; router_cli_ses->temp_tables.erase(table);
prop->rses_prop_data.temp_tables.erase(table);
} }
} }
} }
@ -104,10 +103,8 @@ bool is_read_tmp_table(ROUTER_CLIENT_SES *router_cli_ses,
table += info[i].table; table += info[i].table;
} }
rses_property_t* prop = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES]; if (router_cli_ses->temp_tables.find(table) !=
router_cli_ses->temp_tables.end())
if (prop->rses_prop_data.temp_tables.find(table) !=
prop->rses_prop_data.temp_tables.end())
{ {
rval = true; rval = true;
MXS_INFO("Query targets a temporary table: %s", table.c_str()); 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 */ /** Add the table to the set of temporary tables */
rses_property_t* prop = router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES]; router_cli_ses->temp_tables.insert(table);
prop->rses_prop_data.temp_tables.insert(table);
MXS_FREE(tblname); MXS_FREE(tblname);
} }