Skip to content

Commit 970a4f6

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to 24c295a9dd
1 parent 66b7287 commit 970a4f6

39 files changed

Lines changed: 280 additions & 180 deletions

src/duckdb/src/catalog/catalog_set.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,6 @@ bool CatalogSet::DropEntryInternal(CatalogTransaction transaction, const string
401401
throw CatalogException("Cannot drop entry \"%s\" because it is an internal system entry", entry->name);
402402
}
403403

404-
entry->OnDrop();
405-
406404
// create a new tombstone entry and replace the currently stored one
407405
// set the timestamp to the timestamp of the current transaction
408406
// and point it at the tombstone node
@@ -454,6 +452,7 @@ void CatalogSet::VerifyExistenceOfDependency(transaction_t commit_id, CatalogEnt
454452
void CatalogSet::CommitDrop(transaction_t commit_id, transaction_t start_time, CatalogEntry &entry) {
455453
auto &duck_catalog = GetCatalog();
456454

455+
entry.OnDrop();
457456
// Make sure that we don't see any uncommitted changes
458457
auto transaction_id = MAX_TRANSACTION_ID;
459458
// This will allow us to see all committed changes made before this COMMIT happened

src/duckdb/src/common/file_system.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -628,39 +628,9 @@ bool FileSystem::CanHandleFile(const string &fpath) {
628628
throw NotImplementedException("%s: CanHandleFile is not implemented!", GetName());
629629
}
630630

631-
static string LookupExtensionForPattern(const string &pattern) {
632-
for (const auto &entry : EXTENSION_FILE_PREFIXES) {
633-
if (StringUtil::StartsWith(pattern, entry.name)) {
634-
return entry.extension;
635-
}
636-
}
637-
return "";
638-
}
639-
640631
vector<OpenFileInfo> FileSystem::GlobFiles(const string &pattern, ClientContext &context, const FileGlobInput &input) {
641632
auto result = Glob(pattern);
642633
if (result.empty()) {
643-
string required_extension = LookupExtensionForPattern(pattern);
644-
if (!required_extension.empty() && !context.db->ExtensionIsLoaded(required_extension)) {
645-
auto &dbconfig = DBConfig::GetConfig(context);
646-
if (!ExtensionHelper::CanAutoloadExtension(required_extension) ||
647-
!dbconfig.options.autoload_known_extensions) {
648-
auto error_message =
649-
"File " + pattern + " requires the extension " + required_extension + " to be loaded";
650-
error_message =
651-
ExtensionHelper::AddExtensionInstallHintToErrorMsg(context, error_message, required_extension);
652-
throw MissingExtensionException(error_message);
653-
}
654-
// an extension is required to read this file, but it is not loaded - try to load it
655-
ExtensionHelper::AutoLoadExtension(context, required_extension);
656-
// success! glob again
657-
// check the extension is loaded just in case to prevent an infinite loop here
658-
if (!context.db->ExtensionIsLoaded(required_extension)) {
659-
throw InternalException("Extension load \"%s\" did not throw but somehow the extension was not loaded",
660-
required_extension);
661-
}
662-
return GlobFiles(pattern, context, input);
663-
}
664634
if (input.behavior == FileGlobOptions::FALLBACK_GLOB && !HasGlob(pattern)) {
665635
// if we have no glob in the pattern and we have an extension, we try to glob
666636
if (!HasGlob(pattern)) {

src/duckdb/src/common/sorting/sort.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,15 @@ class SortGlobalSourceState : public GlobalSourceState {
378378
return merger_global_state ? merger_global_state->MaxThreads() : 1;
379379
}
380380

381+
void Destroy() {
382+
if (!merger_global_state) {
383+
return;
384+
}
385+
auto guard = merger_global_state->Lock();
386+
merger.sorted_runs.clear();
387+
sink.temporary_memory_state.reset();
388+
}
389+
381390
public:
382391
//! The global sink state
383392
SortGlobalSinkState &sink;
@@ -477,16 +486,26 @@ SourceResultType Sort::MaterializeColumnData(ExecutionContext &context, Operator
477486
}
478487

479488
// Merge into global output collection
480-
auto guard = gstate.Lock();
481-
if (!gstate.column_data) {
482-
gstate.column_data = std::move(local_column_data);
483-
} else {
484-
gstate.column_data->Merge(*local_column_data);
489+
{
490+
auto guard = gstate.Lock();
491+
if (!gstate.column_data) {
492+
gstate.column_data = std::move(local_column_data);
493+
} else {
494+
gstate.column_data->Merge(*local_column_data);
495+
}
485496
}
486497

498+
// Destroy local state before returning
499+
input.local_state.Cast<SortLocalSourceState>().merger_local_state.reset();
500+
487501
// Return type indicates whether materialization is done
488502
const auto progress_data = GetProgress(context.client, input.global_state);
489-
return progress_data.done == progress_data.total ? SourceResultType::FINISHED : SourceResultType::HAVE_MORE_OUTPUT;
503+
if (progress_data.done == progress_data.total) {
504+
// Destroy global state before returning
505+
gstate.Destroy();
506+
return SourceResultType::FINISHED;
507+
}
508+
return SourceResultType::HAVE_MORE_OUTPUT;
490509
}
491510

492511
unique_ptr<ColumnDataCollection> Sort::GetColumnData(OperatorSourceInput &input) const {

src/duckdb/src/common/sorting/sorted_run_merger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ SortedRunMerger::SortedRunMerger(const Expression &decode_sort_key_p, shared_ptr
888888
unique_ptr<LocalSourceState> SortedRunMerger::GetLocalSourceState(ExecutionContext &,
889889
GlobalSourceState &gstate_p) const {
890890
auto &gstate = gstate_p.Cast<SortedRunMergerGlobalState>();
891+
auto guard = gstate.Lock();
891892
return make_uniq<SortedRunMergerLocalState>(gstate);
892893
}
893894

src/duckdb/src/common/virtual_file_system.cpp

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ VirtualFileSystem::VirtualFileSystem(unique_ptr<FileSystem> &&inner) : default_f
1717

1818
unique_ptr<FileHandle> VirtualFileSystem::OpenFileExtended(const OpenFileInfo &file, FileOpenFlags flags,
1919
optional_ptr<FileOpener> opener) {
20+
2021
auto compression = flags.Compression();
2122
if (compression == FileCompressionType::AUTO_DETECT) {
2223
// auto-detect compression settings based on file name
@@ -34,8 +35,9 @@ unique_ptr<FileHandle> VirtualFileSystem::OpenFileExtended(const OpenFileInfo &f
3435
}
3536
}
3637
// open the base file handle in UNCOMPRESSED mode
38+
3739
flags.SetCompression(FileCompressionType::UNCOMPRESSED);
38-
auto file_handle = FindFileSystem(file.path).OpenFile(file, flags, opener);
40+
auto file_handle = FindFileSystem(file.path, opener).OpenFile(file, flags, opener);
3941
if (!file_handle) {
4042
return nullptr;
4143
}
@@ -111,15 +113,15 @@ void VirtualFileSystem::RemoveDirectory(const string &directory, optional_ptr<Fi
111113
bool VirtualFileSystem::ListFilesExtended(const string &directory,
112114
const std::function<void(OpenFileInfo &info)> &callback,
113115
optional_ptr<FileOpener> opener) {
114-
return FindFileSystem(directory).ListFiles(directory, callback, opener);
116+
return FindFileSystem(directory, opener).ListFiles(directory, callback, opener);
115117
}
116118

117119
void VirtualFileSystem::MoveFile(const string &source, const string &target, optional_ptr<FileOpener> opener) {
118120
FindFileSystem(source).MoveFile(source, target, opener);
119121
}
120122

121123
bool VirtualFileSystem::FileExists(const string &filename, optional_ptr<FileOpener> opener) {
122-
return FindFileSystem(filename).FileExists(filename, opener);
124+
return FindFileSystem(filename, opener).FileExists(filename, opener);
123125
}
124126

125127
bool VirtualFileSystem::IsPipe(const string &filename, optional_ptr<FileOpener> opener) {
@@ -139,7 +141,7 @@ string VirtualFileSystem::PathSeparator(const string &path) {
139141
}
140142

141143
vector<OpenFileInfo> VirtualFileSystem::Glob(const string &path, FileOpener *opener) {
142-
return FindFileSystem(path).Glob(path, opener);
144+
return FindFileSystem(path, opener).Glob(path, opener);
143145
}
144146

145147
void VirtualFileSystem::RegisterSubSystem(unique_ptr<FileSystem> fs) {
@@ -216,16 +218,61 @@ bool VirtualFileSystem::SubSystemIsDisabled(const string &name) {
216218
return disabled_file_systems.find(name) != disabled_file_systems.end();
217219
}
218220

221+
FileSystem &VirtualFileSystem::FindFileSystem(const string &path, optional_ptr<FileOpener> opener) {
222+
return FindFileSystem(path, FileOpener::TryGetDatabase(opener));
223+
}
224+
225+
FileSystem &VirtualFileSystem::FindFileSystem(const string &path, optional_ptr<DatabaseInstance> db_instance) {
226+
auto fs = FindFileSystemInternal(path);
227+
228+
if (!fs && db_instance) {
229+
string required_extension;
230+
231+
for (const auto &entry : EXTENSION_FILE_PREFIXES) {
232+
if (StringUtil::StartsWith(path, entry.name)) {
233+
required_extension = entry.extension;
234+
}
235+
}
236+
if (!required_extension.empty() && db_instance && !db_instance->ExtensionIsLoaded(required_extension)) {
237+
auto &dbconfig = DBConfig::GetConfig(*db_instance);
238+
if (!ExtensionHelper::CanAutoloadExtension(required_extension) ||
239+
!dbconfig.options.autoload_known_extensions) {
240+
auto error_message = "File " + path + " requires the extension " + required_extension + " to be loaded";
241+
error_message =
242+
ExtensionHelper::AddExtensionInstallHintToErrorMsg(*db_instance, error_message, required_extension);
243+
throw MissingExtensionException(error_message);
244+
}
245+
// an extension is required to read this file, but it is not loaded - try to load it
246+
ExtensionHelper::AutoLoadExtension(*db_instance, required_extension);
247+
}
248+
249+
// Retry after having autoloaded
250+
fs = FindFileSystem(path);
251+
}
252+
253+
if (!fs) {
254+
fs = default_fs;
255+
}
256+
if (!disabled_file_systems.empty() && disabled_file_systems.find(fs->GetName()) != disabled_file_systems.end()) {
257+
throw PermissionException("File system %s has been disabled by configuration", fs->GetName());
258+
}
259+
return *fs;
260+
}
261+
219262
FileSystem &VirtualFileSystem::FindFileSystem(const string &path) {
220-
auto &fs = FindFileSystemInternal(path);
221-
if (!disabled_file_systems.empty() && disabled_file_systems.find(fs.GetName()) != disabled_file_systems.end()) {
222-
throw PermissionException("File system %s has been disabled by configuration", fs.GetName());
263+
auto fs = FindFileSystemInternal(path);
264+
if (!fs) {
265+
fs = default_fs;
266+
}
267+
if (!disabled_file_systems.empty() && disabled_file_systems.find(fs->GetName()) != disabled_file_systems.end()) {
268+
throw PermissionException("File system %s has been disabled by configuration", fs->GetName());
223269
}
224-
return fs;
270+
return *fs;
225271
}
226272

227-
FileSystem &VirtualFileSystem::FindFileSystemInternal(const string &path) {
273+
optional_ptr<FileSystem> VirtualFileSystem::FindFileSystemInternal(const string &path) {
228274
FileSystem *fs = nullptr;
275+
229276
for (auto &sub_system : sub_systems) {
230277
if (sub_system->CanHandleFile(path)) {
231278
if (sub_system->IsManuallySet()) {
@@ -237,7 +284,9 @@ FileSystem &VirtualFileSystem::FindFileSystemInternal(const string &path) {
237284
if (fs) {
238285
return *fs;
239286
}
240-
return *default_fs;
287+
288+
// We could use default_fs, that's on the caller
289+
return nullptr;
241290
}
242291

243292
} // namespace duckdb

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 "1-dev136"
2+
#define DUCKDB_PATCH_VERSION "1-dev178"
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.1-dev136"
11+
#define DUCKDB_VERSION "v1.4.1-dev178"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "76a3383248"
14+
#define DUCKDB_SOURCE_ID "24c295a9dd"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/include/duckdb/common/virtual_file_system.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "duckdb/common/file_system.hpp"
1212
#include "duckdb/common/map.hpp"
1313
#include "duckdb/common/unordered_set.hpp"
14+
#include "duckdb/main/extension_helper.hpp"
1415

1516
namespace duckdb {
1617

@@ -82,8 +83,10 @@ class VirtualFileSystem : public FileSystem {
8283
}
8384

8485
private:
86+
FileSystem &FindFileSystem(const string &path, optional_ptr<FileOpener> file_opener);
87+
FileSystem &FindFileSystem(const string &path, optional_ptr<DatabaseInstance> database_instance);
8588
FileSystem &FindFileSystem(const string &path);
86-
FileSystem &FindFileSystemInternal(const string &path);
89+
optional_ptr<FileSystem> FindFileSystemInternal(const string &path);
8790

8891
private:
8992
vector<unique_ptr<FileSystem>> sub_systems;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ class KeyValueSecretReader {
296296
Value result;
297297
auto lookup_result = TryGetSecretKeyOrSetting(secret_key, setting_name, result);
298298
if (lookup_result) {
299-
value_out = result.GetValue<TYPE>();
299+
if (!result.IsNull()) {
300+
value_out = result.GetValue<TYPE>();
301+
}
300302
}
301303
return lookup_result;
302304
}

src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ class FilterPushdown {
102102
void ExtractFilterBindings(const Expression &expr, vector<ColumnBinding> &bindings);
103103
//! Generate filters from the current set of filters stored in the FilterCombiner
104104
void GenerateFilters();
105-
//! if there are filters in this FilterPushdown node, push them into the combiner
106-
void PushFilters();
105+
//! if there are filters in this FilterPushdown node, push them into the combiner. Returns
106+
//! FilterResult::UNSATISFIABLE if the subtree should be stripped, or FilterResult::SUCCESS otherwise
107+
FilterResult PushFilters();
107108
};
108109

109110
} // namespace duckdb

src/duckdb/src/include/duckdb/storage/table/array_column_data.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class ArrayColumnData : public ColumnData {
4848
idx_t Fetch(ColumnScanState &state, row_t row_id, Vector &result) override;
4949
void FetchRow(TransactionData transaction, ColumnFetchState &state, row_t row_id, Vector &result,
5050
idx_t result_idx) override;
51-
void Update(TransactionData transaction, idx_t column_index, Vector &update_vector, row_t *row_ids,
52-
idx_t update_count) override;
53-
void UpdateColumn(TransactionData transaction, const vector<column_t> &column_path, Vector &update_vector,
54-
row_t *row_ids, idx_t update_count, idx_t depth) override;
51+
void Update(TransactionData transaction, DataTable &data_table, idx_t column_index, Vector &update_vector,
52+
row_t *row_ids, idx_t update_count) override;
53+
void UpdateColumn(TransactionData transaction, DataTable &data_table, const vector<column_t> &column_path,
54+
Vector &update_vector, row_t *row_ids, idx_t update_count, idx_t depth) override;
5555
unique_ptr<BaseStatistics> GetUpdateStatistics() override;
5656

5757
void CommitDropColumn() override;

0 commit comments

Comments
 (0)