Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating two tables sometimes corrupts database #532

Open
jussisaurio opened this issue Dec 21, 2024 · 0 comments
Open

creating two tables sometimes corrupts database #532

jussisaurio opened this issue Dec 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jussisaurio
Copy link
Collaborator

limbo> create table a (b integer primary key);
limbo> create table b (c integer primary key); <-- doesn't seem to matter what this is
SQLite version 3.46.0 2024-05-23 13:25:27
Enter ".help" for usage hints.
sqlite> select * from a;
Parse error: malformed database schema (b) - invalid rootpage (11)

doesn't happen every time

@jussisaurio jussisaurio added the bug Something isn't working label Dec 21, 2024
penberg added a commit that referenced this issue Dec 27, 2024
…ssi Saurio

This PR's genesis is from investigating #532, but I still can't reliably
reproduce it on either `main` or this branch so I don't know if this PR
_fixes_ anything, but I guess it aligns us more with sqlite anyway
---
Anyway: I looked at DBs created with limbo and with sqlite using
[ImHex](https://github.com/WerWolv/ImHex) and the differences seem to
be:
1. SQLite uses varint according to [the
spec](https://www.sqlite.org/fileformat.html#record_format), whereas
limbo always encodes integers as i64
2. Limbo adds 4 bytes of zeros for overflow page pointer (even in cases
where the cell doesnt overflow)
3. Limbo adds a space after `CREATE TABLE name` before the `(` even when
user doesn't specify it?
I implemented the following:
- Fix 1: Varint serialization of i8, i16, i24, i32, i48 and i64
according to payload, instead of always using i64
- Fix 2: Removed the 4 bytes reserved for overflow page pointer in non-
overflow cases

Reviewed-by: Pere Diaz Bou <[email protected]>

Closes #550
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant