diff --git a/query_classifier/test/canonical_tests/canonizer.c b/query_classifier/test/canonical_tests/canonizer.c index da06c998d..3f5de1e1a 100644 --- a/query_classifier/test/canonical_tests/canonizer.c +++ b/query_classifier/test/canonical_tests/canonizer.c @@ -57,8 +57,8 @@ int main(int argc, char** argv) return 1; } - while (!feof(infile)) - { + while (!feof(infile) && fgets(readbuff, 4092, infile)) + { fgets(readbuff,4092,infile); char* nl = strchr(readbuff, '\n'); if(nl) diff --git a/query_classifier/test/canonical_tests/expected.sql b/query_classifier/test/canonical_tests/expected.sql index b0a712096..8dab956e8 100644 --- a/query_classifier/test/canonical_tests/expected.sql +++ b/query_classifier/test/canonical_tests/expected.sql @@ -15,4 +15,78 @@ delete from tst where lname like '?' and fname like '?'; select ? from tst where fname='?' or lname like '?'; select ?,?,?,? from tst where name='?' or name='?' or name='?' or name='?'; select count(?),count(?),count(?),count(?),count (?),count(?) from tst; -select count(?),count(?),count(?),count(?),count (?),count(?) from tst; +begin; +BEGIN +BEGIN; +commit; +COMMIT; +COMMIT; +CREATE DATABASE FOO; +CREATE EVENT myevent +CREATE FUNCTION hello (s CHAR(?)) +CREATE INDEX foo_t1 on T1 (id); +CREATE PROCEDURE simpleproc (OUT param1 INT) +CREATE TABLE myCity (a int, b char(?)); +create table t1 (id integer); +create table t1(id integer); +CREATE TABLE T1 (id integer); +CREATE TABLE T1 (id integer); +CREATE TABLE T2 (id integer); +CREATE TEMPORARY TABLE T1 (id integer); +DELETE FROM myCity; +DELETE FROM myCity; +DELIMITER ;// +DELIMITER //; +DO +DROP DATABASE FOO; +DROP DATABASE If EXISTS FOO; +DROP EVENT IF EXISTS myevent; +DROP EVENT myevent; +DROP FUNCTION hello; +DROP FUNCTION IF EXISTS hello; +DROP PROCEDURE IF EXISTS simpleproc; +DROP PROCEDURE simpleproc; +DROP TABLE IF EXISTS myCity; +drop table if exists t1; +DROP TABLE IF EXISTS T1; +DROP TABLE IF EXISTS T2; +DROP TABLE myCity; +drop table t1; +DROP TABLE T1; +DROP TABLE T2; +END // +INSERT INTO myCity VALUES (?, '?'); +INSERT INTO myCity VALUES (?, '?'); +insert into t1 values(?); +insert into t1 values(?); +INSERT INTO T2 VALUES (@@?); +ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL ? HOUR +RETURN CONCAT('?',s,'?'); +RETURNS CHAR(?) DETERMINISTIC +SELECT @?; +SELECT @?; +SELECT COUNT(*) FROM myCity; +select count(*) from t1; +select count(*) from t1; +select count(*) from user where user='?'; + SELECT COUNT(*) INTO param1 FROM t; +SELECT IF(@? <> @?,'?','?') AS result; +SELECT IF(id <> @?,'?','?') AS result FROM T2; +SELECT IF(@@? <> @?,'?','?') AS result; +SELECT (@@?) INTO @?; +set autocommit=?; +SET autocommit=?; +SET autocommit = ?; +set autocommit=?; +SET autocommit=?; +SET AUTOCOMMIT=?; +set autocommit=OFF; +SET autocommit = oFf; +SET autocommit = Off; +SET AUTOCOMMIT=oN; +START TRANSACTION; +UPDATE t1 SET id = id + ?; +use mysql; +use test; +USE test; +USE test; diff --git a/query_classifier/test/canonical_tests/input.sql b/query_classifier/test/canonical_tests/input.sql index 59e9a2496..74c912212 100644 --- a/query_classifier/test/canonical_tests/input.sql +++ b/query_classifier/test/canonical_tests/input.sql @@ -15,3 +15,78 @@ delete from tst where lname like '%man%' and fname like '%ard%'; select 100 from tst where fname='10' or lname like '%100%'; select 1,20,300,4000 from tst where name='1000' or name='200' or name='30' or name='4'; select count(1),count(10),count(100),count(2),count (20),count(200) from tst; +begin; +BEGIN +BEGIN; +commit; +COMMIT; +COMMIT; +CREATE DATABASE FOO; +CREATE EVENT myevent +CREATE FUNCTION hello (s CHAR(20)) +CREATE INDEX foo_t1 on T1 (id); +CREATE PROCEDURE simpleproc (OUT param1 INT) +CREATE TABLE myCity (a int, b char(20)); +create table t1 (id integer); +create table t1(id integer); +CREATE TABLE T1 (id integer); +CREATE TABLE T1 (id integer); +CREATE TABLE T2 (id integer); +CREATE TEMPORARY TABLE T1 (id integer); +DELETE FROM myCity; +DELETE FROM myCity; +DELIMITER ;// +DELIMITER //; +DO +DROP DATABASE FOO; +DROP DATABASE If EXISTS FOO; +DROP EVENT IF EXISTS myevent; +DROP EVENT myevent; +DROP FUNCTION hello; +DROP FUNCTION IF EXISTS hello; +DROP PROCEDURE IF EXISTS simpleproc; +DROP PROCEDURE simpleproc; +DROP TABLE IF EXISTS myCity; +drop table if exists t1; +DROP TABLE IF EXISTS T1; +DROP TABLE IF EXISTS T2; +DROP TABLE myCity; +drop table t1; +DROP TABLE T1; +DROP TABLE T2; +END // +INSERT INTO myCity VALUES (1, 'Milan'); +INSERT INTO myCity VALUES (2, 'London'); +insert into t1 values(1); +insert into t1 values(1); +INSERT INTO T2 VALUES (@@server_id); +ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR +RETURN CONCAT('Hello, ',s,'!'); +RETURNS CHAR(50) DETERMINISTIC +SELECT @a; +SELECT @a; +SELECT COUNT(*) FROM myCity; +select count(*) from t1; +select count(*) from t1; +select count(*) from user where user='maxuser'; + SELECT COUNT(*) INTO param1 FROM t; +SELECT IF(@a <> @TMASTER_ID,'OK (slave)','FAIL (master)') AS result; +SELECT IF(id <> @TMASTER_ID,'OK (slave)','FAIL (master)') AS result FROM T2; +SELECT IF(@@server_id <> @TMASTER_ID,'OK (slave)','FAIL (master)') AS result; +SELECT (@@server_id) INTO @a; +set autocommit=0; +SET autocommit=0; +SET autocommit = 0; +set autocommit=1; +SET autocommit=1; +SET AUTOCOMMIT=1; +set autocommit=OFF; +SET autocommit = oFf; +SET autocommit = Off; +SET AUTOCOMMIT=oN; +START TRANSACTION; +UPDATE t1 SET id = id + 1; +use mysql; +use test; +USE test; +USE test; diff --git a/utils/skygw_utils.cc b/utils/skygw_utils.cc index 56dc04d61..1b507a055 100644 --- a/utils/skygw_utils.cc +++ b/utils/skygw_utils.cc @@ -2033,7 +2033,8 @@ void skygw_file_close( static pcre2_code* replace_values_re = NULL; -static const PCRE2_SPTR replace_values_pattern = (PCRE2_SPTR) "(?i)([-=,+*/([:space:]]|\\b)([0-9.]+|NULL)([-=,+*/)[:space:];]|$)"; +static const PCRE2_SPTR replace_values_pattern = (PCRE2_SPTR) "(?i)([-=,+*/([:space:]]|\\b|[@])" + "(?:[0-9.]+|(?<=[@])[a-z_]+|NULL)([-=,+*/)[:space:];]|$)"; /** * Replace every literal number and NULL value with a question mark. @@ -2042,7 +2043,7 @@ static const PCRE2_SPTR replace_values_pattern = (PCRE2_SPTR) "(?i)([-=,+*/([:sp */ char* replace_values(const char* str) { - static const PCRE2_SPTR replace = (PCRE2_SPTR) "$1?$3"; + static const PCRE2_SPTR replace = (PCRE2_SPTR) "$1?$2"; pcre2_match_data* mdata; size_t orig_len = strlen(str); size_t len = orig_len;