Commit Graph

1493 Commits

Author SHA1 Message Date
Gustavo Sverzut Barbieri
cd2d817c10 github.com/penberg/limbo was moved to github.com/tursodatabase/limbo
Adjust all the references since they were broken
2025-02-08 10:21:49 -03:00
Pekka Enberg
71d2a9b6ab Merge 'Replace hashmap for io_uring pending ops with static array' from Preston Thorpe
Since we are already round robin'ing our `iovecs` in the same way, and
the map will never be larger than MAX_IOVECS, we can remove the cost of
hashing and keep o(1) lookups.

Closes #922
2025-02-08 11:15:54 +02:00
Pekka Enberg
b17610ab77 core/mvcc: Minor code cleanups
Make the source file readable from top to bottom by moving private
functions at the end of the struct implementation.
2025-02-08 10:55:13 +02:00
Jussi Saurio
791255fd8c MVCC: Add a few comments 2025-02-08 10:20:48 +02:00
Jussi Saurio
fab105c10c MVCC: fix write conflict handling 2025-02-08 10:10:09 +02:00
PThorpe92
575a524d04 Replace hashmap for io_uring pending ops with static array 2025-02-07 09:05:08 -05:00
Pekka Enberg
8c0c967ea2 Merge 'Implement json_quote' from Pedro Muniz
Hi! This is my first PR on the project, so I apologize if I did not
follow a convention from the project.
#127
This PR implements json_quote as specified in their source:
https://www.sqlite.org/json1.html#jquote. It follows the internal doc
guidelines for implementing functions. Most tests were added from sqlite
test suite for json_quote, while some others were added by me. Sqlite
test suite for json_quote depends on json_valid to test for correct
escape control characters, so that specific test at the moment cannot be
done the same way.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Reviewed-by: Sonny (@sonhmai)

Closes #763
2025-02-07 13:33:05 +02:00
Pekka Enberg
7169706809 Merge 'Add support for delete row' from Krishna Vishal
**Core delete tasks**:
- [x] Implement free page functionality
- [x] Clear overflow pages if any before deleting their cells using free
page.
- [x] Implement delete for leaf page
- [ ] Balance after delete properly
**Auxiliary tasks to make delete work properly**:
- [x] Implement block coalescing in `free_cell_range` to reduce
fragmentation.
- [x] Track page fragmentation in `free_cell_range`.
- [x] Update page offsets in `drop_cell` and update cell pointer array
after dropping a cell.
- [x] Add TCL tasks
Closes #455
--------
I will add support for balancing after delete once `balance_nonroot` is
extended. In the current state of `balance_nonroot` balancing won't work
after delete and corrupts page.
But delete itself is functional now.

