diff --git a/include/maxscale/protocol/mysql.h b/include/maxscale/protocol/mysql.h index d29c3785b..5e8a412f8 100644 --- a/include/maxscale/protocol/mysql.h +++ b/include/maxscale/protocol/mysql.h @@ -353,7 +353,7 @@ typedef struct int ignore_replies; /*< How many replies should be discarded */ GWBUF* stored_query; /*< Temporarily stored queries */ bool collect_result; /*< Collect the next result set as one buffer */ - int num_eof_packets; /*< Signal number to indicate is current packet is ok packet*/ + uint32_t num_eof_packets; /*< Signal number to indicate is current packet is ok packet*/ #if defined(SS_DEBUG) skygw_chk_t protocol_chk_tail; #endif diff --git a/server/modules/protocol/MySQL/mysql_common.cc b/server/modules/protocol/MySQL/mysql_common.cc index 420c7fc86..d1413ca78 100644 --- a/server/modules/protocol/MySQL/mysql_common.cc +++ b/server/modules/protocol/MySQL/mysql_common.cc @@ -1231,6 +1231,8 @@ create_capabilities(MySQLProtocol *conn, bool with_ssl, bool db_specified, bool } /** add session track */ final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_SESSION_TRACK; + /** support deprecate eof */ + final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_DEPRECATE_EOF; /* Compression is not currently supported */ ss_dassert(!compress); @@ -1855,30 +1857,30 @@ void mxs_mysql_get_session_track_info(GWBUF *buff, MySQLProtocol *proto) { while (gwbuf_copy_data(buff, offset, MYSQL_HEADER_LEN+1, header_and_command) == (MYSQL_HEADER_LEN+1)) { - size_t packet_len = gw_mysql_get_byte3(header_and_command) + MYSQL_HEADER_LEN; + size_t packet_len = gw_mysql_get_byte3(header_and_command); uint8_t cmd = header_and_command[MYSQL_COM_OFFSET]; - if (packet_len > MYSQL_OK_PACKET_MIN_LEN && cmd == MYSQL_REPLY_OK && proto->num_eof_packets == 0) - { - buff->gwbuf_type |= GWBUF_TYPE_REPLY_OK; - mxs_mysql_parse_ok_packet(buff, offset, packet_len); - } - offset += packet_len; - /* first packet of result set */ if ((proto->current_command == MXS_COM_QUERY || proto->current_command == MXS_COM_STMT_FETCH || proto->current_command == MXS_COM_STMT_EXECUTE) && - proto->num_eof_packets == 0 && - cmd > MYSQL_REPLY_OK && - cmd < MYSQL_REPLY_LOCAL_INFILE) + cmd == MYSQL_REPLY_EOF) { - proto->num_eof_packets = 2; + proto->num_eof_packets++; } - if (cmd == MYSQL_REPLY_EOF && proto->num_eof_packets > 0) + if (packet_len > MYSQL_OK_PACKET_MIN_LEN && + (proto->num_eof_packets % 2) == 0) { - proto->num_eof_packets--; + /* ok packet or deprecated eof */ + if (cmd == MYSQL_REPLY_OK || + (cmd == MYSQL_REPLY_EOF && + proto->server_capabilities & GW_MYSQL_CAPABILITIES_DEPRECATE_EOF)) + { + buff->gwbuf_type |= GWBUF_TYPE_REPLY_OK; + mxs_mysql_parse_ok_packet(buff, offset, packet_len); + } } + offset += (packet_len + + MYSQL_HEADER_LEN); } } }