Skip to content

Commit

Permalink
Merge pull request #9771 from Mytherin/attachfixagain
Browse files Browse the repository at this point in the history
ATTACH - Always run ExtractExtensionPrefix also if a name is provided
  • Loading branch information
Mytherin committed Nov 23, 2023
2 parents cafbcfb + d218797 commit eed7b7b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/execution/operator/schema/physical_attach.cpp
Expand Up @@ -6,6 +6,7 @@
#include "duckdb/main/extension_helper.hpp"
#include "duckdb/parser/parsed_data/attach_info.hpp"
#include "duckdb/storage/storage_extension.hpp"
#include "duckdb/main/database_path_and_type.hpp"

namespace duckdb {

Expand Down Expand Up @@ -66,9 +67,12 @@ SourceResultType PhysicalAttach::GetData(ExecutionContext &context, DataChunk &c
// get the name and path of the database
auto &name = info->name;
auto &path = info->path;
if (db_type.empty()) {
DBPathAndType::ExtractExtensionPrefix(path, db_type);
}
if (name.empty()) {
auto &fs = FileSystem::GetFileSystem(context.client);
name = AttachedDatabase::ExtractDatabaseNameAndType(path, db_type, fs);
name = AttachedDatabase::ExtractDatabaseName(path, fs);
}

// check ATTACH IF NOT EXISTS
Expand Down
1 change: 0 additions & 1 deletion src/include/duckdb/main/attached_database.hpp
Expand Up @@ -62,7 +62,6 @@ class AttachedDatabase : public CatalogEntry {
void SetInitialDatabase();

static string ExtractDatabaseName(const string &dbpath, FileSystem &fs);
static string ExtractDatabaseNameAndType(string &dbpath, string &db_type, FileSystem &fs);

private:
DatabaseInstance &db;
Expand Down
8 changes: 0 additions & 8 deletions src/main/attached_database.cpp
Expand Up @@ -101,14 +101,6 @@ bool AttachedDatabase::IsReadOnly() const {
return type == AttachedDatabaseType::READ_ONLY_DATABASE;
}

string AttachedDatabase::ExtractDatabaseNameAndType(string &dbpath, string &db_type, FileSystem &fs) {
// try to extract database type from path
if (db_type.empty()) {
DBPathAndType::ExtractExtensionPrefix(dbpath, db_type);
}
return AttachedDatabase::ExtractDatabaseName(dbpath, fs);
}

string AttachedDatabase::ExtractDatabaseName(const string &dbpath, FileSystem &fs) {
if (dbpath.empty() || dbpath == IN_MEMORY_PATH) {
return "memory";
Expand Down

0 comments on commit eed7b7b

Please sign in to comment.