Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/duckdb/src/catalog/catalog_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,17 @@ optional_ptr<CatalogEntry> CatalogSet::CreateDefaultEntry(CatalogTransaction tra
// no defaults either: return null
return nullptr;
}
read_lock.unlock();
auto unlock = !defaults->LockDuringCreate();
if (unlock) {
read_lock.unlock();
}
// this catalog set has a default map defined
// check if there is a default entry that we can create with this name
auto entry = defaults->CreateDefaultEntry(transaction, name);

read_lock.lock();
if (unlock) {
read_lock.lock();
}
if (!entry) {
// no default entry
return nullptr;
Expand All @@ -582,7 +587,9 @@ optional_ptr<CatalogEntry> CatalogSet::CreateDefaultEntry(CatalogTransaction tra
// we found a default entry, but failed
// this means somebody else created the entry first
// just retry?
read_lock.unlock();
if (unlock) {
read_lock.unlock();
}
return GetEntry(transaction, name);
}

Expand Down Expand Up @@ -653,20 +660,25 @@ void CatalogSet::CreateDefaultEntries(CatalogTransaction transaction, unique_loc
if (!defaults || defaults->created_all_entries) {
return;
}
auto unlock = !defaults->LockDuringCreate();
// this catalog set has a default set defined:
auto default_entries = defaults->GetDefaultEntries();
for (auto &default_entry : default_entries) {
auto entry_value = map.GetEntry(default_entry);
if (!entry_value) {
// we unlock during the CreateEntry, since it might reference other catalog sets...
// specifically for views this can happen since the view will be bound
read_lock.unlock();
if (unlock) {
read_lock.unlock();
}
auto entry = defaults->CreateDefaultEntry(transaction, default_entry);
if (!entry) {
throw InternalException("Failed to create default entry for %s", default_entry);
}

read_lock.lock();
if (unlock) {
read_lock.lock();
}
CreateCommittedEntry(std::move(entry));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/duckdb/src/function/table/version/pragma_version.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef DUCKDB_PATCH_VERSION
#define DUCKDB_PATCH_VERSION "5-dev2"
#define DUCKDB_PATCH_VERSION "5-dev4"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 4
Expand All @@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 1
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v1.4.5-dev2"
#define DUCKDB_VERSION "v1.4.5-dev4"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "32ae75b320"
#define DUCKDB_SOURCE_ID "b6fbc09f79"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class DefaultGenerator {
virtual unique_ptr<CatalogEntry> CreateDefaultEntry(CatalogTransaction transaction, const string &entry_name);
//! Get a list of all default entries in the generator
virtual vector<string> GetDefaultEntries() = 0;
//! Whether or not we should keep the lock while calling CreateDefaultEntry
//! If this is set to false, CreateDefaultEntry might be called multiple times in parallel also for the same entry
//! Otherwise it will be called exactly once per entry
virtual bool LockDuringCreate() const {
return false;
}
};

} // namespace duckdb
3 changes: 3 additions & 0 deletions src/duckdb/src/include/duckdb/main/secret/secret_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ class DefaultSecretGenerator : public DefaultGenerator {
unique_ptr<CatalogEntry> CreateDefaultEntry(CatalogTransaction transaction, const string &entry_name) override;
unique_ptr<CatalogEntry> CreateDefaultEntry(ClientContext &context, const string &entry_name) override;
vector<string> GetDefaultEntries() override;
bool LockDuringCreate() const override {
return true;
}

protected:
unique_ptr<CatalogEntry> CreateDefaultEntryInternal(const string &entry_name);
Expand Down