SET PROFILE applies constraints too.

This commit is contained in:
Vitaly Baranov 2021-07-23 09:15:26 +03:00
parent 7afcc65060
commit 249ccd879e
2 changed files with 11 additions and 2 deletions

View File

@ -32,7 +32,13 @@ SettingsProfilesInfo::getConstraintsAndProfileIDs(const std::shared_ptr<const Se
auto res = std::make_shared<SettingsConstraintsAndProfileIDs>(manager);
res->current_profiles = profiles;
res->constraints = previous ? previous->constraints : constraints;
if (previous)
{
res->constraints = previous->constraints;
res->constraints.merge(constraints);
}
else
res->constraints = constraints;
if (previous)
{

View File

@ -214,12 +214,15 @@ def test_show_profiles():
def test_set_profile():
instance.query("CREATE SETTINGS PROFILE P1 SETTINGS max_memory_usage=10000000001")
instance.query("CREATE SETTINGS PROFILE P1 SETTINGS max_memory_usage=10000000001 MAX 20000000002")
session_id = new_session_id()
instance.http_query("SET profile='P1'", user='robin', params={'session_id':session_id})
assert instance.http_query("SELECT getSetting('max_memory_usage')", user='robin', params={'session_id':session_id}) == "10000000001\n"
expected_error = "max_memory_usage shouldn't be greater than 20000000002"
assert expected_error in instance.http_query_and_get_error("SET max_memory_usage=20000000003", user='robin', params={'session_id':session_id})
def test_changing_default_profiles_affects_new_sessions_only():
instance.query("CREATE SETTINGS PROFILE P1 SETTINGS max_memory_usage=10000000001")