StorageMaterializedView: update dependencies on DETACH TABLE

Previously the dependencies were updated only on DROP TABLE, so
detaching a materialized view and inserting to source table thrown an exception.
This commit is contained in:
Marek Vavruša 2017-12-15 19:41:06 -06:00 committed by alexey-milovidov
parent fb1aa84973
commit 6d4f106f11
2 changed files with 9 additions and 0 deletions

View File

@ -175,6 +175,14 @@ bool StorageMaterializedView::optimize(const ASTPtr & query, const ASTPtr & part
return getTargetTable()->optimize(query, partition, final, deduplicate, context);
}
void StorageMaterializedView::shutdown()
{
/// Make sure the dependency is removed after DETACH TABLE
global_context.removeDependency(
DatabaseAndTableName(select_database_name, select_table_name),
DatabaseAndTableName(database_name, table_name));
}
StoragePtr StorageMaterializedView::getTargetTable() const
{
return global_context.getTable(target_database_name, target_table_name);

View File

@ -33,6 +33,7 @@ public:
BlockOutputStreamPtr write(const ASTPtr & query, const Settings & settings) override;
void drop() override;
bool optimize(const ASTPtr & query, const ASTPtr & partition, bool final, bool deduplicate, const Context & context) override;
void shutdown() override;
BlockInputStreams read(
const Names & column_names,