Commit Graph

614 Commits

Author SHA1 Message Date
Nikita Sivukhin
5ce3d12f75 fix typo 2025-02-09 17:31:39 +04:00
Nikita Sivukhin
3557c8aada adjust fuzz test 2025-02-09 17:31:39 +04:00
PThorpe92
75898027a0 Remove unnecessary reference counting from completion io callbacks 2025-02-08 08:20:19 -05:00
Nikita Sivukhin
75e2f01ec4 print btree for debugging 2025-02-08 13:03:38 +04:00
Nikita Sivukhin
55dd108878 setup simple insertion fuzz test 2025-02-08 12:38:32 +04:00
Krishna Vishal
7cb7eb4e65 Merge branch 'main' into delete-btree-row 2025-02-07 01:15:21 +05:30
krishvishal
349fd51559 Get db_header from Pager instead of BTreeCursor.
Fix page_cache in btree tests to use `parking_lot::RwLock`
2025-02-07 00:11:06 +05:30
krishvishal
f836ad7561 Remove write to PAGE_HEADER_OFFSET_CELL_CONTENT_AREA in insert_into_cell. This causes corruption when you reuse cell spaces from free_list. 2025-02-06 23:39:12 +05:30
krishvishal
7d67895306 1. Added frangmentation handling to find_free_cell
2. Added asserts and corruption error to `allocate_cell_space`
2025-02-06 23:39:09 +05:30
krishvishal
8263bd0482 Update page offsets in drop_cell and update cell pointer array after dropping a cell. 2025-02-06 23:36:27 +05:30
krishvishal
73dae3003d Implement block coalescing in free_cell_range to reduce fragmentation and also added fragmentation tracking. 2025-02-06 23:36:26 +05:30
krishvishal
95da2244bb Implemented delete(). Now we are able to delete a row. It handles both interior page and leaf page cell differently. 2025-02-06 23:34:27 +05:30
krishvishal
f62ec61694 Added a unit-test to test the case where clear_overflow_pages function is called on cell with no overflow pages 2025-02-06 23:34:26 +05:30
krishvishal
8c763780a8 Added free list and free_page functionality in Pager module. Now we can add dropped pages to free list, so pages can be reused in allocate_page. 2025-02-06 23:34:12 +05:30
krishvishal
83b214a4e3 Added clear_over_pages it deletes all the overflow pages related to a cell. 2025-02-06 23:27:07 +05:30
Pekka Enberg
f3902ef9b6 core: Rename OwnedRecord to Record
We only have one record type so let's call it `Record`.
2025-02-06 13:40:34 +02:00
Alex Miller
9ac52b66d9 Refactor cursor to support multiple state machines 2025-01-30 14:08:44 -08:00
Pekka Enberg
983875c443 core: Remove database header from BTreeCursor
It's already in the pager so use it from there to reduce the size of the
`BTreeCursor` struct.
2025-01-26 16:48:12 +02:00
Jorge López
218a2e6dda syntactic changes: remove unneeded mut, lifetimes,references that get instantaneously dereferenced and casts 2025-01-18 18:43:47 +01:00
Jorge López
2cc8cb9ad8 syntactic changes: use assert_eq!() instead of assert!() for equality comparisons 2025-01-18 18:37:50 +01:00
Jorge López
f160206cdd syntactic changes: replace unwrap() with ? in functions that return Result<...> 2025-01-18 18:33:43 +01:00
Jorge López
86a4714711 syntactic changes: remove unneeded paths when the type is already imported 2025-01-18 18:29:12 +01:00
Jussi Saurio
bf48c0ae72 Remove trait Cursor 2025-01-11 17:19:25 +02:00
Pere Diaz Bou
6802bb7e6a distinguish balance and balance_non_root
`balance_non_root` should be as close as possible to `balance_non_root`
in SQLite. This commits extract `balance_non_root` from `balance` and
renames `balance_leaf` to `balance` as it enables future work on a
complete `balance_non_root` procedure.
2025-01-08 19:05:49 +01:00
Kould
a33984087f chore: add comment on BTreeCursor::seek 2025-01-02 18:18:17 +08:00
Kould
e5d0ad044e fix: index seek wrong 2025-01-02 11:11:44 +08:00
Lauri Virtanen
854005b977 Run cargo clippy --fix && cargo fmt 2024-12-29 19:22:28 +02:00
김선우
ad2d515ffd Merge branch 'main' into feature/delete-planning 2024-12-27 23:21:35 +09:00
Pekka Enberg
5065074617 Merge 'core: disk serialization changes to align with sqlite' from Jussi 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 <pere-altea@homail.com>

Closes #550
2024-12-27 10:06:52 +02:00
jussisaurio
80933a32e9 remove space allocated for overflow pointer in non-overflow cases 2024-12-25 23:09:23 +02:00
jussisaurio
42ea9041e1 rename cell_get_raw_pointer_region() and refactor a bit 2024-12-24 19:27:01 +02:00
jussisaurio
25338b5cb4 refactor compute_free_space() 2024-12-24 19:00:22 +02:00
jussisaurio
c6b7ddf77a Improve comments in BTreeCursor::compute_free_space() 2024-12-24 10:30:27 +02:00
jussisaurio
91cca0d5b7 use more descriptive names in BTreeCursor::insert_into_cell() 2024-12-24 10:28:53 +02:00
jussisaurio
9ea4c95ee1 even more comments 2024-12-23 22:07:20 +02:00
jussisaurio
6a287ae1a9 add comment about cell_content_area 0 value meaning u16::MAX 2024-12-23 21:33:57 +02:00
jussisaurio
40a0bef0dc better fixme comments 2024-12-23 21:19:18 +02:00
jussisaurio
c417fe7880 add link to sqlite source about payload_overflows() 2024-12-23 21:14:20 +02:00
jussisaurio
b57a95752c core/btree: improve documentation 2024-12-22 23:05:25 +02:00
김선우
9bacf80f2e Change to println! 2024-12-22 14:41:12 +09:00
김선우
a42b185ece Nit 2024-12-22 14:22:10 +09:00
김선우
9a8b94ef93 First successful implementation of delete planning 2024-12-22 13:16:16 +09:00
Ikko Eltociear Ashimine
043fba2632 core: update btree.rs
postion -> position
2024-12-15 03:31:46 +09:00
Pere Diaz Bou
97dd95abea core: change Rc<RefCell<Page>> to Arc<Page>
This includes an inner struct in Page wrapped with Unsafe cell to access
it. This is done intentionally because concurrency control of pages is
handled by pages and not by the page itself.
2024-12-13 13:09:13 +01:00
krishvishal
7e2928a5f1 Feature: last_insert_rowid()
- Changed `Cursor` trait to be able to get access to `root_page`
- SQLite only updates last_insert_rowid for non-schema inserts. So we check if the `InsertAwait` is not for `root_page` before
  updating rowid
2024-12-09 22:48:42 +05:30
Lauri Virtanen
afeb1cbe74 Clippy warning fixes 2024-11-24 20:24:47 +02:00
Lauri Virtanen
a7100d8e9b Autofix clippy issues with cargo fix --clippy 2024-11-24 20:24:47 +02:00
jussisaurio
f945795ae6 consistent naming 2024-11-21 20:25:51 +02:00
jussisaurio
d8eb4be424 better, less cool names 2024-11-21 20:23:53 +02:00
jussisaurio
3002f2a552 io macro 2024-11-21 20:23:23 +02:00