MXS-2512 Update error information in additional place
An error may be returned directly or as part of a result set. Both cases must be handled.
This commit is contained in:
@ -218,7 +218,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void process_packets(GWBUF* buffer);
|
void process_packets(GWBUF* buffer);
|
||||||
void process_reply_start(mxs::Buffer::iterator it);
|
|
||||||
|
|
||||||
// Controlled by the session
|
// Controlled by the session
|
||||||
ResponseStat& response_stat();
|
ResponseStat& response_stat();
|
||||||
@ -245,6 +244,10 @@ private:
|
|||||||
bool m_skip_next = false;
|
bool m_skip_next = false;
|
||||||
Error m_error;
|
Error m_error;
|
||||||
|
|
||||||
|
void process_reply_start(mxs::Buffer::iterator it, uint32_t len);
|
||||||
|
|
||||||
|
void update_error(mxs::Buffer::iterator it, uint32_t len);
|
||||||
|
|
||||||
inline bool is_opening_cursor() const
|
inline bool is_opening_cursor() const
|
||||||
{
|
{
|
||||||
return m_opening_cursor;
|
return m_opening_cursor;
|
||||||
|
@ -241,7 +241,7 @@ bool is_last_eof(Iter it)
|
|||||||
return (status & SERVER_MORE_RESULTS_EXIST) == 0;
|
return (status & SERVER_MORE_RESULTS_EXIST) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RWBackend::process_reply_start(Iter it)
|
void RWBackend::process_reply_start(Iter it, uint32_t len)
|
||||||
{
|
{
|
||||||
uint8_t cmd = *it;
|
uint8_t cmd = *it;
|
||||||
m_local_infile_requested = false;
|
m_local_infile_requested = false;
|
||||||
@ -263,6 +263,8 @@ void RWBackend::process_reply_start(Iter it)
|
|||||||
|
|
||||||
case MYSQL_REPLY_ERR:
|
case MYSQL_REPLY_ERR:
|
||||||
// Nothing ever follows an error packet
|
// Nothing ever follows an error packet
|
||||||
|
++it;
|
||||||
|
update_error(it, len);
|
||||||
set_reply_state(REPLY_STATE_DONE);
|
set_reply_state(REPLY_STATE_DONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -319,7 +321,7 @@ void RWBackend::process_packets(GWBUF* result)
|
|||||||
switch (m_reply_state)
|
switch (m_reply_state)
|
||||||
{
|
{
|
||||||
case REPLY_STATE_START:
|
case REPLY_STATE_START:
|
||||||
process_reply_start(it);
|
process_reply_start(it, len);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REPLY_STATE_DONE:
|
case REPLY_STATE_DONE:
|
||||||
@ -359,18 +361,7 @@ void RWBackend::process_packets(GWBUF* result)
|
|||||||
else if (cmd == MYSQL_REPLY_ERR)
|
else if (cmd == MYSQL_REPLY_ERR)
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
uint16_t code = 0;
|
update_error(it, len);
|
||||||
code |= (*it++);
|
|
||||||
code |= (*it++) << 8;
|
|
||||||
++it;
|
|
||||||
auto sql_state_begin = it;
|
|
||||||
it.advance(5);
|
|
||||||
auto sql_state_end = it;
|
|
||||||
auto message_begin = it;
|
|
||||||
it.advance(len - (1 + 2 + 1 + 5));
|
|
||||||
auto message_end = it;
|
|
||||||
|
|
||||||
m_error.set(code, sql_state_begin, sql_state_end, message_begin, message_end);
|
|
||||||
set_reply_state(REPLY_STATE_DONE);
|
set_reply_state(REPLY_STATE_DONE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -462,4 +453,21 @@ mxs::SRWBackends RWBackend::from_servers(SERVER_REF* servers)
|
|||||||
|
|
||||||
return backends;
|
return backends;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RWBackend::update_error(mxs::Buffer::iterator it, uint32_t len)
|
||||||
|
{
|
||||||
|
uint16_t code = 0;
|
||||||
|
code |= (*it++);
|
||||||
|
code |= (*it++) << 8;
|
||||||
|
++it;
|
||||||
|
auto sql_state_begin = it;
|
||||||
|
it.advance(5);
|
||||||
|
auto sql_state_end = it;
|
||||||
|
auto message_begin = it;
|
||||||
|
it.advance(len - (1 + 2 + 1 + 5));
|
||||||
|
auto message_end = it;
|
||||||
|
|
||||||
|
m_error.set(code, sql_state_begin, sql_state_end, message_begin, message_end);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user