1 Commits
Author SHA1 Message Date
lixsp11 104dc21b04 fix(store): use 64-bit file offsets in the SQLite page writer
sqlite_writer.c computed page offsets as (long)(page - 1) * 65536 and
passed them to fseek()/ftell(). long is 32 bits on Windows, so once a
database grows past 2 GiB the offset goes negative and fseek() fails;
the result is ignored, so pages land wherever the stream happens to be.
Past 4 GiB the offset wraps back to small positive values and the
writer overwrites the start of the file. The staging database stops
at exactly 4 GiB, is corrupt, and the run ends in persist_failed.

Route every seek/tell in the writer through 64-bit wrappers
(_fseeki64/_ftelli64 on Windows, fseeko/ftello elsewhere) and compute
offsets with a new cbm_writer_page_offset() helper that widens before
multiplying.

Fixes #2399

Signed-off-by: lixsp11 <30531760+Lixsp11@users.noreply.github.com>
2026-10-13 16:28:45 +09:00