//===----------------------------------------------------------------------===//
//                         DuckDB
// This code is autogenerated from 'scripts/settings_scripts/update_settings_src_code.py'.
// Please do not make any changes directly here, as they will be overwritten.
// If you need to implement a custom function for a new setting, enable the
// 'custom_implementation' in 'src/common/settings.json' for this setting.
//
//===----------------------------------------------------------------------===//

#include "duckdb/main/settings.hpp"
#include "duckdb/common/enum_util.hpp"
#include "duckdb/main/client_context.hpp"
#include "duckdb/main/config.hpp"

namespace duckdb {

//===----------------------------------------------------------------------===//
// Access Mode
//===----------------------------------------------------------------------===//
void AccessModeSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &input) {
	if (!OnGlobalSet(db, config, input)) {
		return;
	}
	auto str_input = StringUtil::Upper(input.GetValue<string>());
	config.options.access_mode = EnumUtil::FromString<AccessMode>(str_input);
}

void AccessModeSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
	config.options.access_mode = DBConfigOptions().access_mode;
}

Value AccessModeSetting::GetSetting(const ClientContext &context) {
	auto &config = DBConfig::GetConfig(context);
	return Value(StringUtil::Lower(EnumUtil::ToString(config.options.access_mode)));
}

//===----------------------------------------------------------------------===//
// Allow Parser Override Extension
//===----------------------------------------------------------------------===//
void AllowParserOverrideExtensionSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<AllowParserOverride>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Arrow Output Version
//===----------------------------------------------------------------------===//
void ArrowOutputVersionSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<ArrowFormatVersion>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Checkpoint Threshold
//===----------------------------------------------------------------------===//
void CheckpointThresholdSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
	config.options.checkpoint_wal_size = DBConfigOptions().checkpoint_wal_size;
}

//===----------------------------------------------------------------------===//
// Custom User Agent
//===----------------------------------------------------------------------===//
Value CustomUserAgentSetting::GetSetting(const ClientContext &context) {
	auto &config = DBConfig::GetConfig(context);
	return Value(config.options.custom_user_agent);
}

//===----------------------------------------------------------------------===//
// Debug Checkpoint Abort
//===----------------------------------------------------------------------===//
void DebugCheckpointAbortSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<CheckpointAbort>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Debug Force External
//===----------------------------------------------------------------------===//
void DebugForceExternalSetting::SetLocal(ClientContext &context, const Value &input) {
	auto &config = ClientConfig::GetConfig(context);
	config.force_external = input.GetValue<bool>();
}

void DebugForceExternalSetting::ResetLocal(ClientContext &context) {
	ClientConfig::GetConfig(context).force_external = ClientConfig().force_external;
}

Value DebugForceExternalSetting::GetSetting(const ClientContext &context) {
	auto &config = ClientConfig::GetConfig(context);
	return Value::BOOLEAN(config.force_external);
}

//===----------------------------------------------------------------------===//
// Debug Physical Table Scan Execution Strategy
//===----------------------------------------------------------------------===//
void DebugPhysicalTableScanExecutionStrategySetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<PhysicalTableScanExecutionStrategy>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Debug Verify Vector
//===----------------------------------------------------------------------===//
void DebugVerifyVectorSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<DebugVectorVerification>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Debug Window Mode
//===----------------------------------------------------------------------===//
void DebugWindowModeSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<WindowAggregationMode>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Deprecated Using Key Syntax
//===----------------------------------------------------------------------===//
void DeprecatedUsingKeySyntaxSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<DeprecatedUsingKeySyntax>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Enable Caching Operators
//===----------------------------------------------------------------------===//
void EnableCachingOperatorsSetting::SetLocal(ClientContext &context, const Value &input) {
	auto &config = ClientConfig::GetConfig(context);
	config.enable_caching_operators = input.GetValue<bool>();
}

void EnableCachingOperatorsSetting::ResetLocal(ClientContext &context) {
	ClientConfig::GetConfig(context).enable_caching_operators = ClientConfig().enable_caching_operators;
}

Value EnableCachingOperatorsSetting::GetSetting(const ClientContext &context) {
	auto &config = ClientConfig::GetConfig(context);
	return Value::BOOLEAN(config.enable_caching_operators);
}

//===----------------------------------------------------------------------===//
// Enable Progress Bar
//===----------------------------------------------------------------------===//
void EnableProgressBarSetting::SetLocal(ClientContext &context, const Value &input) {
	if (!OnLocalSet(context, input)) {
		return;
	}
	auto &config = ClientConfig::GetConfig(context);
	config.enable_progress_bar = input.GetValue<bool>();
}

void EnableProgressBarSetting::ResetLocal(ClientContext &context) {
	if (!OnLocalReset(context)) {
		return;
	}
	ClientConfig::GetConfig(context).enable_progress_bar = ClientConfig().enable_progress_bar;
}

Value EnableProgressBarSetting::GetSetting(const ClientContext &context) {
	auto &config = ClientConfig::GetConfig(context);
	return Value::BOOLEAN(config.enable_progress_bar);
}

//===----------------------------------------------------------------------===//
// Explain Output
//===----------------------------------------------------------------------===//
void ExplainOutputSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<ExplainOutputType>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Force Bitpacking Mode
//===----------------------------------------------------------------------===//
void ForceBitpackingModeSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<BitpackingMode>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// H T T P Proxy
//===----------------------------------------------------------------------===//
Value HTTPProxySetting::GetSetting(const ClientContext &context) {
	auto &config = DBConfig::GetConfig(context);
	return Value(config.options.http_proxy);
}

//===----------------------------------------------------------------------===//
// Lambda Syntax
//===----------------------------------------------------------------------===//
void LambdaSyntaxSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<LambdaSyntax>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Pin Threads
//===----------------------------------------------------------------------===//
void PinThreadsSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<ThreadPinMode>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Storage Block Prefetch
//===----------------------------------------------------------------------===//
void StorageBlockPrefetchSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<StorageBlockPrefetch>(StringValue::Get(parameter));
}

//===----------------------------------------------------------------------===//
// Validate External File Cache
//===----------------------------------------------------------------------===//
void ValidateExternalFileCacheSetting::OnSet(SettingCallbackInfo &info, Value &parameter) {
	EnumUtil::FromString<CacheValidationMode>(StringValue::Get(parameter));
}

} // namespace duckdb
