Add functionality for bypassing MySQL whitespace/comments

This functionality is needed both in the query classifier, where
it was first created, and in the cache.
This commit is contained in:
Johan Wikman
2017-03-17 10:02:27 +02:00
parent 6db3cc380b
commit 7469c5be52
3 changed files with 166 additions and 0 deletions

View File

@ -53,9 +53,29 @@ GWBUF* modutil_create_mysql_err_msg(int packet_number,
int merrno,
const char *statemsg,
const char *msg);
int modutil_count_signal_packets(GWBUF*, int, int, int*);
mxs_pcre2_result_t modutil_mysql_wildcard_match(const char* pattern, const char* string);
/**
* Given a buffer containing a MySQL statement, this function will return
* a pointer to the first character that is not whitespace. In this context,
* comments are also counted as whitespace. For instance:
*
* "SELECT" => "SELECT"
* " SELECT => "SELECT"
* " / * A comment * / SELECT" => "SELECT"
* "-- comment\nSELECT" => "SELECT"
*
* @param sql Pointer to buffer containing a MySQL statement
* @param len Length of sql.
*
* @return The first non whitespace (including comments) character. If the
* entire buffer is only whitespace, the returned pointer will point
* to the character following the buffer (i.e. sql + len).
*/
char* modutil_MySQL_bypass_whitespace(char* sql, size_t len);
/** Character and token searching functions */
char* strnchr_esc(char* ptr, char c, int len);
char* strnchr_esc_mysql(char* ptr, char c, int len);