diff --git a/src/duckdb/src/common/path.cpp b/src/duckdb/src/common/path.cpp index fdebd11a1..ed2a82bd6 100644 --- a/src/duckdb/src/common/path.cpp +++ b/src/duckdb/src/common/path.cpp @@ -355,4 +355,20 @@ size_t Path::ParseUNCScheme(const string &input, Path &parsed) { } #endif +string Path::AddSuffixToPath(const string &path, const string &suffix) { + // we append the ".wal" **before** a question mark in case of GET parameters + // but only if we are not in a windows long path (which starts with \\?\) + std::size_t question_mark_pos = std::string::npos; + if (!StringUtil::StartsWith(path, "\\\\?\\")) { + question_mark_pos = path.find('?'); + } + auto result = path; + if (question_mark_pos != std::string::npos) { + result.insert(question_mark_pos, suffix); + } else { + result += suffix; + } + return result; +} + } // namespace duckdb diff --git a/src/duckdb/src/function/table/version/pragma_version.cpp b/src/duckdb/src/function/table/version/pragma_version.cpp index d5423e33b..9849ff087 100644 --- a/src/duckdb/src/function/table/version/pragma_version.cpp +++ b/src/duckdb/src/function/table/version/pragma_version.cpp @@ -1,5 +1,5 @@ #ifndef DUCKDB_PATCH_VERSION -#define DUCKDB_PATCH_VERSION "1-dev399" +#define DUCKDB_PATCH_VERSION "1-dev401" #endif #ifndef DUCKDB_MINOR_VERSION #define DUCKDB_MINOR_VERSION 5 @@ -8,10 +8,10 @@ #define DUCKDB_MAJOR_VERSION 1 #endif #ifndef DUCKDB_VERSION -#define DUCKDB_VERSION "v1.5.1-dev399" +#define DUCKDB_VERSION "v1.5.1-dev401" #endif #ifndef DUCKDB_SOURCE_ID -#define DUCKDB_SOURCE_ID "222ea44eb4" +#define DUCKDB_SOURCE_ID "710adf3d05" #endif #include "duckdb/function/table/system_functions.hpp" #include "duckdb/main/database.hpp" diff --git a/src/duckdb/src/include/duckdb/common/path.hpp b/src/duckdb/src/include/duckdb/common/path.hpp index 8756b66cf..8191f6b97 100644 --- a/src/duckdb/src/include/duckdb/common/path.hpp +++ b/src/duckdb/src/include/duckdb/common/path.hpp @@ -135,6 +135,8 @@ class Path { return FromString(input).ToString(); } + static string AddSuffixToPath(const string &path, const string &suffix); + private: string scheme; string authority; diff --git a/src/duckdb/src/main/config.cpp b/src/duckdb/src/main/config.cpp index 3d988be58..3f27c726a 100644 --- a/src/duckdb/src/main/config.cpp +++ b/src/duckdb/src/main/config.cpp @@ -11,6 +11,7 @@ #include "duckdb/storage/storage_extension.hpp" #include "duckdb/common/serializer/serializer.hpp" #include "duckdb/common/exception/parser_exception.hpp" +#include "duckdb/common/path.hpp" #ifndef DUCKDB_NO_THREADS #include "duckdb/common/thread.hpp" @@ -547,10 +548,8 @@ void DBConfig::SetDefaultTempDirectory() { options.temporary_directory = string(); } else if (DBConfig::IsInMemoryDatabase(options.database_path.c_str())) { options.temporary_directory = ".tmp"; - } else if (StringUtil::Contains(options.database_path, "?")) { - options.temporary_directory = StringUtil::Split(options.database_path, "?")[0] + ".tmp"; } else { - options.temporary_directory = options.database_path + ".tmp"; + options.temporary_directory = Path::AddSuffixToPath(options.database_path, ".tmp"); } } diff --git a/src/duckdb/src/storage/storage_manager.cpp b/src/duckdb/src/storage/storage_manager.cpp index ea179bc1a..6ea32cb90 100644 --- a/src/duckdb/src/storage/storage_manager.cpp +++ b/src/duckdb/src/storage/storage_manager.cpp @@ -19,6 +19,7 @@ #include "duckdb/catalog/catalog_entry/duck_table_entry.hpp" #include "duckdb/transaction/duck_transaction_manager.hpp" #include "mbedtls_wrapper.hpp" +#include "duckdb/common/path.hpp" namespace duckdb { using SHA256State = duckdb_mbedtls::MbedTlsWrapper::SHA256State; @@ -285,19 +286,7 @@ unique_ptr> StorageManager::GetWALLock() { } string StorageManager::GetWALPath(const string &suffix) { - // we append the ".wal" **before** a question mark in case of GET parameters - // but only if we are not in a windows long path (which starts with \\?\) - std::size_t question_mark_pos = std::string::npos; - if (!StringUtil::StartsWith(path, "\\\\?\\")) { - question_mark_pos = path.find('?'); - } - auto result = path; - if (question_mark_pos != std::string::npos) { - result.insert(question_mark_pos, suffix); - } else { - result += suffix; - } - return result; + return Path::AddSuffixToPath(path, suffix); } string StorageManager::GetCheckpointWALPath() {