From 3ac477d185d99045d4dd4e7664b6d115e2f29e07 Mon Sep 17 00:00:00 2001 From: Yves Date: Thu, 20 Feb 2025 22:01:04 +0100 Subject: [PATCH] Update database instance in server first So that even if we throw after loading twice we'll have refreshed the instance --- src/ui_extension.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ui_extension.cpp b/src/ui_extension.cpp index cc6577b..dbfd4b9 100644 --- a/src/ui_extension.cpp +++ b/src/ui_extension.cpp @@ -130,10 +130,14 @@ void InitStorageExtension(duckdb::DatabaseInstance &db) { } static void LoadInternal(DatabaseInstance &instance) { - auto &config = DBConfig::GetConfig(instance); - InitStorageExtension(instance); + // If the server is already running we need to update the database instance + // since the previous one was invalidated (eg. in the shell when we '.open' + // a new database) + ui::HttpServer::UpdateDatabaseInstanceIfRunning(instance.shared_from_this()); + + auto &config = DBConfig::GetConfig(instance); config.AddExtensionOption( UI_LOCAL_PORT_SETTING_NAME, UI_LOCAL_PORT_SETTING_DESCRIPTION, LogicalType::USMALLINT, Value::USMALLINT(UI_LOCAL_PORT_SETTING_DEFAULT)); @@ -155,11 +159,6 @@ static void LoadInternal(DatabaseInstance &instance) { SingleBoolResultBind, RunOnceTableFunctionState::Init); ExtensionUtil::RegisterFunction(instance, tf); } - - // If the server is already running we need to update the database instance - // since the previous one was invalidated (eg. in the shell when we '.open' - // a new database) - ui::HttpServer::UpdateDatabaseInstanceIfRunning(instance.shared_from_this()); } void UiExtension::Load(DuckDB &db) { LoadInternal(*db.instance); }