Merge branch 'develop' into tee_fixes

This commit is contained in:
Markus Makela
2015-03-06 18:27:41 +02:00
49 changed files with 4515 additions and 84 deletions

View File

@ -63,6 +63,23 @@ unsigned char *ptr;
return ptr[4] == 0x03; // COM_QUERY
}
/**
* Check if a GWBUF structure is a MySQL COM_STMT_PREPARE packet
*
* @param buf Buffer to check
* @return True if GWBUF is a COM_STMT_PREPARE packet
*/
int
modutil_is_SQL_prepare(GWBUF *buf)
{
unsigned char *ptr;
if (GWBUF_LENGTH(buf) < 5)
return 0;
ptr = GWBUF_DATA(buf);
return ptr[4] == 0x16 ; // COM_STMT_PREPARE
}
/**
* Extract the SQL portion of a COM_QUERY packet
*
@ -243,7 +260,7 @@ modutil_get_SQL(GWBUF *buf)
unsigned int len, length;
char *ptr, *dptr, *rval = NULL;
if (!modutil_is_SQL(buf))
if (!modutil_is_SQL(buf) && !modutil_is_SQL_prepare(buf))
return rval;
ptr = GWBUF_DATA(buf);
length = *ptr++;