MXS-1824: Track only the opening of cursors
Whether a cursor is open or not does not matter as long as the attempt to open a cursor is detected.
This commit is contained in:
@ -596,8 +596,9 @@ bool reply_is_complete(SRWBackend& backend, GWBUF *buffer)
|
|||||||
LOG_RS(backend, REPLY_STATE_RSET_ROWS);
|
LOG_RS(backend, REPLY_STATE_RSET_ROWS);
|
||||||
backend->set_reply_state(REPLY_STATE_RSET_ROWS);
|
backend->set_reply_state(REPLY_STATE_RSET_ROWS);
|
||||||
|
|
||||||
if (backend->cursor_is_open())
|
if (backend->is_opening_cursor())
|
||||||
{
|
{
|
||||||
|
backend->set_cursor_opened();
|
||||||
MXS_INFO("Cursor successfully opened");
|
MXS_INFO("Cursor successfully opened");
|
||||||
LOG_RS(backend, REPLY_STATE_DONE);
|
LOG_RS(backend, REPLY_STATE_DONE);
|
||||||
backend->set_reply_state(REPLY_STATE_DONE);
|
backend->set_reply_state(REPLY_STATE_DONE);
|
||||||
|
|||||||
@ -19,7 +19,7 @@ RWBackend::RWBackend(SERVER_REF* ref):
|
|||||||
m_reply_state(REPLY_STATE_DONE),
|
m_reply_state(REPLY_STATE_DONE),
|
||||||
m_large_packet(false),
|
m_large_packet(false),
|
||||||
m_command(0),
|
m_command(0),
|
||||||
m_open_cursor(false),
|
m_opening_cursor(false),
|
||||||
m_expected_rows(0)
|
m_expected_rows(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -84,20 +84,15 @@ bool RWBackend::write(GWBUF* buffer, response_type type)
|
|||||||
gwbuf_copy_data(buffer, MYSQL_PS_ID_OFFSET + MYSQL_PS_ID_SIZE, 1, &flags);
|
gwbuf_copy_data(buffer, MYSQL_PS_ID_OFFSET + MYSQL_PS_ID_SIZE, 1, &flags);
|
||||||
|
|
||||||
// Any non-zero flag value means that we have an open cursor
|
// Any non-zero flag value means that we have an open cursor
|
||||||
m_open_cursor = flags != 0;
|
m_opening_cursor = flags != 0;
|
||||||
}
|
}
|
||||||
else if (cmd == MXS_COM_STMT_FETCH)
|
else if (cmd == MXS_COM_STMT_FETCH)
|
||||||
{
|
{
|
||||||
ss_dassert(m_open_cursor);
|
|
||||||
// Number of rows to fetch is a 4 byte integer after the ID
|
// Number of rows to fetch is a 4 byte integer after the ID
|
||||||
uint8_t buf[4];
|
uint8_t buf[4];
|
||||||
gwbuf_copy_data(buffer, MYSQL_PS_ID_OFFSET + MYSQL_PS_ID_SIZE, 4, buf);
|
gwbuf_copy_data(buffer, MYSQL_PS_ID_OFFSET + MYSQL_PS_ID_SIZE, 4, buf);
|
||||||
m_expected_rows = gw_mysql_get_byte4(buf);
|
m_expected_rows = gw_mysql_get_byte4(buf);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_open_cursor = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,9 +77,14 @@ public:
|
|||||||
return m_command;
|
return m_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool cursor_is_open() const
|
inline bool is_opening_cursor() const
|
||||||
{
|
{
|
||||||
return m_open_cursor;
|
return m_opening_cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void set_cursor_opened()
|
||||||
|
{
|
||||||
|
m_opening_cursor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -89,7 +94,7 @@ private:
|
|||||||
*calculation for result sets when the result
|
*calculation for result sets when the result
|
||||||
* contains very large rows */
|
* contains very large rows */
|
||||||
uint8_t m_command;
|
uint8_t m_command;
|
||||||
bool m_open_cursor; /**< Whether we have an open cursor */
|
bool m_opening_cursor; /**< Whether we are opening a cursor */
|
||||||
uint32_t m_expected_rows; /**< Number of rows a COM_STMT_FETCH is retrieving */
|
uint32_t m_expected_rows; /**< Number of rows a COM_STMT_FETCH is retrieving */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user