Merge branch '2.2' into develop

This commit is contained in:
Markus Mäkelä
2018-06-13 00:25:56 +03:00
12 changed files with 154 additions and 78 deletions

View File

@ -2915,10 +2915,15 @@ public:
dcb && atomic_load_int32(&m_more);
dcb = dcb->thread.next)
{
if (!m_func(dcb, m_data))
ss_dassert(dcb->session);
if (dcb->session->state != SESSION_STATE_DUMMY)
{
atomic_store_int32(&m_more, 0);
break;
if (!m_func(dcb, m_data))
{
atomic_store_int32(&m_more, 0);
break;
}
}
}
}

View File

@ -26,6 +26,22 @@ using namespace maxscale;
const int QC_TRACE_MSG_LEN = 1000;
// Copy of mxs_mysql_extract_ps_id() in modules/protocol/MySQL/mysql_common.cc,
// but we do not want to create a dependency from maxscale-common to that.
uint32_t mysql_extract_ps_id(GWBUF* buffer)
{
uint32_t rval = 0;
uint8_t id[MYSQL_PS_ID_SIZE];
if (gwbuf_copy_data(buffer, MYSQL_PS_ID_OFFSET, sizeof(id), id) == sizeof(id))
{
rval = gw_mysql_get_byte4(id);
}
return rval;
}
// Copied from mysql_common.c
// TODO: The current database should somehow be available in a generic fashion.
const char* qc_mysql_get_current_db(MXS_SESSION* session)
@ -285,6 +301,24 @@ public:
}
}
void erase(GWBUF* buffer)
{
uint8_t cmd = mxs_mysql_get_command(buffer);
if (cmd == MXS_COM_QUERY)
{
erase(get_text_ps_id(buffer));
}
else if (qc_mysql_is_ps_command(cmd))
{
erase(mysql_extract_ps_id(buffer));
}
else
{
ss_info_dassert(!true, "QueryClassifier::PSManager::erase called with invalid query");
}
}
private:
typedef std::tr1::unordered_map<uint32_t, uint32_t> BinaryPSMap;
typedef std::tr1::unordered_map<std::string, uint32_t> TextPSMap;
@ -328,14 +362,9 @@ uint32_t QueryClassifier::ps_get_type(std::string id) const
return m_sPs_manager->get_type(id);
}
void QueryClassifier::ps_erase(std::string id)
void QueryClassifier::ps_erase(GWBUF* buffer)
{
return m_sPs_manager->erase(id);
}
void QueryClassifier::ps_erase(uint32_t id)
{
return m_sPs_manager->erase(id);
return m_sPs_manager->erase(buffer);
}
uint32_t QueryClassifier::get_route_target(uint8_t command, uint32_t qtype, HINT* pHints)
@ -525,27 +554,6 @@ uint32_t QueryClassifier::get_route_target(uint8_t command, uint32_t qtype, HINT
return target;
}
namespace
{
// Copy of mxs_mysql_extract_ps_id() in modules/protocol/MySQL/mysql_common.cc,
// but we do not want to create a dependency from maxscale-common to that.
uint32_t mysql_extract_ps_id(GWBUF* buffer)
{
uint32_t rval = 0;
uint8_t id[MYSQL_PS_ID_SIZE];
if (gwbuf_copy_data(buffer, MYSQL_PS_ID_OFFSET, sizeof(id), id) == sizeof(id))
{
rval = gw_mysql_get_byte4(id);
}
return rval;
}
}
uint32_t QueryClassifier::ps_id_internal_get(GWBUF* pBuffer)
{
uint32_t internal_id = 0;

View File

@ -1631,7 +1631,7 @@ static bool reauthenticate_client(MXS_SESSION* session, GWBUF* packetbuf)
*/
static int route_by_statement(MXS_SESSION* session, uint64_t capabilities, GWBUF** p_readbuf)
{
int rc;
int rc = 1;
GWBUF* packetbuf;
do
{
@ -1738,6 +1738,7 @@ static int route_by_statement(MXS_SESSION* session, uint64_t capabilities, GWBUF
// Store the original COM_CHANGE_USER for later
proto->stored_query = packetbuf;
packetbuf = NULL;
rc = 1;
}
else if (proto->changing_user)
{

View File

@ -360,6 +360,10 @@ bool RWSplitSession::route_session_write(GWBUF *querybuf, uint8_t command, uint3
{
m_qc.ps_store(querybuf, id);
}
else if (qc_query_is_type(type, QUERY_TYPE_DEALLOC_PREPARE))
{
m_qc.ps_erase(querybuf);
}
MXS_INFO("Session write, routing to all servers.");