mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
fix alter of settings in MergeTree
This commit is contained in:
parent
eca877ff39
commit
9071ecd428
@ -1818,11 +1818,10 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, Context
|
||||
if (MergeTreeSettings::isPartFormatSetting(setting_name) && !new_value)
|
||||
{
|
||||
/// Use default settings + new and check if doesn't affect part format settings
|
||||
MergeTreeSettings copy = *getSettings();
|
||||
copy.resetToDefault();
|
||||
copy.applyChanges(new_changes);
|
||||
auto copy = getDefaultSettings();
|
||||
copy->applyChanges(new_changes);
|
||||
String reason;
|
||||
if (!canUsePolymorphicParts(copy, &reason) && !reason.empty())
|
||||
if (!canUsePolymorphicParts(*copy, &reason) && !reason.empty())
|
||||
throw Exception("Can't change settings. Reason: " + reason, ErrorCodes::NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@ -1984,14 +1983,12 @@ void MergeTreeData::changeSettings(
|
||||
}
|
||||
}
|
||||
|
||||
MergeTreeSettings copy = *getSettings();
|
||||
/// reset to default settings before applying existing
|
||||
copy.resetToDefault();
|
||||
copy.applyChanges(new_changes);
|
||||
/// Reset to default settings before applying existing.
|
||||
auto copy = getDefaultSettings();
|
||||
copy->applyChanges(new_changes);
|
||||
copy->sanityCheck(getContext()->getSettingsRef());
|
||||
|
||||
copy.sanityCheck(getContext()->getSettingsRef());
|
||||
|
||||
storage_settings.set(std::make_unique<const MergeTreeSettings>(copy));
|
||||
storage_settings.set(std::move(copy));
|
||||
StorageInMemoryMetadata new_metadata = getInMemoryMetadata();
|
||||
new_metadata.setSettingsChanges(new_settings);
|
||||
setInMemoryMetadata(new_metadata);
|
||||
|
@ -1087,6 +1087,9 @@ private:
|
||||
|
||||
// Get partition matcher for FREEZE / UNFREEZE queries.
|
||||
MatcherFn getPartitionMatcher(const ASTPtr & partition, ContextPtr context) const;
|
||||
|
||||
/// Returns default settings for storage with possible changes from global config.
|
||||
virtual std::unique_ptr<MergeTreeSettings> getDefaultSettings() const = 0;
|
||||
};
|
||||
|
||||
/// RAII struct to record big parts that are submerging or emerging.
|
||||
|
@ -1577,4 +1577,9 @@ void StorageMergeTree::startBackgroundMovesIfNeeded()
|
||||
background_moves_executor.start();
|
||||
}
|
||||
|
||||
std::unique_ptr<MergeTreeSettings> StorageMergeTree::getDefaultSettings() const
|
||||
{
|
||||
return std::make_unique<MergeTreeSettings>(getContext()->getMergeTreeSettings());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -235,6 +235,8 @@ private:
|
||||
|
||||
void startBackgroundMovesIfNeeded() override;
|
||||
|
||||
std::unique_ptr<MergeTreeSettings> getDefaultSettings() const override;
|
||||
|
||||
friend class MergeTreeProjectionBlockOutputStream;
|
||||
friend class MergeTreeBlockOutputStream;
|
||||
friend class MergeTreeData;
|
||||
|
@ -7174,6 +7174,11 @@ void StorageReplicatedMergeTree::startBackgroundMovesIfNeeded()
|
||||
background_moves_executor.start();
|
||||
}
|
||||
|
||||
std::unique_ptr<MergeTreeSettings> StorageReplicatedMergeTree::getDefaultSettings() const
|
||||
{
|
||||
return std::make_unique<MergeTreeSettings>(getContext()->getReplicatedMergeTreeSettings());
|
||||
}
|
||||
|
||||
|
||||
void StorageReplicatedMergeTree::lockSharedData(const IMergeTreeDataPart & part) const
|
||||
{
|
||||
|
@ -702,6 +702,8 @@ private:
|
||||
|
||||
void startBackgroundMovesIfNeeded() override;
|
||||
|
||||
std::unique_ptr<MergeTreeSettings> getDefaultSettings() const override;
|
||||
|
||||
std::set<String> getPartitionIdsAffectedByCommands(const MutationCommands & commands, ContextPtr query_context) const;
|
||||
PartitionBlockNumbersHolder allocateBlockNumbersInAffectedPartitions(
|
||||
const MutationCommands & commands, ContextPtr query_context, const zkutil::ZooKeeperPtr & zookeeper) const;
|
||||
|
Loading…
Reference in New Issue
Block a user