|
1 | 1 | diff --git a/src/storage/storage_manager.cpp b/src/storage/storage_manager.cpp |
2 | | -index cb6c654e5f..a6b2af3b85 100644 |
| 2 | +index 45d42174f1..10b3ce47b1 100644 |
3 | 3 | --- a/src/storage/storage_manager.cpp |
4 | 4 | +++ b/src/storage/storage_manager.cpp |
5 | | -@@ -160,9 +160,12 @@ void SingleFileStorageManager::LoadDatabase(StorageOptions storage_options) { |
| 5 | +@@ -162,9 +162,15 @@ void SingleFileStorageManager::LoadDatabase(StorageOptions storage_options) { |
6 | 6 | row_group_size, STANDARD_VECTOR_SIZE); |
7 | 7 | } |
8 | 8 | } |
9 | 9 | - // Check if the database file already exists. |
10 | 10 | - // Note: a file can also exist if there was a ROLLBACK on a previous transaction creating that file. |
11 | 11 | - if (!read_only && !fs.FileExists(path)) { |
12 | | -+ auto db_file_handle = fs.OpenFile(path, FileFlags::FILE_FLAGS_READ | FileFlags::FILE_FLAGS_NULL_IF_NOT_EXISTS); |
13 | | -+ bool is_empty_file = db_file_handle->GetFileSize() == 0; |
14 | | -+ db_file_handle.reset(); |
| 12 | ++ bool is_empty_file = true; |
| 13 | ++ auto db_file_handle = fs.OpenFile(path, FileFlags::FILE_FLAGS_READ | FileFlags::FILE_FLAGS_NULL_IF_NOT_EXISTS); |
| 14 | ++ if (db_file_handle && db_file_handle->GetFileSize() != 0) { |
| 15 | ++ is_empty_file = false; |
| 16 | ++ db_file_handle.reset(); |
| 17 | ++ } |
15 | 18 | + |
16 | | -+ // first check if the database exists |
17 | | -+ if (!read_only && ( !fs.FileExists(path) || ( options.use_direct_io && is_empty_file )) ) { |
| 19 | ++ // first check if the database exists |
| 20 | ++ if (!read_only && (!fs.FileExists(path) || (options.use_direct_io && is_empty_file))) { |
18 | 21 | // file does not exist and we are in read-write mode |
19 | 22 | // create a new file |
20 | 23 |
|
0 commit comments