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.
This commit is contained in:
Johan Wikman 2019-06-12 13:20:19 +03:00
parent c418bf81e1
commit d03e025046

View File

@ -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);