From 01ab0c873698c60254555bfcd936c50433edc4a0 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 67f544ad5..7ccf8af9b 100644 --- a/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y +++ b/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y @@ -960,7 +960,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);