/src/duckdb/src/main/settings/settings.cpp
Line | Count | Source |
1 | | #include "duckdb/main/settings.hpp" |
2 | | #include "duckdb/main/client_context.hpp" |
3 | | #include "duckdb/main/config.hpp" |
4 | | |
5 | | namespace duckdb { |
6 | | |
7 | 5.12M | bool Settings::TryGetSettingInternal(const ClientContext &context, idx_t setting_index, Value &result) { |
8 | 5.12M | return context.TryGetCurrentUserSetting(setting_index, result); |
9 | 5.12M | } |
10 | | |
11 | 1.22M | bool Settings::TryGetSettingInternal(const DBConfig &config, idx_t setting_index, Value &result) { |
12 | 1.22M | auto lookup_result = config.TryGetCurrentUserSetting(setting_index, result); |
13 | 1.22M | return lookup_result; |
14 | 1.22M | } |
15 | | |
16 | 823k | bool Settings::TryGetSettingInternal(const DatabaseInstance &db, idx_t setting_index, Value &result) { |
17 | 823k | return TryGetSettingInternal(DBConfig::GetConfig(db), setting_index, result); |
18 | 823k | } |
19 | | |
20 | 0 | void Settings::SetSettingInternal(DatabaseInstance &db, idx_t setting_index, SetScope scope, Value target_value) { |
21 | 0 | SetSettingInternal(DBConfig::GetConfig(db), setting_index, scope, std::move(target_value)); |
22 | 0 | } |
23 | | |
24 | 0 | void Settings::SetSettingInternal(DBConfig &config, idx_t setting_index, SetScope scope, Value target_value) { |
25 | 0 | if (scope != SetScope::GLOBAL) { |
26 | 0 | throw InternalException( |
27 | 0 | "Attempting to set setting with index %d with non-global scope, but no ClientContext was provided", |
28 | 0 | setting_index); |
29 | 0 | } |
30 | 0 | config.SetOption(setting_index, std::move(target_value)); |
31 | 0 | } |
32 | | |
33 | 6.59k | void Settings::SetSettingInternal(ClientContext &context, idx_t setting_index, SetScope scope, Value target_value) { |
34 | 6.59k | if (scope == SetScope::GLOBAL) { |
35 | 0 | SetSettingInternal(DBConfig::GetConfig(context), setting_index, scope, std::move(target_value)); |
36 | 0 | return; |
37 | 0 | } |
38 | 6.59k | auto &client_config = ClientConfig::GetConfig(context); |
39 | 6.59k | client_config.user_settings.SetUserSetting(setting_index, std::move(target_value)); |
40 | 6.59k | } |
41 | | |
42 | | } // namespace duckdb |