From a9f07844b3aba4aa4ea109535df618a0cf598ce5 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 26 Sep 2019 16:51:21 +0300 Subject: [PATCH] MXS-2699 Accept '_[character_set] hex' as string The purpose is to recognize e.g. /_utf8mb4 0xD091D092D093/ as a valid string. The rule actually accepts /id integer/, but in case the statement is something else but an '_' immediately followed by a character set, followed by a hex number, it will be rejected by the server so no harm done. --- query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y b/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y index f24536295..0537d09f7 100644 --- a/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y +++ b/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y @@ -1926,6 +1926,13 @@ expr(A) ::= VARIABLE(X). { spanSet(&A, &X, &X); } %ifdef MAXSCALE +expr(A) ::= id(X) INTEGER(Y). { + // The sole purpose of this is to interpret something like '_utf8mb4 0xD091D092D093' + // as a string. It does not matter that any identifier followed by an integer will + // be interpreted as a string, as invalid usage will be caught by the server. + A.pExpr = sqlite3PExpr(pParse, TK_STRING, 0, 0, &Y); + spanSet(&A, &X, &Y); +} expr(A) ::= VARIABLE(X) variable_tail(Y). { // As we won't be executing any queries, we do not need to do // the things that are done above.