dbms: fixed error with multiquery mode in Client [#METR-15975].

This commit is contained in:
Alexey Milovidov 2015-04-14 23:46:34 +03:00
parent 7415b65a55
commit 3a658e4b26
3 changed files with 26 additions and 8 deletions

View File

@ -9,7 +9,7 @@ namespace DB
/// Распарсить запрос или записать сообщение об ошибке в out_error_message.
ASTPtr tryParseQuery(
IParser & parser,
IParser::Pos begin,
IParser::Pos & pos, /// Сдвигается до конца распарсенного фрагмента.
IParser::Pos end,
std::string & out_error_message,
bool hilite,
@ -17,6 +17,13 @@ ASTPtr tryParseQuery(
/// Распарсить запрос или кинуть исключение с сообщением об ошибке.
ASTPtr parseQueryAndMovePosition(
IParser & parser,
IParser::Pos & pos, /// Сдвигается до конца распарсенного фрагмента.
IParser::Pos end,
const std::string & description);
ASTPtr parseQuery(
IParser & parser,
IParser::Pos begin,

View File

@ -653,7 +653,7 @@ private:
}
}
else
res = DB::parseQuery(parser, pos, end, "");
res = DB::parseQueryAndMovePosition(parser, pos, end, "");
if (is_interactive)
{

View File

@ -86,20 +86,20 @@ static std::string getSyntaxErrorMessage(
ASTPtr tryParseQuery(
IParser & parser,
IParser::Pos begin,
IParser::Pos & pos,
IParser::Pos end,
std::string & out_error_message,
bool hilite,
const std::string & description)
{
if (begin == end || *begin == ';')
if (pos == end || *pos == ';')
{
out_error_message = "Empty query";
return nullptr;
}
Expected expected = "";
IParser::Pos pos = begin;
IParser::Pos begin = pos;
IParser::Pos max_parsed_pos = pos;
ASTPtr res;
@ -116,14 +116,14 @@ ASTPtr tryParseQuery(
}
ASTPtr parseQuery(
ASTPtr parseQueryAndMovePosition(
IParser & parser,
IParser::Pos begin,
IParser::Pos & pos,
IParser::Pos end,
const std::string & description)
{
std::string error_message;
ASTPtr res = tryParseQuery(parser, begin, end, error_message, false, description);
ASTPtr res = tryParseQuery(parser, pos, end, error_message, false, description);
if (res)
return res;
@ -131,4 +131,15 @@ ASTPtr parseQuery(
throw Exception(error_message, ErrorCodes::SYNTAX_ERROR);
}
ASTPtr parseQuery(
IParser & parser,
IParser::Pos begin,
IParser::Pos end,
const std::string & description)
{
auto pos = begin;
return parseQueryAndMovePosition(parser, pos, end, description);
}
}