diff --git a/dbms/src/Storages/System/StorageSystemPartsBase.cpp b/dbms/src/Storages/System/StorageSystemPartsBase.cpp index b185cca8be2..f1f99c312f4 100644 --- a/dbms/src/Storages/System/StorageSystemPartsBase.cpp +++ b/dbms/src/Storages/System/StorageSystemPartsBase.cpp @@ -113,12 +113,12 @@ public: } } + block_to_filter.insert(ColumnWithTypeAndName(std::move(table_column_mut), std::make_shared(), "table")); + block_to_filter.insert(ColumnWithTypeAndName(std::move(engine_column_mut), std::make_shared(), "engine")); + block_to_filter.insert(ColumnWithTypeAndName(std::move(active_column_mut), std::make_shared(), "active")); + if (rows) { - block_to_filter.insert(ColumnWithTypeAndName(std::move(table_column_mut), std::make_shared(), "table")); - block_to_filter.insert(ColumnWithTypeAndName(std::move(engine_column_mut), std::make_shared(), "engine")); - block_to_filter.insert(ColumnWithTypeAndName(std::move(active_column_mut), std::make_shared(), "active")); - /// Filter block_to_filter with columns 'database', 'table', 'engine', 'active'. VirtualColumnUtils::filterBlockWithQuery(query_info.query, block_to_filter, context); rows = block_to_filter.rows(); diff --git a/dbms/tests/queries/0_stateless/00603_system_parts_nonexistent_database.reference b/dbms/tests/queries/0_stateless/00603_system_parts_nonexistent_database.reference new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00603_system_parts_nonexistent_database.reference @@ -0,0 +1 @@ +0 diff --git a/dbms/tests/queries/0_stateless/00603_system_parts_nonexistent_database.sql b/dbms/tests/queries/0_stateless/00603_system_parts_nonexistent_database.sql new file mode 100644 index 00000000000..378d9dc80d3 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00603_system_parts_nonexistent_database.sql @@ -0,0 +1 @@ +SELECT count() FROM system.parts WHERE database = 'T5yajf3DLcMjJJvpCeX5ajUy1P0VTk51zMEp1kDKXZAGr5EpleuIKbuY8cKaThkaBqllUm2EFxDX';