From d03e025046b4b3af2974e956323eff84d9ab1dfb Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 12 Jun 2019 13:20:19 +0300 Subject: [PATCH] MXS-2553 Allow parenthesis around SELECT With this change, a parenthesized top-level SELECT, such as "(SELECT f FROM t)" will be fully parsed. Before this change, the statement was classified as invalid and would thus have been sent to the master. With this change also statements like (SELECT f FROM t1) UNION (SELECT f FROM t2) will be correctly classified, although only partially parsed. --- .../qc_sqlite/sqlite-src-3110100/src/parse.y | 11 +++++++++++ 1 file changed, 11 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 08318ba8d..5f26b05ef 100644 --- a/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y +++ b/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y @@ -959,7 +959,18 @@ cmd ::= DROP VIEW ifexists(E) fullname(X). { //////////////////////// The SELECT statement ///////////////////////////////// // +%ifdef MAXSCALE +%type pselect {Select*} +%destructor pselect {sqlite3SelectDelete(pParse->db, $$);} + +pselect(A) ::= LP pselect(X) RP. { A = X; } +pselect(A) ::= select(X). { A = X; } + +cmd ::= pselect(X). { +%endif +%ifndef MAXSCALE cmd ::= select(X). { +%endif SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0}; #ifdef MAXSCALE mxs_sqlite3Select(pParse, X, &dest);