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

Fixed test [#CLICKHOUSE-2]

上级 91266924
......@@ -323,6 +323,20 @@ BlockOutputStreamPtr StorageBuffer::write(const ASTPtr & /*query*/, const Settin
}
bool StorageBuffer::mayBenefitFromIndexForIn(const ASTPtr & left_in_operand) const
{
if (no_destination)
return false;
auto destination = context.getTable(destination_database, destination_table);
if (destination.get() == this)
throw Exception("Destination table is myself. Read will cause infinite loop.", ErrorCodes::INFINITE_LOOP);
return destination->mayBenefitFromIndexForIn(left_in_operand);
}
void StorageBuffer::startup()
{
if (context.getSettingsRef().readonly)
......
......@@ -75,6 +75,8 @@ public:
bool supportsFinal() const override { return true; }
bool supportsIndexForIn() const override { return true; }
bool mayBenefitFromIndexForIn(const ASTPtr & left_in_operand) const override;
/// The structure of the subordinate table is not checked and does not change.
void alter(const AlterCommands & params, const String & database_name, const String & table_name, const Context & context) override;
......
......@@ -111,6 +111,27 @@ namespace
}
bool StorageMerge::mayBenefitFromIndexForIn(const ASTPtr & left_in_operand) const
{
/// It's beneficial if it is true for at least one table.
StorageListWithLocks selected_tables = getSelectedTables();
size_t i = 0;
for (const auto & table : selected_tables)
{
if (table.first->mayBenefitFromIndexForIn(left_in_operand))
return true;
++i;
/// For simplicity reasons, check only first ten tables.
if (i > 10)
break;
}
return false;
}
BlockInputStreams StorageMerge::read(
const Names & column_names,
const SelectQueryInfo & query_info,
......
......@@ -44,6 +44,8 @@ public:
/// the structure of sub-tables is not checked
void alter(const AlterCommands & params, const String & database_name, const String & table_name, const Context & context) override;
bool mayBenefitFromIndexForIn(const ASTPtr & left_in_operand) const override;
private:
String name;
String source_database;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册