diff --git a/src/common/local_file_system.cpp b/src/common/local_file_system.cpp index db5352f9e75e..c7364d21ffb7 100644 --- a/src/common/local_file_system.cpp +++ b/src/common/local_file_system.cpp @@ -571,19 +571,24 @@ int64_t LocalFileSystem::Write(FileHandle &handle, void *buffer, int64_t nr_byte } bool LocalFileSystem::Trim(FileHandle &handle, idx_t offset_bytes, idx_t length_bytes) { + bool trimmed = false; +#if defined(DUCKDB_RUN_SLOW_VERIFIERS) || defined(DUCKDB_ALTERNATIVE_VERIFY) + std::vector zeros(length_bytes, '\0'); + Write(handle, zeros.data(), length_bytes, offset_bytes); + trimmed = true; +#endif #if defined(__linux__) // FALLOC_FL_PUNCH_HOLE requires glibc 2.18 or up #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 18) - return false; + // Nothing #else int fd = handle.Cast().fd; int res = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, UnsafeNumericCast(offset_bytes), UnsafeNumericCast(length_bytes)); - return res == 0; + trimmed = (res == 0); #endif -#else - return false; #endif + return trimmed; } int64_t LocalFileSystem::GetFileSize(FileHandle &handle) {