Skip to content

Commit db63b69

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to 0efe5ccb5b
1 parent 7fbf610 commit db63b69

File tree

20 files changed

+135
-49
lines changed

20 files changed

+135
-49
lines changed

src/duckdb/extension/parquet/parquet_writer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "duckdb/common/serializer/write_stream.hpp"
1313
#include "duckdb/common/string_util.hpp"
1414
#include "duckdb/function/table_function.hpp"
15+
#include "duckdb/main/extension_helper.hpp"
1516
#include "duckdb/main/client_context.hpp"
1617
#include "duckdb/main/connection.hpp"
1718
#include "duckdb/parser/parsed_data/create_copy_function_info.hpp"
@@ -374,6 +375,12 @@ ParquetWriter::ParquetWriter(ClientContext &context, FileSystem &fs, string file
374375

375376
if (encryption_config) {
376377
auto &config = DBConfig::GetConfig(context);
378+
379+
// To ensure we can write, we need to autoload httpfs
380+
if (!config.encryption_util || !config.encryption_util->SupportsEncryption()) {
381+
ExtensionHelper::TryAutoLoadExtension(context, "httpfs");
382+
}
383+
377384
if (config.encryption_util && debug_use_openssl) {
378385
// Use OpenSSL
379386
encryption_util = config.encryption_util;

src/duckdb/src/common/encryption_key_manager.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ EncryptionKey::EncryptionKey(data_ptr_t encryption_key_p) {
1919
D_ASSERT(memcmp(key, encryption_key_p, MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH) == 0);
2020

2121
// zero out the encryption key in memory
22-
memset(encryption_key_p, 0, MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
22+
duckdb_mbedtls::MbedTlsWrapper::AESStateMBEDTLS::SecureClearData(encryption_key_p,
23+
MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
2324
LockEncryptionKey(key);
2425
}
2526

@@ -37,7 +38,7 @@ void EncryptionKey::LockEncryptionKey(data_ptr_t key, idx_t key_len) {
3738
}
3839

3940
void EncryptionKey::UnlockEncryptionKey(data_ptr_t key, idx_t key_len) {
40-
memset(key, 0, key_len);
41+
duckdb_mbedtls::MbedTlsWrapper::AESStateMBEDTLS::SecureClearData(key, key_len);
4142
#if defined(_WIN32)
4243
VirtualUnlock(key, key_len);
4344
#else
@@ -64,15 +65,16 @@ EncryptionKeyManager &EncryptionKeyManager::Get(DatabaseInstance &db) {
6465

6566
string EncryptionKeyManager::GenerateRandomKeyID() {
6667
uint8_t key_id[KEY_ID_BYTES];
67-
duckdb_mbedtls::MbedTlsWrapper::AESStateMBEDTLS::GenerateRandomDataStatic(key_id, KEY_ID_BYTES);
68+
RandomEngine engine;
69+
engine.RandomData(key_id, KEY_ID_BYTES);
6870
string key_id_str(reinterpret_cast<const char *>(key_id), KEY_ID_BYTES);
6971
return key_id_str;
7072
}
7173

7274
void EncryptionKeyManager::AddKey(const string &key_name, data_ptr_t key) {
7375
derived_keys.emplace(key_name, EncryptionKey(key));
7476
// Zero-out the encryption key
75-
std::memset(key, 0, DERIVED_KEY_LENGTH);
77+
duckdb_mbedtls::MbedTlsWrapper::AESStateMBEDTLS::SecureClearData(key, DERIVED_KEY_LENGTH);
7678
}
7779

7880
bool EncryptionKeyManager::HasKey(const string &key_name) const {
@@ -107,7 +109,7 @@ string EncryptionKeyManager::Base64Decode(const string &key) {
107109
auto output = duckdb::unique_ptr<unsigned char[]>(new unsigned char[result_size]);
108110
Blob::FromBase64(key, output.get(), result_size);
109111
string decoded_key(reinterpret_cast<const char *>(output.get()), result_size);
110-
memset(output.get(), 0, result_size);
112+
duckdb_mbedtls::MbedTlsWrapper::AESStateMBEDTLS::SecureClearData(output.get(), result_size);
111113
return decoded_key;
112114
}
113115

@@ -124,10 +126,9 @@ void EncryptionKeyManager::DeriveKey(string &user_key, data_ptr_t salt, data_ptr
124126

125127
KeyDerivationFunctionSHA256(reinterpret_cast<const_data_ptr_t>(decoded_key.data()), decoded_key.size(), salt,
126128
derived_key);
127-
128-
// wipe the original and decoded key
129-
std::fill(user_key.begin(), user_key.end(), 0);
130-
std::fill(decoded_key.begin(), decoded_key.end(), 0);
129+
duckdb_mbedtls::MbedTlsWrapper::AESStateMBEDTLS::SecureClearData(data_ptr_cast(&user_key[0]), user_key.size());
130+
duckdb_mbedtls::MbedTlsWrapper::AESStateMBEDTLS::SecureClearData(data_ptr_cast(&decoded_key[0]),
131+
decoded_key.size());
131132
user_key.clear();
132133
decoded_key.clear();
133134
}

src/duckdb/src/common/random_engine.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,14 @@ void RandomEngine::SetSeed(uint64_t seed) {
8282
random_state->pcg.seed(seed);
8383
}
8484

85+
void RandomEngine::RandomData(duckdb::data_ptr_t data, duckdb::idx_t len) {
86+
while (len) {
87+
const auto random_integer = NextRandomInteger();
88+
const auto next = duckdb::MinValue<duckdb::idx_t>(len, sizeof(random_integer));
89+
memcpy(data, duckdb::const_data_ptr_cast(&random_integer), next);
90+
data += next;
91+
len -= next;
92+
}
93+
}
94+
8595
} // namespace duckdb

src/duckdb/src/execution/operator/scan/physical_table_scan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ bool PhysicalTableScan::Equals(const PhysicalOperator &other_p) const {
259259
return false;
260260
}
261261
auto &other = other_p.Cast<PhysicalTableScan>();
262-
if (function.function != other.function.function) {
262+
if (function != other.function) {
263263
return false;
264264
}
265265
if (column_ids != other.column_ids) {

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 "2-dev305"
2+
#define DUCKDB_PATCH_VERSION "2-dev332"
33
#endif
44
#ifndef DUCKDB_MINOR_VERSION
55
#define DUCKDB_MINOR_VERSION 4
@@ -8,10 +8,10 @@
88
#define DUCKDB_MAJOR_VERSION 1
99
#endif
1010
#ifndef DUCKDB_VERSION
11-
#define DUCKDB_VERSION "v1.4.2-dev305"
11+
#define DUCKDB_VERSION "v1.4.2-dev332"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "8090b8d52e"
14+
#define DUCKDB_SOURCE_ID "0efe5ccb5b"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/function/table_function.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ TableFunction::TableFunction(const vector<LogicalType> &arguments, table_functio
3737
TableFunction::TableFunction() : TableFunction("", {}, nullptr, nullptr, nullptr, nullptr) {
3838
}
3939

40+
bool TableFunction::operator==(const TableFunction &rhs) const {
41+
return name == rhs.name && arguments == rhs.arguments && varargs == rhs.varargs && bind == rhs.bind &&
42+
bind_replace == rhs.bind_replace && bind_operator == rhs.bind_operator && init_global == rhs.init_global &&
43+
init_local == rhs.init_local && function == rhs.function && in_out_function == rhs.in_out_function &&
44+
in_out_function_final == rhs.in_out_function_final && statistics == rhs.statistics &&
45+
dependency == rhs.dependency && cardinality == rhs.cardinality &&
46+
pushdown_complex_filter == rhs.pushdown_complex_filter && pushdown_expression == rhs.pushdown_expression &&
47+
to_string == rhs.to_string && dynamic_to_string == rhs.dynamic_to_string &&
48+
table_scan_progress == rhs.table_scan_progress && get_partition_data == rhs.get_partition_data &&
49+
get_bind_info == rhs.get_bind_info && type_pushdown == rhs.type_pushdown &&
50+
get_multi_file_reader == rhs.get_multi_file_reader && supports_pushdown_type == rhs.supports_pushdown_type &&
51+
get_partition_info == rhs.get_partition_info && get_partition_stats == rhs.get_partition_stats &&
52+
get_virtual_columns == rhs.get_virtual_columns && get_row_id_columns == rhs.get_row_id_columns &&
53+
serialize == rhs.serialize && deserialize == rhs.deserialize &&
54+
verify_serialization == rhs.verify_serialization && projection_pushdown == rhs.projection_pushdown &&
55+
filter_pushdown == rhs.filter_pushdown && filter_prune == rhs.filter_prune &&
56+
sampling_pushdown == rhs.sampling_pushdown && late_materialization == rhs.late_materialization &&
57+
global_initialization == rhs.global_initialization;
58+
}
59+
60+
bool TableFunction::operator!=(const TableFunction &rhs) const {
61+
return !(*this == rhs);
62+
}
63+
4064
bool TableFunction::Equal(const TableFunction &rhs) const {
4165
// number of types
4266
if (this->arguments.size() != rhs.arguments.size()) {

src/duckdb/src/include/duckdb/common/encryption_key_manager.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class EncryptionKeyManager : public ObjectCacheEntry {
6666
static void KeyDerivationFunctionSHA256(data_ptr_t user_key, idx_t user_key_size, data_ptr_t salt,
6767
data_ptr_t derived_key);
6868
static string Base64Decode(const string &key);
69+
70+
//! Generate a (non-cryptographically secure) random key ID
6971
static string GenerateRandomKeyID();
7072

7173
public:

src/duckdb/src/include/duckdb/common/encryption_state.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class EncryptionUtil {
5959

6060
virtual ~EncryptionUtil() {
6161
}
62+
63+
//! Whether the EncryptionUtil supports encryption (some may only support decryption)
64+
DUCKDB_API virtual bool SupportsEncryption() {
65+
return true;
66+
}
6267
};
6368

6469
} // namespace duckdb

src/duckdb/src/include/duckdb/common/http_util.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ struct PostRequestInfo : public BaseRequest {
216216
class HTTPClient {
217217
public:
218218
virtual ~HTTPClient() = default;
219+
virtual void Initialize(HTTPParams &http_params) = 0;
219220

220221
virtual unique_ptr<HTTPResponse> Get(GetRequestInfo &info) = 0;
221222
virtual unique_ptr<HTTPResponse> Put(PutRequestInfo &info) = 0;

src/duckdb/src/include/duckdb/common/random_engine.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class RandomEngine {
3838

3939
void SetSeed(uint64_t seed);
4040

41+
void RandomData(duckdb::data_ptr_t data, duckdb::idx_t len);
42+
4143
static RandomEngine &Get(ClientContext &context);
4244

4345
mutex lock;

0 commit comments

Comments
 (0)