From e16d3b2fb2cf839cca8235653c0e6e0a332199d1 Mon Sep 17 00:00:00 2001 From: Krystie Date: Sun, 28 Jun 2026 14:02:28 -0700 Subject: [PATCH] fix: column-family RocksDB::Open uses SFINAE wrapper (DB** vs unique_ptr*) The CF Open overload had the same DB** vs unique_ptr* API drift as the non-CF version, but was calling rocksdb::DB::Open directly instead of through the SFINAE wrapper. On MSYS2 MinGW (Windows CI) the unique_ptr-only overload causes a compile error. Added OpenRocksDBCF with the same int/long SFINAE pattern. --- src/txdb-rocksdb.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/txdb-rocksdb.cpp b/src/txdb-rocksdb.cpp index 660936c..a13de40 100644 --- a/src/txdb-rocksdb.cpp +++ b/src/txdb-rocksdb.cpp @@ -75,6 +75,39 @@ inline rocksdb::Status OpenRocksDB(const rocksdb::Options& opts, return OpenRocksDBImpl(opts, path, dbptr, 0); } +// Same SFINAE pattern for the column-family Open overload. +// Some RocksDB versions (MSYS2 MinGW) ship only the unique_ptr signature. +template +inline auto OpenRocksDBCFImpl(const rocksdb::Options& opts, const std::string& path, + const std::vector& cfDescs, + std::vector* handles, + T** dbptr, int) + -> decltype(rocksdb::DB::Open(opts, path, cfDescs, handles, dbptr)) +{ + return rocksdb::DB::Open(opts, path, cfDescs, handles, dbptr); +} + +template +inline rocksdb::Status OpenRocksDBCFImpl(const rocksdb::Options& opts, const std::string& path, + const std::vector& cfDescs, + std::vector* handles, + T** dbptr, long) +{ + std::unique_ptr tmp; + auto s = rocksdb::DB::Open(opts, path, cfDescs, handles, &tmp); + if (s.ok()) *dbptr = tmp.release(); + return s; +} + +inline rocksdb::Status OpenRocksDBCF(const rocksdb::Options& opts, + const std::string& path, + const std::vector& cfDescs, + std::vector* handles, + rocksdb::DB** dbptr) +{ + return OpenRocksDBCFImpl(opts, path, cfDescs, handles, dbptr, 0); +} + } // anonymous namespace static rocksdb::Options GetRocksOptions() @@ -157,7 +190,7 @@ static void open_rocksdb(rocksdb::Options& options, bool fRemoveOld = false) } std::vector handles; - rocksdb::Status status = rocksdb::DB::Open(options, directory.string(), + rocksdb::Status status = OpenRocksDBCF(options, directory.string(), cfDescs, &handles, &g_rocksdb); if (!status.ok()) { // Fallback: open without CFs (old-style single-CF database)