Skip to content

Commit 7082d16

Browse files
Resolve setting-name aliases in tryGetLiveValueAsString
The changeable-settings map is keyed by canonical names, but `getServerSetting` accepts path-style aliases such as `query_cache.max_size_in_bytes` (alias for `query_cache_max_size_in_bytes`). Without resolving the alias first, the lookup missed the live value and the function silently fell back to the stale config value. Run `name` through `ServerSettingsTraits::resolveName` before consulting the map, and add a test that exercises a path alias.
1 parent a15d12f commit 7082d16

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎src/Core/ServerSettings.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,8 +1925,12 @@ void ServerSettings::dumpToSystemServerSettingsColumns(ServerSettingColumnsParam
19251925

19261926
std::optional<String> ServerSettings::tryGetLiveValueAsString(ContextPtr context, std::string_view name) const
19271927
{
1928+
/// Resolve `name` so that path-style aliases (e.g. `query_cache.max_size_in_bytes`) and any
1929+
/// other aliases are looked up against the canonical setting names used as keys in the map.
1930+
const std::string_view resolved_name = ServerSettingsTraits::resolveName(name);
1931+
19281932
const auto changeable_settings = collectChangeableServerSettings(context);
1929-
auto it = changeable_settings.find(String{name});
1933+
auto it = changeable_settings.find(String{resolved_name});
19301934
if (it == changeable_settings.end())
19311935
return std::nullopt;
19321936
return it->second.first;

‎tests/queries/0_stateless/04241_get_server_setting_live_values.reference‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
1
33
1
44
1
5+
1

‎tests/queries/0_stateless/04241_get_server_setting_live_values.sql‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ SELECT toUInt64(getServerSetting('mark_cache_size'))
2020
SELECT toString(getServerSetting('mark_cache_policy'))
2121
= (SELECT value FROM system.server_settings WHERE name = 'mark_cache_policy')
2222
AS mark_cache_policy_matches;
23+
24+
-- Path-style aliases for runtime-changeable settings should also resolve to the live value.
25+
-- `query_cache.max_size_in_bytes` is an alias for `query_cache_max_size_in_bytes`.
26+
SELECT toUInt64(getServerSetting('query_cache.max_size_in_bytes'))
27+
= toUInt64((SELECT value FROM system.server_settings WHERE name = 'query_cache_max_size_in_bytes'))
28+
AS query_cache_max_size_in_bytes_alias_matches;

0 commit comments

Comments
 (0)