Skip to content

Commit 765cd76

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to 9cb1e3d3ca
1 parent 8b5dda3 commit 765cd76

File tree

18 files changed

+102
-71
lines changed

18 files changed

+102
-71
lines changed

src/duckdb/extension/json/json_functions/copy_json.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ static void ThrowJSONCopyParameterException(const string &loption) {
1818
}
1919

2020
static BoundStatement CopyToJSONPlan(Binder &binder, CopyStatement &stmt) {
21+
static const unordered_set<string> SUPPORTED_BASE_OPTIONS {
22+
"compression", "encoding", "use_tmp_file", "overwrite_or_ignore", "overwrite", "append", "filename_pattern",
23+
"file_extension", "per_thread_output", "file_size_bytes",
24+
// "partition_by", unsupported
25+
"return_files", "preserve_order", "return_stats", "write_partition_columns", "write_empty_file",
26+
"hive_file_pattern"};
27+
2128
auto stmt_copy = stmt.Copy();
2229
auto &copy = stmt_copy->Cast<CopyStatement>();
2330
auto &copied_info = *copy.info;
@@ -48,9 +55,7 @@ static BoundStatement CopyToJSONPlan(Binder &binder, CopyStatement &stmt) {
4855
csv_copy_options["suffix"] = {"\n]\n"};
4956
csv_copy_options["new_line"] = {",\n\t"};
5057
}
51-
} else if (loption == "compression" || loption == "encoding" || loption == "per_thread_output" ||
52-
loption == "file_size_bytes" || loption == "use_tmp_file" || loption == "overwrite_or_ignore" ||
53-
loption == "filename_pattern" || loption == "file_extension") {
58+
} else if (SUPPORTED_BASE_OPTIONS.find(loption) != SUPPORTED_BASE_OPTIONS.end()) {
5459
// We support these base options
5560
csv_copy_options.insert(kv);
5661
} else {

src/duckdb/extension/parquet/parquet_crypto.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ class EncryptionTransport : public TTransport {
9090
public:
9191
EncryptionTransport(TProtocol &prot_p, const string &key, const EncryptionUtil &encryption_util_p)
9292
: prot(prot_p), trans(*prot.getTransport()),
93-
aes(encryption_util_p.CreateEncryptionState(EncryptionTypes::GCM,
94-
reinterpret_cast<const_data_ptr_t>(key.data()), key.size())),
93+
aes(encryption_util_p.CreateEncryptionState(EncryptionTypes::GCM, key.size())),
9594
allocator(Allocator::DefaultAllocator(), ParquetCrypto::CRYPTO_BLOCK_SIZE) {
9695
Initialize(key);
9796
}
@@ -174,9 +173,8 @@ class DecryptionTransport : public TTransport {
174173
public:
175174
DecryptionTransport(TProtocol &prot_p, const string &key, const EncryptionUtil &encryption_util_p)
176175
: prot(prot_p), trans(*prot.getTransport()),
177-
aes(encryption_util_p.CreateEncryptionState(EncryptionTypes::GCM,
178-
reinterpret_cast<const_data_ptr_t>(key.data()), key.size())),
179-
read_buffer_size(0), read_buffer_offset(0) {
176+
aes(encryption_util_p.CreateEncryptionState(EncryptionTypes::GCM, key.size())), read_buffer_size(0),
177+
read_buffer_offset(0) {
180178
Initialize(key);
181179
}
182180
uint32_t read_virt(uint8_t *buf, uint32_t len) override {

src/duckdb/src/common/encryption_functions.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void EncryptionEngine::AddTempKeyToCache(DatabaseInstance &db) {
7373
data_t temp_key[length];
7474

7575
auto encryption_state = db.GetEncryptionUtil()->CreateEncryptionState(
76-
/* only for random generator */ EncryptionTypes::GCM, temp_key, length);
76+
/* only for random generator */ EncryptionTypes::GCM, length);
7777
encryption_state->GenerateRandomData(temp_key, length);
7878

7979
string key_id = "temp_key";
@@ -85,8 +85,8 @@ void EncryptionEngine::EncryptBlock(AttachedDatabase &attached_db, const string
8585
auto &db = attached_db.GetDatabase();
8686
data_ptr_t block_offset_internal = temp_buffer_manager.InternalBuffer();
8787
auto encrypt_key = GetKeyFromCache(db, key_id);
88-
auto encryption_state = db.GetEncryptionUtil()->CreateEncryptionState(
89-
attached_db.GetStorageManager().GetCipher(), encrypt_key, MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
88+
auto encryption_state = db.GetEncryptionUtil()->CreateEncryptionState(attached_db.GetStorageManager().GetCipher(),
89+
MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
9090

9191
EncryptionTag tag;
9292
EncryptionNonce nonce;
@@ -121,8 +121,8 @@ void EncryptionEngine::DecryptBlock(AttachedDatabase &attached_db, const string
121121
auto &db = attached_db.GetDatabase();
122122

123123
auto decrypt_key = GetKeyFromCache(db, key_id);
124-
auto encryption_state = db.GetEncryptionUtil()->CreateEncryptionState(
125-
attached_db.GetStorageManager().GetCipher(), decrypt_key, MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
124+
auto encryption_state = db.GetEncryptionUtil()->CreateEncryptionState(attached_db.GetStorageManager().GetCipher(),
125+
MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
126126

127127
//! load the stored nonce and tag
128128
EncryptionTag tag;
@@ -158,8 +158,8 @@ void EncryptionEngine::EncryptTemporaryBuffer(DatabaseInstance &db, data_ptr_t b
158158

159159
auto encryption_util = db.GetEncryptionUtil();
160160
// we hard-code GCM here for now, it's the safest and we don't know what is configured here
161-
auto encryption_state = encryption_util->CreateEncryptionState(EncryptionTypes::GCM, temp_key,
162-
MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
161+
auto encryption_state =
162+
encryption_util->CreateEncryptionState(EncryptionTypes::GCM, MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
163163

164164
// zero-out the metadata buffer
165165
memset(metadata, 0, DEFAULT_ENCRYPTED_BUFFER_HEADER_SIZE);
@@ -219,8 +219,8 @@ void EncryptionEngine::DecryptTemporaryBuffer(DatabaseInstance &db, data_ptr_t b
219219
//! initialize encryption state
220220
auto encryption_util = db.GetEncryptionUtil();
221221
auto temp_key = GetKeyFromCache(db, "temp_key");
222-
auto encryption_state = encryption_util->CreateEncryptionState(EncryptionTypes::GCM, temp_key,
223-
MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
222+
auto encryption_state =
223+
encryption_util->CreateEncryptionState(EncryptionTypes::GCM, MainHeader::DEFAULT_ENCRYPTION_KEY_LENGTH);
224224

225225
DecryptBuffer(*encryption_state, temp_key, buffer, buffer_size, metadata);
226226
}

src/duckdb/src/common/encryption_state.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace duckdb {
44

5-
EncryptionState::EncryptionState(EncryptionTypes::CipherType, const_data_ptr_t, idx_t) {
6-
// abstract class, no implementation needed
5+
EncryptionState::EncryptionState(EncryptionTypes::CipherType cipher_p, idx_t key_len_p)
6+
: cipher(cipher_p), key_len(key_len_p) {
77
}
88

99
EncryptionState::~EncryptionState() {
@@ -51,7 +51,7 @@ EncryptionTypes::CipherType EncryptionTypes::StringToCipher(const string &encryp
5151
return CTR;
5252
}
5353
if (encryption_cipher == "CBC") {
54-
return CBC;
54+
throw NotImplementedException("CBC encryption is disabled");
5555
}
5656
return INVALID;
5757
}

src/duckdb/src/common/sorting/sorted_run.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ void SortedRun::Finalize(bool external) {
304304
const auto sort_key_type = key_data->GetLayout().GetSortKeyType();
305305
if (!SortKeyUtils::IsConstantSize(sort_key_type) || SortKeyUtils::HasPayload(sort_key_type)) {
306306
Reorder(context, key_data, payload_data);
307+
} else {
308+
// This ensures keys are unpinned even if they are constant size and have no payload
309+
key_data->Unpin();
307310
}
308311
}
309312

src/duckdb/src/common/types.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,10 @@ LogicalType GetUserTypeRecursive(const LogicalType &type, ClientContext &context
624624
if (type.id() == LogicalTypeId::LIST) {
625625
return LogicalType::LIST(GetUserTypeRecursive(ListType::GetChildType(type), context));
626626
}
627+
if (type.id() == LogicalTypeId::ARRAY) {
628+
return LogicalType::ARRAY(GetUserTypeRecursive(ArrayType::GetChildType(type), context),
629+
ArrayType::GetSize(type));
630+
}
627631
if (type.id() == LogicalTypeId::MAP) {
628632
return LogicalType::MAP(GetUserTypeRecursive(MapType::KeyType(type), context),
629633
GetUserTypeRecursive(MapType::ValueType(type), context));

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 "0-dev4049"
2+
#define DUCKDB_PATCH_VERSION "0-dev4076"
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.0-dev4049"
11+
#define DUCKDB_VERSION "v1.4.0-dev4076"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "a92d9fc987"
14+
#define DUCKDB_SOURCE_ID "9cb1e3d3ca"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class EncryptionTypes {
2929
class EncryptionState {
3030

3131
public:
32-
DUCKDB_API explicit EncryptionState(EncryptionTypes::CipherType cipher_p, const_data_ptr_t key = nullptr,
33-
idx_t key_len = 0);
32+
DUCKDB_API explicit EncryptionState(EncryptionTypes::CipherType cipher_p, idx_t key_len);
3433
DUCKDB_API virtual ~EncryptionState();
3534

3635
public:
@@ -41,6 +40,10 @@ class EncryptionState {
4140
DUCKDB_API virtual size_t Process(const_data_ptr_t in, idx_t in_len, data_ptr_t out, idx_t out_len);
4241
DUCKDB_API virtual size_t Finalize(data_ptr_t out, idx_t out_len, data_ptr_t tag, idx_t tag_len);
4342
DUCKDB_API virtual void GenerateRandomData(data_ptr_t data, idx_t len);
43+
44+
protected:
45+
EncryptionTypes::CipherType cipher;
46+
idx_t key_len;
4447
};
4548

4649
class EncryptionUtil {
@@ -50,8 +53,8 @@ class EncryptionUtil {
5053

5154
public:
5255
virtual shared_ptr<EncryptionState> CreateEncryptionState(EncryptionTypes::CipherType cipher_p,
53-
const_data_ptr_t key = nullptr, idx_t key_len = 0) const {
54-
return make_shared_ptr<EncryptionState>(cipher_p, key, key_len);
56+
idx_t key_len = 0) const {
57+
return make_shared_ptr<EncryptionState>(cipher_p, key_len);
5558
}
5659

5760
virtual ~EncryptionUtil() {

src/duckdb/src/include/duckdb/storage/storage_manager.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class StorageManager {
129129
}
130130
void SetCipher(EncryptionTypes::CipherType cipher_p) {
131131
D_ASSERT(cipher_p != EncryptionTypes::INVALID);
132+
if (cipher_p == EncryptionTypes::CBC) {
133+
throw InvalidInputException("CBC cipher is disabled");
134+
}
132135
storage_options.encryption_cipher = cipher_p;
133136
}
134137
bool IsEncrypted() const {

src/duckdb/src/main/http/http_util.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,12 @@ HTTPUtil::RunRequestWithRetry(const std::function<unique_ptr<HTTPResponse>(void)
379379
// Note: request errors will always be retried
380380
bool should_retry = !response || response->ShouldRetry();
381381
if (!should_retry) {
382+
auto response_code = static_cast<uint16_t>(response->status);
383+
if (response_code >= 200 && response_code < 300) {
384+
response->success = true;
385+
return response;
386+
}
382387
switch (response->status) {
383-
case HTTPStatusCode::OK_200:
384388
case HTTPStatusCode::NotModified_304:
385389
response->success = true;
386390
break;

0 commit comments

Comments
 (0)