Merge branch 'nikvas0/lazy_db' of https://github.com/nikvas0/ClickHouse into nikvas0/lazy_db

This commit is contained in:
Vasilyev Nikita 2019-10-08 11:15:12 +03:00
commit 21b2b20729
3 changed files with 10 additions and 4 deletions

View File

@ -18,7 +18,7 @@ namespace detail
ASTPtr getCreateQueryFromMetadata(const String & metadata_path, const String & database, bool throw_on_error);
}
/* Class to provide basic operations with tables stored on disk.
/* Class to provide basic operations with tables when metadata is stored on disk in .sql files.
*/
class DatabaseOnDisk
{

View File

@ -264,7 +264,11 @@ BlockInputStreams StorageSystemColumns::read(
MutableColumnPtr database_column_mut = ColumnString::create();
for (const auto & database : databases)
{
if (context.hasDatabaseAccessRights(database.first) && database.second->getEngineName() != "Lazy")
/// We are skipping "Lazy" database because we cannot afford initialization of all its tables.
/// This should be documented.
if (context.hasDatabaseAccessRights(database.first)
&& database.second->getEngineName() != "Lazy")
database_column_mut->insert(database.first);
}

View File

@ -61,13 +61,15 @@ static ColumnPtr getFilteredDatabases(const ASTPtr & query, const Context & cont
return block.getByPosition(0).column;
}
static bool needLockStructure(const DatabasePtr& database, const Block& header)
/// Avoid heavy operation on tables if we only queried columns that we can get without table object.
/// Otherwise it will require table initialization for Lazy database.
static bool needLockStructure(const DatabasePtr & database, const Block & header)
{
if (database->getEngineName() != "Lazy")
return true;
static const std::set<std::string> columns_without_lock = { "database", "name", "metadata_modification_time" };
for (const auto& column : header.getColumnsWithTypeAndName())
for (const auto & column : header.getColumnsWithTypeAndName())
{
if (columns_without_lock.find(column.name) == columns_without_lock.end())
return true;