MXS-1861 Detect and handle multistatement responses
Multi-statement SELECTs were properly detected and handled, but e.g. multi-statement UPDATESs were not, with the result that erronous warnings were logged. Now the responses are detected and handled properly.
This commit is contained in:
@ -131,7 +131,21 @@ void MaskingFilterSession::handle_response(GWBUF* pPacket)
|
|||||||
switch (response.type())
|
switch (response.type())
|
||||||
{
|
{
|
||||||
case ComResponse::OK_PACKET:
|
case ComResponse::OK_PACKET:
|
||||||
// We'll end up here also in the case of a multi-result.
|
{
|
||||||
|
ComOK ok(response);
|
||||||
|
|
||||||
|
if (ok.status() & SERVER_MORE_RESULTS_EXIST)
|
||||||
|
{
|
||||||
|
m_res.reset_multi();
|
||||||
|
m_state = EXPECTING_RESPONSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_state = EXPECTING_NOTHING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case ComResponse::LOCAL_INFILE_PACKET: // GET_MORE_CLIENT_DATA/SEND_MORE_CLIENT_DATA
|
case ComResponse::LOCAL_INFILE_PACKET: // GET_MORE_CLIENT_DATA/SEND_MORE_CLIENT_DATA
|
||||||
m_state = EXPECTING_NOTHING;
|
m_state = EXPECTING_NOTHING;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -658,6 +658,65 @@ private:
|
|||||||
uint16_t m_status;
|
uint16_t m_status;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ComOK : public ComResponse
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ComOK(GWBUF* pPacket)
|
||||||
|
: ComResponse(pPacket)
|
||||||
|
{
|
||||||
|
ss_dassert(m_type == OK_PACKET);
|
||||||
|
|
||||||
|
extract_payload();
|
||||||
|
}
|
||||||
|
|
||||||
|
ComOK(const ComResponse& response)
|
||||||
|
: ComResponse(response)
|
||||||
|
{
|
||||||
|
ss_dassert(m_type == OK_PACKET);
|
||||||
|
|
||||||
|
extract_payload();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t affected_rows() const
|
||||||
|
{
|
||||||
|
return m_affected_rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t last_insert_id() const
|
||||||
|
{
|
||||||
|
return m_last_insert_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t warnings() const
|
||||||
|
{
|
||||||
|
return m_warnings;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t status() const
|
||||||
|
{
|
||||||
|
return m_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void extract_payload()
|
||||||
|
{
|
||||||
|
m_affected_rows = LEncInt(&m_pData).value();
|
||||||
|
m_last_insert_id = LEncInt(&m_pData).value();
|
||||||
|
|
||||||
|
m_status = *m_pData++;
|
||||||
|
m_status += (*m_pData++ << 8);
|
||||||
|
|
||||||
|
m_warnings = *m_pData++;
|
||||||
|
m_warnings += (*m_pData++ << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint64_t m_affected_rows;
|
||||||
|
uint64_t m_last_insert_id;
|
||||||
|
uint16_t m_status;
|
||||||
|
uint16_t m_warnings;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class ComRequest
|
* @class ComRequest
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user