Forgot about 'WITH NAME …' statement part.

This commit is contained in:
Ivan Lezhankin 2018-11-01 14:16:04 +03:00
parent 935615a647
commit 126ff55fa7
3 changed files with 21 additions and 2 deletions

View File

@ -130,7 +130,13 @@ void ASTAlterCommand::formatImpl(
}
else if (type == ASTAlterCommand::FREEZE_ALL)
{
// TODO: implement this.
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << "FREEZE";
if (!with_name.empty())
{
settings.ostr << " " << (settings.hilite ? hilite_keyword : "") << "WITH NAME" << (settings.hilite ? hilite_none : "")
<< " " << std::quoted(with_name, '\'');
}
}
else if (type == ASTAlterCommand::DELETE)
{

View File

@ -183,6 +183,19 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
}
else
{
/// WITH NAME 'name' - place local backup to directory with specified name
if (s_with.ignore(pos, expected))
{
if (!s_name.ignore(pos, expected))
return false;
ASTPtr ast_with_name;
if (!parser_string_literal.parse(pos, ast_with_name, expected))
return false;
command->with_name = typeid_cast<const ASTLiteral &>(*ast_with_name).value.get<const String &>();
}
command->type = ASTAlterCommand::FREEZE_ALL;
}
}

View File

@ -15,7 +15,7 @@ namespace DB
* [MODIFY PRIMARY KEY (a, b, c...)]
* [DROP|DETACH|ATTACH PARTITION|PART partition, ...]
* [FETCH PARTITION partition FROM ...]
* [FREEZE [PARTITION]]
* [FREEZE [PARTITION] [WITH NAME name]]
* [DELETE WHERE ...]
* [UPDATE col_name = expr, ... WHERE ...]
*/