MXS-2490: Add direct execution support

Certain MariaDB connectors will use the direct execution for batching
COM_STMT_PREPARE and COM_STMT_EXECUTE execution without waiting for the
COM_STMT_PREPARE to complete. In these cases the COM_STMT_EXECUTE (and
other COM_STMT commands as well) will use the special ID 0xffffffff. When
this is detected, it should be substituted with the ID of the latest
statement that was prepared.
This commit is contained in:
Markus Mäkelä
2019-07-09 14:59:52 +03:00
parent 5aa9daaeea
commit 8a176d64aa
4 changed files with 41 additions and 1 deletions

View File

@ -644,6 +644,13 @@ uint32_t QueryClassifier::ps_id_internal_get(GWBUF* pBuffer)
// All COM_STMT type statements store the ID in the same place
uint32_t external_id = mysql_extract_ps_id(pBuffer);
if (external_id == 0xffffffff)
{
// "Direct execution" that refers to the latest prepared statement
external_id = m_prev_ps_id;
}
auto it = m_ps_handles.find(external_id);
if (it != m_ps_handles.end())
@ -663,6 +670,7 @@ uint32_t QueryClassifier::ps_id_internal_get(GWBUF* pBuffer)
void QueryClassifier::ps_store_response(uint32_t internal_id, GWBUF* buffer)
{
auto external_id = qc_mysql_extract_ps_id(buffer);
m_prev_ps_id = external_id;
m_ps_handles[external_id] = internal_id;
if (auto param_count = qc_extract_ps_param_count(buffer))