Merge branch '2.2' into develop

This commit is contained in:
Markus Mäkelä
2018-04-26 16:39:00 +03:00
7 changed files with 136 additions and 48 deletions

View File

@ -10,9 +10,9 @@ namespace maxscale
RWBackend::RWBackend(SERVER_REF* ref):
mxs::Backend(ref),
m_reply_state(REPLY_STATE_DONE),
m_large_packet(false),
m_modutil_state({}),
m_command(0),
m_open_cursor(false),
m_opening_cursor(false),
m_expected_rows(0)
{
}
@ -77,20 +77,15 @@ bool RWBackend::write(GWBUF* buffer, response_type type)
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
m_open_cursor = flags != 0;
m_opening_cursor = flags != 0;
}
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
uint8_t buf[4];
gwbuf_copy_data(buffer, MYSQL_PS_ID_OFFSET + MYSQL_PS_ID_SIZE, 4, buf);
m_expected_rows = gw_mysql_get_byte4(buf);
}
else
{
m_open_cursor = false;
}
}
}
@ -129,9 +124,7 @@ bool RWBackend::reply_is_complete(GWBUF *buffer)
if (current_command() == MXS_COM_STMT_FETCH)
{
bool more = false;
modutil_state state = {is_large_packet()};
int n_eof = modutil_count_signal_packets(buffer, 0, &more, &state);
set_large_packet(state.state);
int n_eof = modutil_count_signal_packets(buffer, 0, &more, &m_modutil_state);
// If the server responded with an error, n_eof > 0
if (n_eof > 0 || consume_fetched_rows(buffer))
@ -172,10 +165,8 @@ bool RWBackend::reply_is_complete(GWBUF *buffer)
else
{
bool more = false;
modutil_state state = {is_large_packet()};
int n_old_eof = get_reply_state() == REPLY_STATE_RSET_ROWS ? 1 : 0;
int n_eof = modutil_count_signal_packets(buffer, n_old_eof, &more, &state);
set_large_packet(state.state);
int n_eof = modutil_count_signal_packets(buffer, n_old_eof, &more, &m_modutil_state);
if (n_eof > 2)
{
@ -197,8 +188,9 @@ bool RWBackend::reply_is_complete(GWBUF *buffer)
/** Waiting for the EOF packet after the rows */
set_reply_state(REPLY_STATE_RSET_ROWS);
if (cursor_is_open())
if (is_opening_cursor())
{
set_cursor_opened();
MXS_INFO("Cursor successfully opened");
set_reply_state(REPLY_STATE_DONE);
}