MXS-1625 Figure out multi statement state at startup

Whether or not multi statements are allowed is checked when
the QueryClassifier instance is created.
This commit is contained in:
Johan Wikman
2018-04-04 17:02:00 +03:00
parent 25386c4381
commit 8c0033ccb2
3 changed files with 26 additions and 6 deletions

View File

@ -48,6 +48,11 @@ public:
QueryClassifier(MXS_SESSION* pSession,
mxs_target_t use_sql_variables_in);
bool multi_statements_allowed() const
{
return m_multi_statements_allowed;
}
load_data_state_t load_data_state() const
{
return m_load_data_state;
@ -118,6 +123,7 @@ private:
load_data_state_t m_load_data_state;
bool m_have_tmp_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;
};

View File

@ -19,6 +19,21 @@
namespace
{
bool are_multi_statements_allowed(MXS_SESSION* pSession)
{
MySQLProtocol* pPcol = static_cast<MySQLProtocol*>(pSession->client_dcb->protocol);
if (pPcol->client_capabilities & GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS)
{
return true;
}
else
{
return false;
}
}
uint32_t get_prepare_type(GWBUF* buffer)
{
uint32_t type;
@ -189,6 +204,7 @@ QueryClassifier::QueryClassifier(MXS_SESSION* pSession,
, m_load_data_state(LOAD_DATA_INACTIVE)
, m_have_tmp_tables(false)
, m_large_query(false)
, m_multi_statements_allowed(are_multi_statements_allowed(pSession))
, m_sPs_manager(new PSManager)
{
}

View File

@ -403,13 +403,11 @@ inline bool have_semicolon(const char* ptr, int len)
* @param buf Buffer containing the full query
* @return True if the query contains multiple statements
*/
bool check_for_multi_stmt(GWBUF *buf, void *protocol, uint8_t packet_type)
bool check_for_multi_stmt(const QueryClassifier& qc, GWBUF *buf, uint8_t packet_type)
{
MySQLProtocol *proto = (MySQLProtocol *)protocol;
bool rval = false;
if (proto->client_capabilities & GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS &&
packet_type == MXS_COM_QUERY)
if (qc.multi_statements_allowed() && packet_type == MXS_COM_QUERY)
{
char *ptr, *data = (char*)GWBUF_DATA(buf) + 5;
/** Payload size without command byte */
@ -460,7 +458,7 @@ handle_multi_temp_and_load(RWSplitSession *rses, GWBUF *querybuf,
* situation, assigning QUERY_TYPE_WRITE for the query will trigger
* the error processing. */
if ((rses->m_target_node == NULL || rses->m_target_node != rses->m_current_master) &&
(check_for_multi_stmt(querybuf, rses->m_client->protocol, packet_type) ||
(check_for_multi_stmt(rses->qc(), querybuf, packet_type) ||
check_for_sp_call(querybuf, packet_type)))
{
if (rses->m_current_master && rses->m_current_master->in_use())