MXS-1506: Store queries inside RWSplitSession

As the readwritesplit is the only thing that uses the statement storage,
it can be integrated into RWSplitSession. This makes the code a lot
simpler.
This commit is contained in:
Markus Mäkelä
2018-04-04 17:35:07 +03:00
parent 53dec5323d
commit 450b31dd8c
5 changed files with 39 additions and 111 deletions

View File

@ -128,8 +128,6 @@ static MXS_SESSION* session_alloc_body(SERVICE* service, DCB* client_dcb,
session->service = service;
session->client_dcb = client_dcb;
session->stats.connect = time(0);
session->stmt.buffer = NULL;
session->stmt.target = NULL;
session->qualifies_for_pooling = false;
MXS_CONFIG *config = config_get_global_options();
@ -397,7 +395,6 @@ session_final_free(MXS_SESSION *session)
session_dump_statements(session);
}
gwbuf_free(session->stmt.buffer);
delete session->variables;
delete session->last_statements;
MXS_FREE(session);
@ -964,50 +961,6 @@ void session_put_ref(MXS_SESSION *session)
}
}
bool session_store_stmt(MXS_SESSION *session, GWBUF *buf, const SERVER *server)
{
bool rval = false;
if (session->stmt.buffer)
{
/** This should not happen with proper use */
ss_dassert(false);
gwbuf_free(session->stmt.buffer);
}
if ((session->stmt.buffer = gwbuf_clone(buf)))
{
session->stmt.target = server;
/** No old statements were stored and we successfully cloned the buffer */
rval = true;
}
return rval;
}
bool session_take_stmt(MXS_SESSION *session, GWBUF **buffer, const SERVER **target)
{
bool rval = false;
if (session->stmt.buffer && session->stmt.target)
{
*buffer = session->stmt.buffer;
*target = session->stmt.target;
session->stmt.buffer = NULL;
session->stmt.target = NULL;
rval = true;
}
return rval;
}
void session_clear_stmt(MXS_SESSION *session)
{
gwbuf_free(session->stmt.buffer);
session->stmt.buffer = NULL;
session->stmt.target = NULL;
}
uint64_t session_get_next_id()
{
return atomic_add_uint64(&next_session_id, 1);