diff --git a/dbms/include/DB/Parsers/ParserCreateQuery.h b/dbms/include/DB/Parsers/ParserCreateQuery.h index c287995290b..f86a62efe4d 100644 --- a/dbms/include/DB/Parsers/ParserCreateQuery.h +++ b/dbms/include/DB/Parsers/ParserCreateQuery.h @@ -83,7 +83,6 @@ bool IParserNameTypePair::parseImpl(Pos & pos, Pos end, ASTPtr & nod return true; } - pos = begin; return false; } @@ -119,10 +118,6 @@ bool IParserColumnDeclaration::parseImpl(Pos & pos, Pos end, ASTPtr ParserTernaryOperatorExpression expr_parser; const auto begin = pos; - const auto reset_pos_and_return = [&pos, begin] { - pos = begin; - return false; - }; /// mandatory column name ASTPtr name; @@ -160,10 +155,10 @@ bool IParserColumnDeclaration::parseImpl(Pos & pos, Pos end, ASTPtr ws.ignore(pos, end, max_parsed_pos, expected); if (!expr_parser.parse(pos, end, default_expression, max_parsed_pos, expected)) - return reset_pos_and_return(); + return false; } else if (!type) - return reset_pos_and_return(); /// reject sole column name without type + return false; /// reject sole column name without type const auto column_declaration = new ASTColumnDeclaration{StringRange{begin, pos}}; node = column_declaration; diff --git a/dbms/src/Interpreters/tests/logical_expressions_optimizer.cpp b/dbms/src/Interpreters/tests/logical_expressions_optimizer.cpp index ec9533961a2..b05abadc8ff 100644 --- a/dbms/src/Interpreters/tests/logical_expressions_optimizer.cpp +++ b/dbms/src/Interpreters/tests/logical_expressions_optimizer.cpp @@ -231,7 +231,7 @@ bool parse(DB::ASTPtr & ast, const std::string & query) { DB::ParserSelectQuery parser; std::string message; - ast = DB::tryParseQuery(parser, query.begin(), query.begin() + query.size(), message, false, ""); + ast = DB::tryParseQuery(parser, query.data(), query.data() + query.size(), message, false, ""); return !ast.isNull(); } diff --git a/dbms/src/Parsers/ExpressionElementParsers.cpp b/dbms/src/Parsers/ExpressionElementParsers.cpp index 6c2a2135f67..464763c2165 100644 --- a/dbms/src/Parsers/ExpressionElementParsers.cpp +++ b/dbms/src/Parsers/ExpressionElementParsers.cpp @@ -407,23 +407,18 @@ bool ParserStringLiteral::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max bool ParserLiteral::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) { - Pos begin = pos; - ParserNull null_p; ParserNumber num_p; ParserStringLiteral str_p; if (null_p.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; if (num_p.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; if (str_p.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; expected = "literal: one of nullptr, number, single quoted string"; return false; @@ -462,34 +457,27 @@ bool ParserExpressionElement::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & if (subquery_p.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; if (paren_p.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; if (array_p.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; if (lit_p.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; if (fun_p.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; if (id_p.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; if (asterisk_p.parse(pos, end, node, max_parsed_pos, expected)) { node = new ASTAsterisk(StringRange(begin, pos)); return true; } - pos = begin; expected = "expression element: one of array, literal, function, identifier, asterisk, parenthised expression, subquery"; return false; diff --git a/dbms/src/Parsers/ExpressionListParsers.cpp b/dbms/src/Parsers/ExpressionListParsers.cpp index 1d9ce2fafb4..404f25cd14b 100644 --- a/dbms/src/Parsers/ExpressionListParsers.cpp +++ b/dbms/src/Parsers/ExpressionListParsers.cpp @@ -330,10 +330,7 @@ bool ParserLambdaExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & ws.ignore(pos, end, max_parsed_pos, expected); if (!elem_parser.parse(pos, end, expression, max_parsed_pos, expected)) - { - pos = begin; return false; - } /// lambda(tuple(inner_arguments), expression) diff --git a/dbms/src/Parsers/ParserCreateQuery.cpp b/dbms/src/Parsers/ParserCreateQuery.cpp index 363a7d3b022..289b91fdd7c 100644 --- a/dbms/src/Parsers/ParserCreateQuery.cpp +++ b/dbms/src/Parsers/ParserCreateQuery.cpp @@ -54,20 +54,14 @@ bool ParserNestedTable::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_p bool ParserIdentifierWithParameters::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) { - Pos begin = pos; - ParserFunction function_or_array; if (function_or_array.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; - ParserNestedTable nested; if (nested.parse(pos, end, node, max_parsed_pos, expected)) return true; - pos = begin; - return false; } @@ -80,10 +74,7 @@ bool ParserIdentifierWithOptionalParameters::parseImpl(Pos & pos, Pos end, ASTPt Pos begin = pos; if (parametric.parse(pos, end, node, max_parsed_pos, expected)) - { return true; - } - pos = begin; ASTPtr ident; if (non_parametric.parse(pos, end, ident, max_parsed_pos, expected)) @@ -93,7 +84,6 @@ bool ParserIdentifierWithOptionalParameters::parseImpl(Pos & pos, Pos end, ASTPt func->name = typeid_cast(*ident).name; return true; } - pos = begin; return false; } diff --git a/dbms/src/Parsers/ParserShowTablesQuery.cpp b/dbms/src/Parsers/ParserShowTablesQuery.cpp index 6f843c8f4e4..1a0af9cebdd 100644 --- a/dbms/src/Parsers/ParserShowTablesQuery.cpp +++ b/dbms/src/Parsers/ParserShowTablesQuery.cpp @@ -76,10 +76,7 @@ bool ParserShowTablesQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & m return false; } else - { - pos = begin; return false; - } ws.ignore(pos, end); diff --git a/dbms/src/Parsers/ParserTablePropertiesQuery.cpp b/dbms/src/Parsers/ParserTablePropertiesQuery.cpp index 7ab8c77f203..6f0b1ef067c 100644 --- a/dbms/src/Parsers/ParserTablePropertiesQuery.cpp +++ b/dbms/src/Parsers/ParserTablePropertiesQuery.cpp @@ -44,10 +44,7 @@ bool ParserTablePropertiesQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Po ws.ignore(pos, end); if (!s_create.ignore(pos, end, max_parsed_pos, expected)) - { - pos = begin; return false; - } query_ptr = new ASTShowCreateQuery; }