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

This commit is contained in:
Alexey Milovidov 2016-11-14 04:13:56 +03:00
parent 52390b0180
commit eb1ae65eda
2 changed files with 23 additions and 23 deletions

View File

@ -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:
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,25 +176,30 @@ public:
node->attributes |= attributes; node->attributes |= attributes;
} }
} }
else if ((join = typeid_cast<ASTTableJoin *>(node)) != nullptr) else if (ASTTablesInSelectQueryElement * join = typeid_cast<ASTTablesInSelectQueryElement *>(node))
{
if (join->table_join)
{ {
/// Найдена секция JOIN. /// Найдена секция JOIN.
node->enclosing_in_or_join = node; join->enclosing_in_or_join = join->table_join.get();
node->attributes |= IAST::IsJoin; join->table_join->attributes |= IAST::IsJoin;
if (join->locality == ASTTableJoin::Locality::Global) if (static_cast<const ASTTableJoin &>(*join->table_join).locality == ASTTableJoin::Locality::Global)
node->attributes |= IAST::IsGlobal; join->table_join->attributes |= IAST::IsGlobal;
} }
else if ((node != static_cast<IAST *>(select_query)) }
&& ((sub_select_query = typeid_cast<ASTSelectQuery *>(node)) != nullptr)) else if (node != static_cast<IAST *>(select_query))
{
if (ASTSelectQuery * sub_select_query = typeid_cast<ASTSelectQuery *>(node))
{ {
++node->select_query_depth; ++node->select_query_depth;
if (sub_select_query->enclosing_in_or_join != nullptr) if (sub_select_query->enclosing_in_or_join)
{ {
/// Найден подзапрос внутри секции IN или JOIN. /// Найден подзапрос внутри секции IN или JOIN.
preprocessSubquery(*sub_select_query); preprocessSubquery(*sub_select_query);
} }
} }
}
if (!(node->attributes & IAST::IsPreprocessedForInJoinSubqueries)) if (!(node->attributes & IAST::IsPreprocessedForInJoinSubqueries))
{ {

View File

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