Closes #785
2025-02-07 12:36:23 +02:00
Jussi Saurio
b37745ec14 Merge 'Add quickcheck tests for generate_series() and refine implementation' from Jussi Saurio
Adds `quickcheck` property based tests to the recently merged
`generate_series` implementation and fixes various issues in it:
- `0` for `step` should be treated as `1`
- missing `step` should be treated as `1`
- a string like `a` for `step` should be treated as `1`
- saturating overflow
- return an empty series for a variety of invalid inputs, instead of
erroring
For the future:
We should have e2e/fuzz tests comparing sqlite implementation to limbo
implementation

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #910
2025-02-07 10:40:25 +02:00
Pekka Enberg
7809df913a core/mvcc: Rename Database to MvStore 2025-02-07 07:40:33 +02:00
pedrocarlo
c3cad5dfdd corrected to use newly created as_str function to convert to string slice 2025-02-07 00:07:51 -03:00
pedrocarlo
8fe71309c0 cargo fmt 2025-02-06 23:46:00 -03:00
pedrocarlo
c8bb1fd353 unreachable to agg and record types, as it should not be possible to pass them to json_quote 2025-02-06 23:43:30 -03:00
pedrocarlo
b678375c69 increasing string capacity to reduce allocations 2025-02-06 23:37:30 -03:00
pedrocarlo
90ecaf40b5 removed unnecessary string allocations for escaped json value 2025-02-06 23:37:30 -03:00
pedrocarlo
26388cc802 fix: cargo fmt 2025-02-06 23:36:02 -03:00
pedrocarlo
303a687e65 rebase to main 2025-02-06 23:35:58 -03: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
ea174e32f1 chore: cargo fmt 2025-02-06 23:39:12 +05:30
krishvishal
c80007d8a0 Add local constants for free_page offsets for clarity. 2025-02-06 23:39:12 +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
Jussi Saurio
d5f58f5fea Add quickcheck tests for generate_series() and refine implementation 2025-02-06 18:36:21 +02:00
PThorpe92
ae88d51e6f Remove TableReferenceType enum to clean up planner 2025-02-06 09:15:39 -05:00
PThorpe92
a8ae957162 Add tests for series extension, finish initial vtable impl 2025-02-06 09:15:39 -05:00
PThorpe92
ad30ccdc0e Add docs in extension README for vtable modules 2025-02-06 09:15:39 -05:00
PThorpe92
d4c06545e1 Refactor vtable impl and remove Rc Refcell from module 2025-02-06 09:15:39 -05:00
PThorpe92
661c74e338 Apply new planner structure to virtual table impl 2025-02-06 09:15:28 -05:00
Jussi Saurio
f5f77c0bd1 Initial virtual table implementation 2025-02-06 07:51:50 -05:00
Pekka Enberg
f4a574e6bc core: Move strftime to functions module 2025-02-06 13:53:36 +02:00
Pekka Enberg
ee8eabf167 core: Move datetime to functions module 2025-02-06 13:52:25 +02:00
Pekka Enberg
7513f859df core: Move printf to functions module 2025-02-06 13:50:05 +02:00
Pekka Enberg
238fb9c977 Merge 'Sqlean Crypto extension' from Diego Reis
Introduces a new `crypto` extension, compatible with the Sqlean [crypto
extension](https://github.com/nalgeon/sqlean/blob/main/docs/crypto.md).

Closes #903
2025-02-06 13:46:01 +02:00
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
Pekka Enberg
f9828e0e6f core: Parse UTF-8 strings lazily 2025-02-06 13:27:52 +02:00
Pekka Enberg
c210821100 core: Move result row to ProgramState
Move result row to `ProgramState` to mimic what SQLite does where `Vdbe`
struct has a `pResultRow` member. This makes it easier to deal with result
lifetime, but more importantly, eventually lazily parse values at the edges of
the API.
2025-02-06 11:52:26 +02:00
Pekka Enberg
0012e9d556 cargo fmt 2025-02-06 10:44:37 +02:00
Pekka Enberg
f769d1aa2a s/LimboText/Text/g 2025-02-06 10:44:02 +02:00
Pekka Enberg
2546413d40 Merge 'Move vector into core from extensions' from Krishna Vishal
To make implementation of DiskANN in limbo easier, I'm moving `vector`
from `extensions` to core.
Now `vector` related function are exposed via `Function` op code.
I've defined a new enum called `VectorFunc` to group the vector related
functions.
The `vector.test` TCL test runs fine.
```sql
limbo>   SELECT vector_extract(vector('[]'));
[]
limbo> SELECT vector_extract(vector('  [  1  ,  2  ,  3  ]  '));
[1,2,3]
limbo> SELECT vector_extract(vector('[-1000000000000000000]'));
[-1000000000000000000]
limbo> SELECT vector_distance_cos(vector('[1,2,3]'), vector('[3,2,1]'));
0.2857142686843872
```

Closes #902
2025-02-06 07:41:28 +02:00
Diego Reis
05057a04ac completes crypto extension
It aims to be compatible with https://github.com/nalgeon/sqlean/blob/main/docs/crypto.md
2025-02-06 01:42:47 -03:00
Diego Reis
dd58be3b60 Add basic structure for crypto extension 2025-02-05 23:09:26 -03:00
krishvishal
32080aba5d Make vector function accessible through Function op code. 2025-02-06 07:01:50 +05:30
krishvishal
d516821e27 Add vector to core and make necessary changes to types.rs. 2025-02-06 07:00:51 +05:30