Merge branch '2.2' into develop
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <tr1/memory>
|
||||
|
||||
#include <maxscale/backend.hh>
|
||||
#include <maxscale/modutil.h>
|
||||
|
||||
namespace maxscale
|
||||
{
|
||||
@ -69,37 +70,30 @@ public:
|
||||
// For COM_STMT_FETCH processing
|
||||
bool consume_fetched_rows(GWBUF* buffer);
|
||||
|
||||
inline void set_large_packet(bool value)
|
||||
{
|
||||
m_large_packet = value;
|
||||
}
|
||||
|
||||
inline bool is_large_packet() const
|
||||
{
|
||||
return m_large_packet;
|
||||
}
|
||||
|
||||
inline uint8_t current_command() const
|
||||
{
|
||||
return m_command;
|
||||
}
|
||||
|
||||
inline bool cursor_is_open() const
|
||||
{
|
||||
return m_open_cursor;
|
||||
}
|
||||
|
||||
bool reply_is_complete(GWBUF *buffer);
|
||||
|
||||
private:
|
||||
reply_state_t m_reply_state;
|
||||
BackendHandleMap m_ps_handles; /**< Internal ID to backend PS handle mapping */
|
||||
bool m_large_packet; /**< Used to store the state of the EOF packet
|
||||
*calculation for result sets when the result
|
||||
* contains very large rows */
|
||||
modutil_state m_modutil_state; /**< @see modutil_count_signal_packets */
|
||||
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 */
|
||||
|
||||
inline bool is_opening_cursor() const
|
||||
{
|
||||
return m_opening_cursor;
|
||||
}
|
||||
|
||||
inline void set_cursor_opened()
|
||||
{
|
||||
m_opening_cursor = false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -240,7 +240,6 @@ bool RWSplitSession::route_single_stmt(GWBUF *querybuf)
|
||||
/** Track the targets of the COM_STMT_EXECUTE statements. This
|
||||
* information is used to route all COM_STMT_FETCH commands
|
||||
* to the same server where the COM_STMT_EXECUTE was done. */
|
||||
ss_dassert(stmt_id > 0);
|
||||
m_exec_map[stmt_id] = target;
|
||||
MXS_INFO("COM_STMT_EXECUTE on %s: %s", target->name(), target->uri());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user