Skip to content

Commit 6e31df0

Browse files
chore: Update vendored sources to duckdb/duckdb@c6c08d4 (#577)
Fix secret serialization issues (duckdb/duckdb#14652) fix: Initialize atomic class member (duckdb/duckdb#14627) chore: Add qualification for brotli code (duckdb/duckdb#14628) Fix Windows Extensions CI (duckdb/duckdb#14643) Co-authored-by: krlmlr <[email protected]>
1 parent 598851b commit 6e31df0

File tree

9 files changed

+61
-148
lines changed

9 files changed

+61
-148
lines changed

patch/0006-Qualify-brotli.patch

Lines changed: 0 additions & 51 deletions
This file was deleted.

patch/0007-Remove-uninitialized-warnings.patch

Lines changed: 0 additions & 39 deletions
This file was deleted.

patch/0008-Initialize-warning_cb.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/duckdb/src/common/enum_util.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6467,6 +6467,29 @@ SecretPersistType EnumUtil::FromString<SecretPersistType>(const char *value) {
64676467
throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented in FromString<SecretPersistType>", value));
64686468
}
64696469

6470+
template<>
6471+
const char* EnumUtil::ToChars<SecretSerializationType>(SecretSerializationType value) {
6472+
switch(value) {
6473+
case SecretSerializationType::CUSTOM:
6474+
return "CUSTOM";
6475+
case SecretSerializationType::KEY_VALUE_SECRET:
6476+
return "KEY_VALUE_SECRET";
6477+
default:
6478+
throw NotImplementedException(StringUtil::Format("Enum value: '%d' not implemented in ToChars<SecretSerializationType>", value));
6479+
}
6480+
}
6481+
6482+
template<>
6483+
SecretSerializationType EnumUtil::FromString<SecretSerializationType>(const char *value) {
6484+
if (StringUtil::Equals(value, "CUSTOM")) {
6485+
return SecretSerializationType::CUSTOM;
6486+
}
6487+
if (StringUtil::Equals(value, "KEY_VALUE_SECRET")) {
6488+
return SecretSerializationType::KEY_VALUE_SECRET;
6489+
}
6490+
throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented in FromString<SecretSerializationType>", value));
6491+
}
6492+
64706493
template<>
64716494
const char* EnumUtil::ToChars<SequenceInfo>(SequenceInfo value) {
64726495
switch(value) {

src/duckdb/src/function/table/version/pragma_version.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef DUCKDB_PATCH_VERSION
2-
#define DUCKDB_PATCH_VERSION "3-dev142"
2+
#define DUCKDB_PATCH_VERSION "3-dev154"
33
#endif
44
#ifndef DUCKDB_MINOR_VERSION
55
#define DUCKDB_MINOR_VERSION 1
@@ -8,10 +8,10 @@
88
#define DUCKDB_MAJOR_VERSION 1
99
#endif
1010
#ifndef DUCKDB_VERSION
11-
#define DUCKDB_VERSION "v1.1.3-dev142"
11+
#define DUCKDB_VERSION "v1.1.3-dev154"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "7f34190f3f"
14+
#define DUCKDB_SOURCE_ID "c6c08d4c1b"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/include/duckdb/common/enum_util.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ enum class SecretDisplayType : uint8_t;
278278

279279
enum class SecretPersistType : uint8_t;
280280

281+
enum class SecretSerializationType : uint8_t;
282+
281283
enum class SequenceInfo : uint8_t;
282284

283285
enum class SetOperationType : uint8_t;
@@ -728,6 +730,9 @@ const char* EnumUtil::ToChars<SecretDisplayType>(SecretDisplayType value);
728730
template<>
729731
const char* EnumUtil::ToChars<SecretPersistType>(SecretPersistType value);
730732

733+
template<>
734+
const char* EnumUtil::ToChars<SecretSerializationType>(SecretSerializationType value);
735+
731736
template<>
732737
const char* EnumUtil::ToChars<SequenceInfo>(SequenceInfo value);
733738

@@ -1218,6 +1223,9 @@ SecretDisplayType EnumUtil::FromString<SecretDisplayType>(const char *value);
12181223
template<>
12191224
SecretPersistType EnumUtil::FromString<SecretPersistType>(const char *value);
12201225

1226+
template<>
1227+
SecretSerializationType EnumUtil::FromString<SecretSerializationType>(const char *value);
1228+
12211229
template<>
12221230
SequenceInfo EnumUtil::FromString<SequenceInfo>(const char *value);
12231231

src/duckdb/src/include/duckdb/main/secret/secret.hpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ struct CreateSecretInput {
3737
case_insensitive_map_t<Value> options;
3838
};
3939

40-
typedef unique_ptr<BaseSecret> (*secret_deserializer_t)(Deserializer &deserializer, BaseSecret base_secret,
41-
const named_parameter_type_map_t &options);
40+
typedef unique_ptr<BaseSecret> (*secret_deserializer_t)(Deserializer &deserializer, BaseSecret base_secret);
4241
typedef unique_ptr<BaseSecret> (*create_secret_function_t)(ClientContext &context, CreateSecretInput &input);
4342

4443
//! A CreateSecretFunction is a function adds a provider for a secret type.
@@ -81,6 +80,13 @@ struct SecretType {
8180
string default_provider;
8281
};
8382

83+
enum class SecretSerializationType : uint8_t {
84+
//! The secret is serialized with a custom serialization function
85+
CUSTOM = 0,
86+
//! The secret has been serialized as a KeyValueSecret
87+
KEY_VALUE_SECRET = 1
88+
};
89+
8490
//! Base class from which BaseSecret classes can be made.
8591
class BaseSecret {
8692
friend class SecretManager;
@@ -181,30 +187,14 @@ class KeyValueSecret : public BaseSecret {
181187

182188
// FIXME: use serialization scripts
183189
template <class TYPE>
184-
static unique_ptr<BaseSecret> Deserialize(Deserializer &deserializer, BaseSecret base_secret,
185-
const named_parameter_type_map_t &options) {
190+
static unique_ptr<BaseSecret> Deserialize(Deserializer &deserializer, BaseSecret base_secret) {
186191
auto result = make_uniq<TYPE>(base_secret);
187192
Value secret_map_value;
188193
deserializer.ReadProperty(201, "secret_map", secret_map_value);
189194

190195
for (const auto &entry : ListValue::GetChildren(secret_map_value)) {
191196
auto kv_struct = StructValue::GetChildren(entry);
192-
auto key = kv_struct[0].ToString();
193-
auto raw_value = kv_struct[1].ToString();
194-
195-
auto it = options.find(key);
196-
if (it == options.end()) {
197-
throw IOException("Failed to deserialize secret '%s', it contains an unexpected key: '%s'",
198-
base_secret.GetName(), key);
199-
}
200-
auto &logical_type = it->second;
201-
Value value;
202-
if (logical_type.id() == LogicalTypeId::VARCHAR) {
203-
value = Value(raw_value);
204-
} else {
205-
value = Value(raw_value).DefaultCastAs(logical_type);
206-
}
207-
result->secret_map[key] = value;
197+
result->secret_map[kv_struct[0].ToString()] = kv_struct[1];
208198
}
209199

210200
Value redact_set_value;

src/duckdb/src/main/secret/secret.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ void KeyValueSecret::Serialize(Serializer &serializer) const {
8787
map_values.push_back(Value::STRUCT(map_struct));
8888
}
8989

90-
auto map_type = LogicalType::MAP(LogicalType::VARCHAR, LogicalType::VARCHAR);
90+
// Warning: the secret map is serialized into a single MAP value with type ANY
91+
auto map_type = LogicalType::MAP(LogicalType::VARCHAR, LogicalType::ANY);
9192
auto map = Value::MAP(ListType::GetChildType(map_type), map_values);
9293
serializer.WriteProperty(201, "secret_map", map);
9394

src/duckdb/src/main/secret/secret_manager.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ unique_ptr<BaseSecret> SecretManager::DeserializeSecret(Deserializer &deserializ
9797
vector<string> scope;
9898
deserializer.ReadList(103, "scope",
9999
[&](Deserializer::List &list, idx_t i) { scope.push_back(list.ReadElement<string>()); });
100+
auto serialization_type =
101+
deserializer.ReadPropertyWithExplicitDefault(104, "serialization_type", SecretSerializationType::CUSTOM);
102+
103+
switch (serialization_type) {
104+
// This allows us to skip looking up the secret type for deserialization altogether
105+
case SecretSerializationType::KEY_VALUE_SECRET:
106+
return KeyValueSecret::Deserialize<KeyValueSecret>(deserializer, {scope, type, provider, name});
107+
// Continues below: we need to do a type lookup to find the secret deserialize method
108+
case SecretSerializationType::CUSTOM:
109+
break;
110+
default:
111+
throw IOException("Unrecognized secret serialization type found in secret '%s': %s", secret_path,
112+
EnumUtil::ToString(serialization_type));
113+
}
100114

101115
SecretType deserialized_type;
102116
if (!TryLookupTypeInternal(type, deserialized_type)) {
@@ -108,15 +122,7 @@ unique_ptr<BaseSecret> SecretManager::DeserializeSecret(Deserializer &deserializ
108122
"Attempted to deserialize secret type '%s' which does not have a deserialization method", type);
109123
}
110124

111-
auto function_entry = LookupFunctionInternal(type, provider);
112-
if (!function_entry) {
113-
throw IOException("Attempted to deserialize secret (type: '%s', provider: '%s', path: '%s') which does not "
114-
"have any functions registered",
115-
type, provider, secret_path);
116-
}
117-
118-
return deserialized_type.deserializer(deserializer, {scope, type, provider, name},
119-
function_entry->named_parameters);
125+
return deserialized_type.deserializer(deserializer, {scope, type, provider, name});
120126
}
121127

122128
void SecretManager::RegisterSecretType(SecretType &type) {

0 commit comments

Comments
 (0)