mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
change parser
This commit is contained in:
parent
ec2446adfd
commit
dcaa80c90d
@ -121,10 +121,7 @@ private:
|
||||
{
|
||||
if (select.recursive_with)
|
||||
for (const auto & child : select.with()->children)
|
||||
{
|
||||
if (typeid_cast<ASTWithElement *>(child.get()))
|
||||
with_aliases.insert(child->as<ASTWithElement>()->name);
|
||||
}
|
||||
|
||||
if (select.tables())
|
||||
tryVisit<ASTTablesInSelectQuery>(select.refTables());
|
||||
|
@ -106,7 +106,7 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
select_query->recursive_with = s_recursive.ignore(pos, expected);
|
||||
|
||||
if (!ParserList(std::make_unique<ParserWithElement>(), std::make_unique<ParserToken>(TokenType::Comma))
|
||||
if (!ParserList(std::make_unique<ParserWithElement>(select_query->recursive_with), std::make_unique<ParserToken>(TokenType::Comma))
|
||||
.parse(pos, with_expression_list, expected))
|
||||
return false;
|
||||
if (with_expression_list->children.empty())
|
||||
|
@ -26,6 +26,10 @@ bool ParserWithElement::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
with_element->children.push_back(with_element->subquery);
|
||||
node = with_element;
|
||||
}
|
||||
else if (with_recursive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = old_pos;
|
||||
|
@ -10,9 +10,14 @@ namespace DB
|
||||
*/
|
||||
class ParserWithElement : public IParserBase
|
||||
{
|
||||
public:
|
||||
ParserWithElement(bool with_recursive_ = false) : with_recursive(with_recursive_) {}
|
||||
protected:
|
||||
const char * getName() const override { return "WITH element"; }
|
||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
||||
|
||||
/// for `WITH RECURSIVE` CTE, we don't allow expression with alias.
|
||||
bool with_recursive;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,2 @@
|
||||
drop table if exists t;
|
||||
create view t AS (WITH RECURSIVE 42 as ttt SELECT ttt);
|
||||
drop table t;
|
||||
create view t AS (WITH RECURSIVE 42 as ttt SELECT ttt) -- { clientError SYNTAX_ERROR };
|
||||
|
Loading…
Reference in New Issue
Block a user