sysown / proxysql

High-performance MySQL proxy with a GPL license.
http://www.proxysql.com
GNU General Public License v3.0
5.98k stars 974 forks source link

Regex match when replace pattern and negate_match_pattern flag are set but no replacement #1075

Open kartt opened 7 years ago

kartt commented 7 years ago

I'm not sure if this is a bug. I'm facing a problem wherein the query_rule is getting matched but replace_pattern is not getting applied.

Steps to reproduce:

Add query_rule as follows insert into mysql_query_rules(rule_id,active,match_pattern,negate_match_pattern,replace_pattern,apply) values (1, 1, '^select .* from test_table where id =.*', 1, 'select "RANDOM STUFF"', 1);

Now, my understanding is that

ProxySQL version - 1.3.4-15-gf70037c

Am I doing some mistake or "replace_pattern" and "negate_match_pattern" won't work together? Any help is very much appreciated.

Thanks.

renecannao commented 7 years ago

Hi @kartt . This is not a bug, but needs to be documented.

The replaces works replacing the match_pattern with replace_pattern . Since match_pattern doesn't match, no replace happens. In other words, if you use negate_match_pattern , the match+replace can't work. This is expected, but need to be documented.

Thanks

himanshutecstub commented 3 years ago

Hello I use proxysql 2.5 with same problem select hostgroup,username,count_star,digest_text,digest from stats_mysql_query_digest where digest_text like '%myproduct_url%'; Where some query not match with host group i set in query rule. My rule is INSERT INTO mysql_query_rules (rule_id,active,match_digest,destination_hostgroup,apply) VALUES(3,1,'.*(myproduct_url(.*))',5,1); but in below query is run from other host group delete from myproduct_url where (queue_id=?) After update rule check result after below query LOAD MYSQL QUERY RULES TO RUNTIME;SAVE MYSQL QUERY RULES TO DISK;SELECT * FROM stats_mysql_query_digest_reset; Also check with add digest in query_rule but not apply