From a940a2568454d005d6379c5a8e35947f0f22875b Mon Sep 17 00:00:00 2001 From: "Mikhail f. Shiryaev" Date: Sun, 22 Dec 2019 15:35:38 +0100 Subject: [PATCH] Add a way to set multiple parent profiles --- dbms/src/Access/SettingsConstraints.cpp | 14 +++++++++++--- dbms/src/Core/Settings.cpp | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dbms/src/Access/SettingsConstraints.cpp b/dbms/src/Access/SettingsConstraints.cpp index a044b7a0dc1..a4276a03257 100644 --- a/dbms/src/Access/SettingsConstraints.cpp +++ b/dbms/src/Access/SettingsConstraints.cpp @@ -217,9 +217,17 @@ const SettingsConstraints::Constraint * SettingsConstraints::tryGetConstraint(si void SettingsConstraints::setProfile(const String & profile_name, const Poco::Util::AbstractConfiguration & config) { - String parent_profile = "profiles." + profile_name + ".profile"; - if (config.has(parent_profile)) - setProfile(parent_profile, config); // Inheritance of one profile from another. + String elem = "profiles." + profile_name; + + Poco::Util::AbstractConfiguration::Keys config_keys; + config.keys(elem, config_keys); + + for (const std::string & key : config_keys) + { + if (key == "profile" || key.find("profile[") == 0) /// Inheritance of profiles from the current one. + setProfile(config.getString(elem + "." + key), config); + else continue; + } String path_to_constraints = "profiles." + profile_name + ".constraints"; if (config.has(path_to_constraints)) diff --git a/dbms/src/Core/Settings.cpp b/dbms/src/Core/Settings.cpp index 717261e298d..ede3a660cb3 100644 --- a/dbms/src/Core/Settings.cpp +++ b/dbms/src/Core/Settings.cpp @@ -37,7 +37,7 @@ void Settings::setProfile(const String & profile_name, const Poco::Util::Abstrac { if (key == "constraints") continue; - if (key == "profile") /// Inheritance of one profile from another. + if (key == "profile" || key.find("profile[") == 0) /// Inheritance of profiles from the current one. setProfile(config.getString(elem + "." + key), config); else set(key, config.getString(elem + "." + key));