Merge branch 'develop' into MAX-324

Conflicts:
	query_classifier/query_classifier.cc
This commit is contained in:
Markus Makela
2015-01-14 04:56:58 +02:00
27 changed files with 2086 additions and 99 deletions

View File

@ -31,7 +31,7 @@
#include <buffer.h>
#include <string.h>
#include <mysql_client_server_protocol.h>
#include <modutil.h>
/**
* Check if a GWBUF structure is a MySQL COM_QUERY packet
*
@ -493,3 +493,39 @@ GWBUF* modutil_get_next_MySQL_packet(
return_packetbuf:
return packetbuf;
}
/**
* Count the number of EOF, OK or ERR packets in the buffer.
* @param reply Buffer to use
* @param use_ok Whether the DEPRECATE_EOF flag is set
* @param n_found If there were previous packets found
* @return Number of EOF packets
*/
int
modutil_count_signal_packets(GWBUF *reply,int use_ok, int n_found)
{
unsigned char* ptr = (unsigned char*) reply->start;
unsigned char* end = (unsigned char*) reply->end;
int pktlen,pkt = 0;
while(ptr < end)
{
pktlen = gw_mysql_get_byte3(ptr) + 4;
if(PTR_IS_ERR(ptr) || (PTR_IS_EOF(ptr) && !use_ok) || (use_ok && PTR_IS_OK(ptr)))
{
if(n_found)
{
if(ptr + pktlen >= end)
pkt++;
}
else
{
pkt++;
}
}
ptr += pktlen;
}
return pkt;
}