Skip to content

Commit

Permalink
Merge branch 'v2.0.7' of https://github.com/sysown/proxysql into v2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
pondix committed Sep 30, 2019
2 parents 732586a + 6850b1b commit 4dd4ef5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/MySQL_Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ class MySQL_Threads_Handler
bool query_digests;
bool query_digests_lowercase;
bool query_digests_replace_null;
bool query_digests_no_digits;
bool query_digests_normalize_digest_text;
bool query_digests_track_hostname;
bool default_reconnect;
Expand Down
2 changes: 2 additions & 0 deletions include/proxysql_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ __thread bool mysql_thread___commands_stats;
__thread bool mysql_thread___query_digests;
__thread bool mysql_thread___query_digests_lowercase;
__thread bool mysql_thread___query_digests_replace_null;
__thread bool mysql_thread___query_digests_no_digits;
__thread bool mysql_thread___query_digests_normalize_digest_text;
__thread bool mysql_thread___query_digests_track_hostname;
__thread int mysql_thread___query_digests_max_digest_length;
Expand Down Expand Up @@ -836,6 +837,7 @@ extern __thread bool mysql_thread___servers_stats;
extern __thread bool mysql_thread___commands_stats;
extern __thread bool mysql_thread___query_digests;
extern __thread bool mysql_thread___query_digests_lowercase;
extern __thread bool mysql_thread___query_digests_no_digits;
extern __thread bool mysql_thread___query_digests_replace_null;
extern __thread bool mysql_thread___query_digests_normalize_digest_text;
extern __thread bool mysql_thread___query_digests_track_hostname;
Expand Down
19 changes: 19 additions & 0 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ static char * mysql_thread_variables_names[]= {
(char *)"query_digests",
(char *)"query_digests_lowercase",
(char *)"query_digests_replace_null",
(char *)"query_digests_no_digits",
(char *)"query_digests_normalize_digest_text",
(char *)"query_digests_track_hostname",
(char *)"servers_stats",
Expand Down Expand Up @@ -487,6 +488,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() {
variables.query_digests=true;
variables.query_digests_lowercase=false;
variables.query_digests_replace_null=false;
variables.query_digests_no_digits=false;
variables.query_digests_normalize_digest_text=false;
variables.query_digests_track_hostname=false;
variables.connpoll_reset_queue_length = 50;
Expand Down Expand Up @@ -843,6 +845,7 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) {
if (!strcmp(name,"query_digests")) return (int)variables.query_digests;
if (!strcmp(name,"query_digests_lowercase")) return (int)variables.query_digests_lowercase;
if (!strcmp(name,"query_digests_replace_null")) return (int)variables.query_digests_replace_null;
if (!strcmp(name,"query_digests_no_digits")) return (int)variables.query_digests_no_digits;
if (!strcmp(name,"query_digests_normalize_digest_text")) return (int)variables.query_digests_normalize_digest_text;
if (!strcmp(name,"query_digests_track_hostname")) return (int)variables.query_digests_track_hostname;
}
Expand Down Expand Up @@ -902,6 +905,7 @@ int MySQL_Threads_Handler::get_variable_int(const char *name) {
if (!strcmp(name,"query_digests")) return (int)variables.query_digests;
if (!strcmp(name,"query_digests_lowercase")) return (int)variables.query_digests_lowercase;
if (!strcmp(name,"query_digests_replace_null")) return (int)variables.query_digests_replace_null;
if (!strcmp(name,"query_digests_no_digits")) return (int)variables.query_digests_no_digits;
if (!strcmp(name,"query_digests_normalize_digest_text")) return (int)variables.query_digests_normalize_digest_text;
if (!strcmp(name,"query_digests_track_hostname")) return (int)variables.query_digests_track_hostname;
if (!strcmp(name,"connpoll_reset_queue_length")) return (int)variables.connpoll_reset_queue_length;
Expand Down Expand Up @@ -1446,6 +1450,9 @@ char * MySQL_Threads_Handler::get_variable(char *name) { // this is the public f
if (!strcasecmp(name,"query_digests_replace_null")) {
return strdup((variables.query_digests_replace_null ? "true" : "false"));
}
if (!strcasecmp(name,"query_digests_no_digits")) {
return strdup((variables.query_digests_no_digits ? "true" : "false"));
}
if (!strcasecmp(name,"query_digests_normalize_digest_text")) {
return strdup((variables.query_digests_normalize_digest_text ? "true" : "false"));
}
Expand Down Expand Up @@ -2793,6 +2800,17 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t
}
return false;
}
if (!strcasecmp(name,"query_digests_no_digits")) {
if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) {
variables.query_digests_no_digits=true;
return true;
}
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
variables.query_digests_no_digits=false;
return true;
}
return false;
}
if (!strcasecmp(name,"query_digests_normalize_digest_text")) {
if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) {
variables.query_digests_normalize_digest_text=true;
Expand Down Expand Up @@ -4475,6 +4493,7 @@ void MySQL_Thread::refresh_variables() {
mysql_thread___query_digests=(bool)GloMTH->get_variable_int((char *)"query_digests");
mysql_thread___query_digests_lowercase=(bool)GloMTH->get_variable_int((char *)"query_digests_lowercase");
mysql_thread___query_digests_replace_null=(bool)GloMTH->get_variable_int((char *)"query_digests_replace_null");
mysql_thread___query_digests_no_digits=(bool)GloMTH->get_variable_int((char *)"query_digests_no_digits");
mysql_thread___query_digests_normalize_digest_text=(bool)GloMTH->get_variable_int((char *)"query_digests_normalize_digest_text");
mysql_thread___query_digests_track_hostname=(bool)GloMTH->get_variable_int((char *)"query_digests_track_hostname");
variables.min_num_servers_lantency_awareness=GloMTH->get_variable_int((char *)"min_num_servers_lantency_awareness");
Expand Down
28 changes: 25 additions & 3 deletions lib/c_tokenizer.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* c_tokenizer.c */
// Borrowed from http://www.cplusplus.com/faq/sequences/strings/split/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Expand All @@ -12,6 +13,7 @@ extern __thread int mysql_thread___query_digests_max_query_length;
#define bool char
extern __thread bool mysql_thread___query_digests_lowercase;
extern __thread bool mysql_thread___query_digests_replace_null;
extern __thread bool mysql_thread___query_digests_no_digits;

void tokenizer(tokenizer_t *result, const char* s, const char* delimiters, int empties )
{
Expand Down Expand Up @@ -209,8 +211,10 @@ char *mysql_query_digest_and_first_comment(char *s, int _len, char **first_comme

bool lowercase=0;
bool replace_null=0;
bool replace_number=0;
lowercase=mysql_thread___query_digests_lowercase;
replace_null = mysql_thread___query_digests_replace_null;
replace_number = mysql_thread___query_digests_no_digits;

while(i < len)
{
Expand Down Expand Up @@ -253,9 +257,18 @@ char *mysql_query_digest_and_first_comment(char *s, int _len, char **first_comme
// may be digit - start with digit
else if(is_token_char(prev_char) && is_digit_char(*s))
{
flag = 5;
if(len == i+1)
continue;
if (replace_number) {
*p_r++ = '?';
while(*s != '\0' && is_digit_char(*s)) {
s++;
i++;
}
}
else {
flag = 5;
if(len == i+1)
continue;
}
}

// not above case - remove duplicated space char
Expand All @@ -275,6 +288,15 @@ char *mysql_query_digest_and_first_comment(char *s, int _len, char **first_comme
i++;
continue;
}
if (replace_number) {
if (!is_digit_char(prev_char) && is_digit_char(*s)) {
*p_r++ = '?';
while(*s != '\0' && is_digit_char(*s)) {
s++;
i++;
}
}
}
if (replace_null) {
if (*s == 'n' || *s == 'N') { // we search for NULL , #2171
if (i && is_token_char(prev_char)) {
Expand Down

0 comments on commit 4dd4ef5

Please sign in to comment.