Files
turso/core
Jussi Saurio 27b3ecf599 core/db&pager: fix locking for initializing empty database
When `struct Database` is constructed, store `is_empty` as an
`Arc<AtomicBool>` - the value is true if:

1. DB size is zero
2. WAL has no frames

When `struct Pager` is constructed, this `Arc` is simply cloned.
When any connection runs a transaction it will first check `is_empty`,
and if the DB is empty, it will lock `init_lock` and then check `is_empty`
again, and if it's still true, it allocates page1 and stores `false` in
the `is_empty` `AtomicBool` and drops the lock.

---

Note that Limbo can currently have a zero DB and a WAL with frames,
as we have no special logic for folding page1 to the main DB file
during initialization.

Page 1 allocation currently happens on the first transaction (read or
write, due to having to support `select * from sqlite_schema` on an
empty DB; we should really check how SQLite actually does this.).
2025-06-25 14:45:21 +03:00
..
2025-06-23 19:52:13 +01:00
2025-06-23 19:52:13 +01:00
2025-06-23 19:52:13 +01:00
2025-06-23 19:52:13 +01:00
2025-06-23 19:52:13 +01:00
2025-06-23 19:52:13 +01:00
2025-06-23 19:52:13 +01:00
2025-01-28 14:55:38 -05:00
2025-06-23 19:52:13 +01:00
2025-06-11 14:19:06 -03:00
2025-01-28 14:55:38 -05:00
2025-06-23 19:52:13 +01:00
2024-12-24 18:04:30 +01:00
2025-06-23 19:52:13 +01:00
2025-06-23 19:52:13 +01:00
2025-06-23 19:52:13 +01:00
2025-06-23 19:52:13 +01:00