提交 eb1ae65e 编写于 作者: A Alexey Milovidov

Fixed error with analyzing double-distributed subqueries [#METR-23472].

上级 52390b01
...@@ -73,9 +73,9 @@ bool isQueryFromTable(const ASTSelectQuery & query) ...@@ -73,9 +73,9 @@ bool isQueryFromTable(const ASTSelectQuery & query)
if (query_table) if (query_table)
{ {
if (typeid_cast<const ASTSelectQuery *>(query_table.get()) != nullptr) if (typeid_cast<const ASTSelectQuery *>(query_table.get()))
return false; return false;
else if (typeid_cast<const ASTFunction *>(query_table.get()) != nullptr) else if (typeid_cast<const ASTFunction *>(query_table.get()))
return false; return false;
else else
return true; return true;
...@@ -166,11 +166,7 @@ public: ...@@ -166,11 +166,7 @@ public:
auto node = to_preprocess.back(); auto node = to_preprocess.back();
to_preprocess.pop_back(); to_preprocess.pop_back();
ASTFunction * function; if (ASTFunction * function = typeid_cast<ASTFunction *>(node))
ASTTableJoin * join;
ASTSelectQuery * sub_select_query;
if ((function = typeid_cast<ASTFunction *>(node)) != nullptr)
{ {
auto attributes = getAttributesFromInSubqueryName(function->name); auto attributes = getAttributesFromInSubqueryName(function->name);
if (attributes != 0) if (attributes != 0)
...@@ -180,23 +176,28 @@ public: ...@@ -180,23 +176,28 @@ public:
node->attributes |= attributes; node->attributes |= attributes;
} }
} }
else if ((join = typeid_cast<ASTTableJoin *>(node)) != nullptr) else if (ASTTablesInSelectQueryElement * join = typeid_cast<ASTTablesInSelectQueryElement *>(node))
{ {
/// Найдена секция JOIN. if (join->table_join)
node->enclosing_in_or_join = node; {
node->attributes |= IAST::IsJoin; /// Найдена секция JOIN.
if (join->locality == ASTTableJoin::Locality::Global) join->enclosing_in_or_join = join->table_join.get();
node->attributes |= IAST::IsGlobal; join->table_join->attributes |= IAST::IsJoin;
if (static_cast<const ASTTableJoin &>(*join->table_join).locality == ASTTableJoin::Locality::Global)
join->table_join->attributes |= IAST::IsGlobal;
}
} }
else if ((node != static_cast<IAST *>(select_query)) else if (node != static_cast<IAST *>(select_query))
&& ((sub_select_query = typeid_cast<ASTSelectQuery *>(node)) != nullptr))
{ {
++node->select_query_depth; if (ASTSelectQuery * sub_select_query = typeid_cast<ASTSelectQuery *>(node))
if (sub_select_query->enclosing_in_or_join != nullptr)
{ {
/// Найден подзапрос внутри секции IN или JOIN. ++node->select_query_depth;
preprocessSubquery(*sub_select_query);
if (sub_select_query->enclosing_in_or_join)
{
/// Найден подзапрос внутри секции IN или JOIN.
preprocessSubquery(*sub_select_query);
}
} }
} }
......
...@@ -1148,7 +1148,6 @@ bool performTests(const TestEntries & entries) ...@@ -1148,7 +1148,6 @@ bool performTests(const TestEntries & entries)
if (res.first) if (res.first)
{ {
++count; ++count;
std::cout << "Test " << i << " passed.\n";
} }
else else
std::cout << "Test " << i << " at line " << entry.line_num << " failed.\n" std::cout << "Test " << i << " at line " << entry.line_num << " failed.\n"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册