mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
apply comments
This commit is contained in:
parent
f76bd8ed77
commit
192ada5ed9
@ -103,7 +103,6 @@ void DatabaseAtomic::attachTable(ContextPtr /* context_ */, const String & name,
|
|||||||
auto table_id = table->getStorageID();
|
auto table_id = table->getStorageID();
|
||||||
assertDetachedTableNotInUse(table_id.uuid);
|
assertDetachedTableNotInUse(table_id.uuid);
|
||||||
DatabaseOrdinary::attachTableUnlocked(name, table);
|
DatabaseOrdinary::attachTableUnlocked(name, table);
|
||||||
detached_tables.erase(table_id.uuid);
|
|
||||||
|
|
||||||
table_name_to_path.emplace(std::make_pair(name, relative_table_path));
|
table_name_to_path.emplace(std::make_pair(name, relative_table_path));
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,12 @@ class DetachedTablesBlockSource : public ISource
|
|||||||
public:
|
public:
|
||||||
DetachedTablesBlockSource(
|
DetachedTablesBlockSource(
|
||||||
std::vector<UInt8> columns_mask_,
|
std::vector<UInt8> columns_mask_,
|
||||||
Block header,
|
Block header_,
|
||||||
UInt64 max_block_size_,
|
UInt64 max_block_size_,
|
||||||
ColumnPtr databases_,
|
ColumnPtr databases_,
|
||||||
ColumnPtr detached_tables_,
|
ColumnPtr detached_tables_,
|
||||||
ContextPtr context_)
|
ContextPtr context_)
|
||||||
: ISource(std::move(header))
|
: ISource(std::move(header_))
|
||||||
, columns_mask(std::move(columns_mask_))
|
, columns_mask(std::move(columns_mask_))
|
||||||
, max_block_size(max_block_size_)
|
, max_block_size(max_block_size_)
|
||||||
, databases(std::move(databases_))
|
, databases(std::move(databases_))
|
||||||
@ -63,7 +63,9 @@ protected:
|
|||||||
const auto access = context->getAccess();
|
const auto access = context->getAccess();
|
||||||
const bool need_to_check_access_for_databases = !access->isGranted(AccessType::SHOW_TABLES);
|
const bool need_to_check_access_for_databases = !access->isGranted(AccessType::SHOW_TABLES);
|
||||||
|
|
||||||
for (size_t database_idx = 0, rows_count = 0; database_idx < databases->size() && rows_count < max_block_size; ++database_idx)
|
size_t database_idx = 0;
|
||||||
|
size_t rows_count = 0;
|
||||||
|
for (; database_idx < databases->size() && rows_count < max_block_size; ++database_idx)
|
||||||
{
|
{
|
||||||
database_name = databases->getDataAt(database_idx).toString();
|
database_name = databases->getDataAt(database_idx).toString();
|
||||||
database = DatabaseCatalog::instance().tryGetDatabase(database_name);
|
database = DatabaseCatalog::instance().tryGetDatabase(database_name);
|
||||||
@ -92,8 +94,11 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (databases->size() == database_idx && max_block_size != rows_count)
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
const UInt64 num_rows = result_columns.at(0)->size();
|
const UInt64 num_rows = result_columns.at(0)->size();
|
||||||
done = true;
|
|
||||||
return Chunk(std::move(result_columns), num_rows);
|
return Chunk(std::move(result_columns), num_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,6 @@ test03172_system_detached_tables test_table_perm 1
|
|||||||
test03172_system_detached_tables test_table 0
|
test03172_system_detached_tables test_table 0
|
||||||
-----------------------
|
-----------------------
|
||||||
database lazy tests
|
database lazy tests
|
||||||
test03172_system_detached_tables_lazy test_table 0
|
before attach test03172_system_detached_tables_lazy test_table 0
|
||||||
test03172_system_detached_tables_lazy test_table_perm 1
|
before attach test03172_system_detached_tables_lazy test_table_perm 1
|
||||||
DROP TABLE
|
DROP TABLE
|
||||||
|
@ -39,12 +39,12 @@ CREATE TABLE test03172_system_detached_tables_lazy.test_table_perm (number UInt6
|
|||||||
INSERT INTO test03172_system_detached_tables_lazy.test_table_perm SELECT * FROM numbers(100);
|
INSERT INTO test03172_system_detached_tables_lazy.test_table_perm SELECT * FROM numbers(100);
|
||||||
DETACH table test03172_system_detached_tables_lazy.test_table_perm PERMANENTLY;
|
DETACH table test03172_system_detached_tables_lazy.test_table_perm PERMANENTLY;
|
||||||
|
|
||||||
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables_lazy';
|
SELECT 'before attach', database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables_lazy';
|
||||||
|
|
||||||
ATTACH TABLE test03172_system_detached_tables_lazy.test_table;
|
ATTACH TABLE test03172_system_detached_tables_lazy.test_table;
|
||||||
ATTACH TABLE test03172_system_detached_tables_lazy.test_table_perm;
|
ATTACH TABLE test03172_system_detached_tables_lazy.test_table_perm;
|
||||||
|
|
||||||
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables_lazy';
|
SELECT 'after attach', database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables_lazy';
|
||||||
|
|
||||||
SELECT 'DROP TABLE';
|
SELECT 'DROP TABLE';
|
||||||
DROP TABLE test03172_system_detached_tables_lazy.test_table SYNC;
|
DROP TABLE test03172_system_detached_tables_lazy.test_table SYNC;
|
||||||
|
Loading…
Reference in New Issue
Block a user