Update StorageMaterializedView.cpp

This commit is contained in:
tavplubix 2021-04-13 23:14:05 +03:00 committed by GitHub
parent 05e4c8d3ef
commit 39d55556b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,9 +76,10 @@ StorageMaterializedView::StorageMaterializedView(
storage_metadata.setSelectQuery(select);
setInMemoryMetadata(storage_metadata);
bool point_to_itself_by_uuid = has_inner_table && query.to_inner_uuid == table_id_.uuid;
bool point_to_itself_by_name = has_inner_table && query.to_table_id.database_name == table_id_.database_name
&& query.to_table_id.table_name == table_id_.table_name;
bool point_to_itself_by_uuid = has_inner_table && query.to_inner_uuid != UUIDHelpers::Nil
&& query.to_inner_uuid == table_id_.uuid;
bool point_to_itself_by_name = !has_inner_table && query.to_table_id.database_name == table_id_.database_name
&& query.to_table_id.table_name == table_id_.table_name;
if (point_to_itself_by_uuid || point_to_itself_by_name)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Materialized view {} cannot point to itself", table_id_.getFullTableName());