mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 08:52:06 +00:00
Better checks
This commit is contained in:
parent
a431608dd4
commit
edd5a64890
@ -1316,6 +1316,23 @@ std::shared_ptr<const EnabledRolesInfo> Context::getRolesInfo() const
|
||||
return getAccess()->getRolesInfo();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
ALWAYS_INLINE inline void
|
||||
contextSanityCheckWithLock(const Context & context, const Settings & settings, const std::lock_guard<ContextSharedMutex> &)
|
||||
{
|
||||
const auto type = context.getApplicationType();
|
||||
if (type == Context::ApplicationType::LOCAL || type == Context::ApplicationType::SERVER)
|
||||
doSettingsSanityCheck(settings);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE inline void contextSanityCheck(const Context & context, const Settings & settings)
|
||||
{
|
||||
const auto type = context.getApplicationType();
|
||||
if (type == Context::ApplicationType::LOCAL || type == Context::ApplicationType::SERVER)
|
||||
doSettingsSanityCheck(settings);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void Context::checkAccessImpl(const Args &... args) const
|
||||
@ -1425,6 +1442,7 @@ void Context::setCurrentProfilesWithLock(const SettingsProfilesInfo & profiles_i
|
||||
checkSettingsConstraintsWithLock(profiles_info.settings, SettingSource::PROFILE);
|
||||
applySettingsChangesWithLock(profiles_info.settings, lock);
|
||||
settings_constraints_and_current_profiles = profiles_info.getConstraintsAndProfileIDs(settings_constraints_and_current_profiles);
|
||||
contextSanityCheckWithLock(*this, settings, lock);
|
||||
}
|
||||
|
||||
void Context::setCurrentProfile(const String & profile_name, bool check_constraints)
|
||||
@ -1993,6 +2011,7 @@ void Context::setSettings(const Settings & settings_)
|
||||
std::lock_guard lock(mutex);
|
||||
settings = settings_;
|
||||
need_recalculate_access = true;
|
||||
contextSanityCheck(*this, settings);
|
||||
}
|
||||
|
||||
void Context::setSettingWithLock(std::string_view name, const String & value, const std::lock_guard<ContextSharedMutex> & lock)
|
||||
@ -2005,6 +2024,7 @@ void Context::setSettingWithLock(std::string_view name, const String & value, co
|
||||
settings.set(name, value);
|
||||
if (ContextAccessParams::dependsOnSettingName(name))
|
||||
need_recalculate_access = true;
|
||||
contextSanityCheckWithLock(*this, settings, lock);
|
||||
}
|
||||
|
||||
void Context::setSettingWithLock(std::string_view name, const Field & value, const std::lock_guard<ContextSharedMutex> & lock)
|
||||
@ -2024,6 +2044,7 @@ void Context::applySettingChangeWithLock(const SettingChange & change, const std
|
||||
try
|
||||
{
|
||||
setSettingWithLock(change.name, change.value, lock);
|
||||
contextSanityCheckWithLock(*this, settings, lock);
|
||||
}
|
||||
catch (Exception & e)
|
||||
{
|
||||
@ -2039,7 +2060,6 @@ void Context::applySettingsChangesWithLock(const SettingsChanges & changes, cons
|
||||
for (const SettingChange & change : changes)
|
||||
applySettingChangeWithLock(change, lock);
|
||||
applySettingsQuirks(settings);
|
||||
doSettingsSanityCheck(settings);
|
||||
}
|
||||
|
||||
void Context::setSetting(std::string_view name, const String & value)
|
||||
@ -2052,6 +2072,7 @@ void Context::setSetting(std::string_view name, const Field & value)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
setSettingWithLock(name, value, lock);
|
||||
contextSanityCheckWithLock(*this, settings, lock);
|
||||
}
|
||||
|
||||
void Context::applySettingChange(const SettingChange & change)
|
||||
@ -2079,26 +2100,36 @@ void Context::applySettingsChanges(const SettingsChanges & changes)
|
||||
void Context::checkSettingsConstraintsWithLock(const SettingsProfileElements & profile_elements, SettingSource source) const
|
||||
{
|
||||
getSettingsConstraintsAndCurrentProfilesWithLock()->constraints.check(settings, profile_elements, source);
|
||||
if (getApplicationType() == ApplicationType::LOCAL || getApplicationType() == ApplicationType::SERVER)
|
||||
doSettingsSanityCheck(settings);
|
||||
}
|
||||
|
||||
void Context::checkSettingsConstraintsWithLock(const SettingChange & change, SettingSource source) const
|
||||
{
|
||||
getSettingsConstraintsAndCurrentProfilesWithLock()->constraints.check(settings, change, source);
|
||||
if (getApplicationType() == ApplicationType::LOCAL || getApplicationType() == ApplicationType::SERVER)
|
||||
doSettingsSanityCheck(settings);
|
||||
}
|
||||
|
||||
void Context::checkSettingsConstraintsWithLock(const SettingsChanges & changes, SettingSource source) const
|
||||
{
|
||||
getSettingsConstraintsAndCurrentProfilesWithLock()->constraints.check(settings, changes, source);
|
||||
if (getApplicationType() == ApplicationType::LOCAL || getApplicationType() == ApplicationType::SERVER)
|
||||
doSettingsSanityCheck(settings);
|
||||
}
|
||||
|
||||
void Context::checkSettingsConstraintsWithLock(SettingsChanges & changes, SettingSource source) const
|
||||
{
|
||||
getSettingsConstraintsAndCurrentProfilesWithLock()->constraints.check(settings, changes, source);
|
||||
if (getApplicationType() == ApplicationType::LOCAL || getApplicationType() == ApplicationType::SERVER)
|
||||
doSettingsSanityCheck(settings);
|
||||
}
|
||||
|
||||
void Context::clampToSettingsConstraintsWithLock(SettingsChanges & changes, SettingSource source) const
|
||||
{
|
||||
getSettingsConstraintsAndCurrentProfilesWithLock()->constraints.clamp(settings, changes, source);
|
||||
if (getApplicationType() == ApplicationType::LOCAL || getApplicationType() == ApplicationType::SERVER)
|
||||
doSettingsSanityCheck(settings);
|
||||
}
|
||||
|
||||
void Context::checkMergeTreeSettingsConstraintsWithLock(const MergeTreeSettings & merge_tree_settings, const SettingsChanges & changes) const
|
||||
@ -2122,6 +2153,7 @@ void Context::checkSettingsConstraints(const SettingsChanges & changes, SettingS
|
||||
{
|
||||
SharedLockGuard lock(mutex);
|
||||
getSettingsConstraintsAndCurrentProfilesWithLock()->constraints.check(settings, changes, source);
|
||||
doSettingsSanityCheck(settings);
|
||||
}
|
||||
|
||||
void Context::checkSettingsConstraints(SettingsChanges & changes, SettingSource source) const
|
||||
|
Loading…
Reference in New Issue
Block a user