Skip to content

Commit

Permalink
Add s3_url_compatibility_mode to create_secret_functions
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopi committed Oct 17, 2024
1 parent f680b7d commit 6a90eb4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions extension/httpfs/create_secret_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ unique_ptr<BaseSecret> CreateS3SecretFunctions::CreateSecretFunctionInternal(Cli
secret->secret_map["url_style"] = "path";
}

idx_t url_compatibility = -1;
// apply any overridden settings
for (const auto &named_param : input.options) {
auto lower_name = StringUtil::Lower(named_param.first);
Expand Down Expand Up @@ -66,14 +67,31 @@ unique_ptr<BaseSecret> CreateS3SecretFunctions::CreateSecretFunctionInternal(Cli
throw InvalidInputException("Invalid type past to secret option: '%s', found '%s', expected: 'BOOLEAN'",
lower_name, named_param.second.type().ToString());
}
secret->secret_map["url_compatibility_mode"] = Value::BOOLEAN(named_param.second.GetValue<bool>());
const bool v = named_param.second.GetValue<bool>();
if (url_compatibility == -1) {
url_compatibility = v;
} else if (url_compatibility != v) {
throw InvalidInputException("Mismatched values of [s3_]url_compatibility_mode setting. Consider removing the secret.");
}
secret->secret_map["url_compatibility_mode"] = Value::BOOLEAN(v);
} else if (lower_name == "s3_url_compatibility_mode") {
if (named_param.second.type() != LogicalType::BOOLEAN) {
throw InvalidInputException("Invalid type past to secret option: '%s', found '%s', expected: 'BOOLEAN'",
lower_name, named_param.second.type().ToString());
}
const bool v = named_param.second.GetValue<bool>();
if (url_compatibility == -1) {
url_compatibility = v;
} else if (url_compatibility != v) {
throw InvalidInputException("Mismatched values of [s3_]url_compatibility_mode setting. Consider removing the secret.");
}
secret->secret_map["s3_url_compatibility_mode"] = Value::BOOLEAN(v);
} else if (lower_name == "account_id") {
continue; // handled already
} else {
throw InternalException("Unknown named parameter passed to CreateSecretFunctionInternal: " + lower_name);
}
}

return std::move(secret);
}

Expand All @@ -91,6 +109,7 @@ void CreateS3SecretFunctions::SetBaseNamedParams(CreateSecretFunction &function,
function.named_parameters["url_style"] = LogicalType::VARCHAR;
function.named_parameters["use_ssl"] = LogicalType::BOOLEAN;
function.named_parameters["url_compatibility_mode"] = LogicalType::BOOLEAN;
function.named_parameters["s3_url_compatibility_mode"] = LogicalType::BOOLEAN;

if (type == "r2") {
function.named_parameters["account_id"] = LogicalType::VARCHAR;
Expand Down

0 comments on commit 6a90eb4

Please sign in to comment.