diff --git a/dbms/src/Parsers/ParserSelectQuery.cpp b/dbms/src/Parsers/ParserSelectQuery.cpp index 7c6ff6316c0..209060bb377 100644 --- a/dbms/src/Parsers/ParserSelectQuery.cpp +++ b/dbms/src/Parsers/ParserSelectQuery.cpp @@ -71,16 +71,18 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) if (s_top.ignore(pos, expected)) { + ParserNumber num; + if (open_bracket.ignore(pos, expected)) { - if (!exp_elem.parse(pos, select_query->limit_length, expected)) + if (!num.parse(pos, select_query->limit_length, expected)) return false; if (!close_bracket.ignore(pos, expected)) return false; } else { - if (!exp_elem.parse(pos, select_query->limit_length, expected)) + if (!num.parse(pos, select_query->limit_length, expected)) return false; } } diff --git a/dbms/tests/queries/0_stateless/00834_limit_with_constant_expressions.sql b/dbms/tests/queries/0_stateless/00834_limit_with_constant_expressions.sql index 7f6d65979e7..12104145237 100644 --- a/dbms/tests/queries/0_stateless/00834_limit_with_constant_expressions.sql +++ b/dbms/tests/queries/0_stateless/00834_limit_with_constant_expressions.sql @@ -16,7 +16,7 @@ SELECT count() <= 1 FROM (SELECT number FROM numbers(10) LIMIT randConstant() % SELECT number FROM numbers(10) LIMIT 0 + 1 BY number; SELECT number FROM numbers(10) LIMIT 0 BY number; -SELECT TOP(3 + 2) number FROM numbers(10); +SELECT TOP 5 * FROM numbers(10); SELECT * FROM numbers(10) LIMIT 0.33 / 0.165 - 0.33 + 0.67; -- { serverError 440 } SELECT * FROM numbers(10) LIMIT LENGTH('NNN') + COS(0), toDate('0000-00-02'); -- { serverError 440 }