MXS-1625 Move tmp table management to QueryClassifier
Eventually only managed by QueryClassifier.
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
#include <maxscale/cppdefs.hh>
|
||||
#include <string>
|
||||
#include <tr1/memory>
|
||||
#include <tr1/unordered_set>
|
||||
#include <maxscale/router.h>
|
||||
#include <maxscale/session.h>
|
||||
|
||||
@ -27,6 +28,8 @@ class QueryClassifier
|
||||
QueryClassifier& operator = (const QueryClassifier&) = delete;
|
||||
|
||||
public:
|
||||
typedef std::tr1::unordered_set<std::string> TableSet;
|
||||
|
||||
// NOTE: For the time being these must be exactly like the ones in readwritesplit.hh
|
||||
enum
|
||||
{
|
||||
@ -88,6 +91,26 @@ public:
|
||||
m_have_tmp_tables = have_tmp_tables;
|
||||
}
|
||||
|
||||
void add_tmp_table(const std::string& table)
|
||||
{
|
||||
m_tmp_tables.insert(table);
|
||||
}
|
||||
|
||||
void remove_tmp_table(const std::string& table)
|
||||
{
|
||||
m_tmp_tables.erase(table);
|
||||
}
|
||||
|
||||
void clear_tmp_tables()
|
||||
{
|
||||
m_tmp_tables.clear();
|
||||
}
|
||||
|
||||
bool is_tmp_table(const std::string& table)
|
||||
{
|
||||
return m_tmp_tables.find(table) != m_tmp_tables.end();
|
||||
}
|
||||
|
||||
bool large_query() const
|
||||
{
|
||||
return m_large_query;
|
||||
@ -138,6 +161,7 @@ private:
|
||||
load_data_state_t m_load_data_state; /**< The LOAD DATA state */
|
||||
uint64_t m_load_data_sent; /**< How much data has been sent */
|
||||
bool m_have_tmp_tables;
|
||||
TableSet m_tmp_tables; /**< Set of temporary tables */
|
||||
bool m_large_query; /**< Set to true when processing payloads >= 2^24 bytes */
|
||||
bool m_multi_statements_allowed; /**< Are multi-statements allowed */
|
||||
SPSManager m_sPs_manager;
|
||||
|
@ -242,7 +242,7 @@ void check_create_tmp_table(RWSplitSession *router_cli_ses,
|
||||
}
|
||||
|
||||
/** Add the table to the set of temporary tables */
|
||||
router_cli_ses->m_temp_tables.insert(table);
|
||||
router_cli_ses->qc().add_tmp_table(table);
|
||||
|
||||
MXS_FREE(tblname);
|
||||
}
|
||||
@ -253,7 +253,7 @@ void check_create_tmp_table(RWSplitSession *router_cli_ses,
|
||||
*/
|
||||
bool find_table(RWSplitSession* rses, const std::string& table)
|
||||
{
|
||||
if (rses->m_temp_tables.find(table) != rses->m_temp_tables.end())
|
||||
if (rses->qc().is_tmp_table(table))
|
||||
{
|
||||
MXS_INFO("Query targets a temporary table: %s", table.c_str());
|
||||
return false;
|
||||
@ -335,7 +335,7 @@ bool is_read_tmp_table(RWSplitSession *rses,
|
||||
*/
|
||||
bool delete_table(RWSplitSession *rses, const std::string& table)
|
||||
{
|
||||
rses->m_temp_tables.erase(table);
|
||||
rses->qc().remove_tmp_table(table);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -780,7 +780,7 @@ void RWSplitSession::replace_master(SRWBackend& target)
|
||||
|
||||
// As the master has changed, we can reset the temporary table information
|
||||
m_qc.set_have_tmp_tables(false);
|
||||
m_temp_tables.clear();
|
||||
m_qc.clear_tmp_tables();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,7 +111,6 @@ public:
|
||||
int m_expected_responses; /**< Number of expected responses to the current query */
|
||||
GWBUF* m_query_queue; /**< Queued commands waiting to be executed */
|
||||
RWSplit* m_router; /**< The router instance */
|
||||
TableSet m_temp_tables; /**< Set of temporary tables */
|
||||
mxs::SessionCommandList m_sescmd_list; /**< List of executed session commands */
|
||||
ResponseMap m_sescmd_responses; /**< Response to each session command */
|
||||
SlaveResponseList m_slave_responses; /**< Slaves that replied before the master */
|
||||
|
Reference in New Issue
Block a user