mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-24 11:34:21 +01:00
This PR fixes a problem where `sqlite_schema` could be read before page 1 was allocated. The fix is similar to that in SQLite. In SQLite, if `btreeCursor()` sees that the root page is 1 and that the b-tree is empty, it sets the page to 0 ([here](https://github.com/sqlite/sqlite/blob/master/src/btree.c#L4 691-L4696)). SQLite's `moveToRoot()` then uses this special value to return `CURSOR_INVALID` with no rows ([here](https://github.com/sqlite/s qlite/blob/master/src/btree.c#L5538-L5540)). Fixes https://github.com/tursodatabase/turso/issues/2449 Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #2551