| 33 | } |
| 34 | |
| 35 | static void validateEmptyWAL(const std::string& path, ClientContext* context) { |
| 36 | auto vfs = common::VirtualFileSystem::GetUnsafe(*context); |
| 37 | auto walFilePath = storage::StorageUtils::getWALFilePath(path); |
| 38 | if (vfs->fileOrPathExists(walFilePath, context)) { |
| 39 | auto walFile = vfs->openFile(walFilePath, |
| 40 | common::FileOpenFlags(common::FileFlags::READ_ONLY), context); |
| 41 | if (walFile->getFileSize() > 0) { |
| 42 | throw common::RuntimeException(std::format( |
| 43 | "Cannot attach an external Lbug database with non-empty wal file. Try manually " |
| 44 | "checkpointing the external database (i.e., run \"CHECKPOINT;\").")); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | AttachedLbugDatabase::AttachedLbugDatabase(std::string dbPath, std::string dbName, |
| 50 | std::string dbType, ClientContext* clientContext) |
no test coverage detected