mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
All set methods in metadata
This commit is contained in:
parent
33a74a3ea0
commit
b47a7327fd
@ -616,24 +616,11 @@ ASTPtr IStorage::getSettingsChanges() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void IStorage::setSettingsChanges(const ASTPtr & settings_changes_)
|
||||
{
|
||||
if (settings_changes_)
|
||||
metadata->settings_changes = settings_changes_->clone();
|
||||
else
|
||||
metadata->settings_changes = nullptr;
|
||||
}
|
||||
|
||||
const SelectQueryDescription & IStorage::getSelectQuery() const
|
||||
{
|
||||
return metadata->select;
|
||||
}
|
||||
|
||||
void IStorage::setSelectQuery(const SelectQueryDescription & select_)
|
||||
{
|
||||
metadata->select = select_;
|
||||
}
|
||||
|
||||
bool IStorage::hasSelectQuery() const
|
||||
{
|
||||
return metadata->select.select_query != nullptr;
|
||||
|
@ -148,12 +148,10 @@ public: /// thread-unsafe part. lockStructure must be acquired
|
||||
|
||||
/// Storage settings
|
||||
ASTPtr getSettingsChanges() const;
|
||||
void setSettingsChanges(const ASTPtr & settings_changes_);
|
||||
bool hasSettingsChanges() const { return metadata->settings_changes != nullptr; }
|
||||
|
||||
/// Select query for *View storages.
|
||||
const SelectQueryDescription & getSelectQuery() const;
|
||||
void setSelectQuery(const SelectQueryDescription & select_);
|
||||
bool hasSelectQuery() const;
|
||||
|
||||
StorageInMemoryMetadata getInMemoryMetadata() const { return *metadata; }
|
||||
|
@ -1474,7 +1474,9 @@ void MergeTreeData::changeSettings(
|
||||
MergeTreeSettings copy = *getSettings();
|
||||
copy.applyChanges(new_changes);
|
||||
storage_settings.set(std::make_unique<const MergeTreeSettings>(copy));
|
||||
setSettingsChanges(new_settings);
|
||||
StorageInMemoryMetadata new_metadata = getInMemoryMetadata();
|
||||
new_metadata.setSettingsChanges(new_settings);
|
||||
setInMemoryMetadata(new_metadata);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,4 +76,17 @@ void StorageInMemoryMetadata::setColumnTTLs(const TTLColumnsDescription & column
|
||||
column_ttls_by_name = column_ttls_by_name_;
|
||||
}
|
||||
|
||||
void StorageInMemoryMetadata::setSettingsChanges(const ASTPtr & settings_changes_)
|
||||
{
|
||||
if (settings_changes_)
|
||||
settings_changes = settings_changes_;
|
||||
else
|
||||
settings_changes = nullptr;
|
||||
}
|
||||
|
||||
void StorageInMemoryMetadata::setSelectQuery(const SelectQueryDescription & select_)
|
||||
{
|
||||
select = select_;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ struct StorageInMemoryMetadata
|
||||
void setTableTTLs(const TTLTableDescription & table_ttl_);
|
||||
|
||||
void setColumnTTLs(const TTLColumnsDescription & column_ttls_by_name_);
|
||||
|
||||
void setSettingsChanges(const ASTPtr & settings_changes_);
|
||||
|
||||
void setSelectQuery(const SelectQueryDescription & select_);
|
||||
};
|
||||
|
||||
using StorageMetadataPtr = std::shared_ptr<StorageInMemoryMetadata>;
|
||||
|
@ -52,7 +52,6 @@ StorageMaterializedView::StorageMaterializedView(
|
||||
{
|
||||
StorageInMemoryMetadata metadata_;
|
||||
metadata_.setColumns(columns_);
|
||||
setInMemoryMetadata(metadata_);
|
||||
|
||||
if (!query.select)
|
||||
throw Exception("SELECT query is not specified for " + getName(), ErrorCodes::INCORRECT_QUERY);
|
||||
@ -68,7 +67,8 @@ StorageMaterializedView::StorageMaterializedView(
|
||||
throw Exception("UNION is not supported for MATERIALIZED VIEW", ErrorCodes::QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW);
|
||||
|
||||
auto select = SelectQueryDescription::getSelectQueryFromASTForMatView(query.select->clone(), local_context);
|
||||
setSelectQuery(select);
|
||||
metadata_.setSelectQuery(select);
|
||||
setInMemoryMetadata(metadata_);
|
||||
|
||||
if (!has_inner_table)
|
||||
target_table_id = query.to_table_id;
|
||||
@ -206,7 +206,7 @@ void StorageMaterializedView::alter(
|
||||
|
||||
DatabaseCatalog::instance().updateDependency(old_select.select_table_id, table_id, new_select.select_table_id, table_id);
|
||||
|
||||
setSelectQuery(new_select);
|
||||
new_metadata.setSelectQuery(new_select);
|
||||
}
|
||||
/// end modify query
|
||||
|
||||
|
@ -3648,7 +3648,6 @@ void StorageReplicatedMergeTree::alter(
|
||||
StorageInMemoryMetadata future_metadata = getInMemoryMetadata();
|
||||
params.apply(future_metadata, query_context);
|
||||
|
||||
|
||||
changeSettings(future_metadata.settings_changes, table_lock_holder);
|
||||
|
||||
DatabaseCatalog::instance().getDatabase(table_id.database_name)->alterTable(query_context, table_id, future_metadata);
|
||||
|
@ -40,7 +40,6 @@ StorageView::StorageView(
|
||||
{
|
||||
StorageInMemoryMetadata metadata_;
|
||||
metadata_.setColumns(columns_);
|
||||
setInMemoryMetadata(metadata_);
|
||||
|
||||
if (!query.select)
|
||||
throw Exception("SELECT query is not specified for " + getName(), ErrorCodes::INCORRECT_QUERY);
|
||||
@ -48,7 +47,8 @@ StorageView::StorageView(
|
||||
SelectQueryDescription description;
|
||||
|
||||
description.inner_query = query.select->ptr();
|
||||
setSelectQuery(description);
|
||||
metadata_.setSelectQuery(description);
|
||||
setInMemoryMetadata(metadata_);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user