dbms: removed useless code [#METR-2944].

This commit is contained in:
Alexey Milovidov 2015-04-14 05:55:59 +03:00
parent c4ea83a906
commit cfd2d2aad5
7 changed files with 3 additions and 39 deletions

View File

@ -83,7 +83,6 @@ bool IParserNameTypePair<NameParser>::parseImpl(Pos & pos, Pos end, ASTPtr & nod
return true;
}
pos = begin;
return false;
}
@ -119,10 +118,6 @@ bool IParserColumnDeclaration<NameParser>::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<NameParser>::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;

View File

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

View File

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

View File

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

View File

@ -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<ASTIdentifier &>(*ident).name;
return true;
}
pos = begin;
return false;
}

View File

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

View File

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