Remove multi-packet additions to response parsing

The additions to the packet parsing code weren't necessary once the
statement output change was reverted.
This commit is contained in:
Markus Mäkelä
2017-04-04 09:55:24 +03:00
parent 5037646846
commit 8fe31f360d
6 changed files with 64 additions and 105 deletions

View File

@ -719,65 +719,48 @@ static void diagnostics(MXS_ROUTER *instance, DCB *dcb)
*/
bool reply_is_complete(backend_ref_t* bref, GWBUF *buffer)
{
size_t offset = 0;
size_t len = gwbuf_length(buffer);
while (offset < len)
if (bref->reply_state == REPLY_STATE_START && !mxs_mysql_is_result_set(buffer))
{
if (bref->reply_state == REPLY_STATE_START &&
!mxs_mysql_is_result_set(buffer, offset))
if (!mxs_mysql_more_results_after_ok(buffer))
{
if (!mxs_mysql_more_results_after_ok(buffer, offset))
{
/** Not a result set, we have the complete response */
LOG_RS(bref, REPLY_STATE_DONE);
bref->reply_state = REPLY_STATE_DONE;
break;
}
/** Not a result set, we have the complete response */
LOG_RS(bref, REPLY_STATE_DONE);
bref->reply_state = REPLY_STATE_DONE;
}
}
else
{
bool more = false;
int old_eof = bref->reply_state == REPLY_STATE_RSET_ROWS ? 1 : 0;
uint8_t header[MYSQL_HEADER_LEN];
gwbuf_copy_data(buffer, offset, sizeof(header), header);
offset += MYSQL_GET_PAYLOAD_LEN(header) + MYSQL_HEADER_LEN;
int n_eof = modutil_count_signal_packets(buffer, old_eof, &more);
mysql_server_cmd_t cmd = mxs_mysql_current_command(bref->bref_dcb->session);
if (n_eof == 0)
{
/** Waiting for the EOF packet after the column definitions */
LOG_RS(bref, REPLY_STATE_RSET_COLDEF);
bref->reply_state = REPLY_STATE_RSET_COLDEF;
}
else if (n_eof == 1 && cmd != MYSQL_COM_FIELD_LIST)
{
/** Waiting for the EOF packet after the rows */
LOG_RS(bref, REPLY_STATE_RSET_ROWS);
bref->reply_state = REPLY_STATE_RSET_ROWS;
}
else
{
bool more = false;
int old_eof = bref->reply_state == REPLY_STATE_RSET_ROWS ? 1 : 0;
/** We either have a complete result set or a response to
* a COM_FIELD_LIST command */
ss_dassert(n_eof == 2 || (n_eof == 1 && cmd == MYSQL_COM_FIELD_LIST));
LOG_RS(bref, REPLY_STATE_DONE);
bref->reply_state = REPLY_STATE_DONE;
int n_eof = modutil_count_signal_packets(buffer, old_eof, &more, &offset);
mysql_server_cmd_t cmd = mxs_mysql_current_command(bref->bref_dcb->session);
if (n_eof == 0)
if (more)
{
/** Waiting for the EOF packet after the column definitions */
LOG_RS(bref, REPLY_STATE_RSET_COLDEF);
bref->reply_state = REPLY_STATE_RSET_COLDEF;
}
else if (n_eof == 1 && cmd != MYSQL_COM_FIELD_LIST)
{
/** Waiting for the EOF packet after the rows */
LOG_RS(bref, REPLY_STATE_RSET_ROWS);
bref->reply_state = REPLY_STATE_RSET_ROWS;
}
else
{
/** We either have a complete result set or a response to
* a COM_FIELD_LIST command */
ss_dassert(n_eof == 2 || (n_eof == 1 && cmd == MYSQL_COM_FIELD_LIST));
LOG_RS(bref, REPLY_STATE_DONE);
bref->reply_state = REPLY_STATE_DONE;
if (more)
{
/** The server will send more resultsets */
LOG_RS(bref, REPLY_STATE_START);
bref->reply_state = REPLY_STATE_START;
}
else
{
ss_dassert(offset == len);
break;
}
/** The server will send more resultsets */
LOG_RS(bref, REPLY_STATE_START);
bref->reply_state = REPLY_STATE_START;
}
}
}