Commit Graph

911 Commits

Author SHA1 Message Date
Elijah Morgan
058ca89561 feat add basic opfs support and tests 2025-01-01 10:31:26 -05:00
PThorpe92
ed95007298 Separate exec insns to individual functions 2024-12-31 07:55:40 -05:00
PThorpe92
45eeee1589 Add comment and match case for improperly called values 2024-12-31 07:54:01 -05:00
PThorpe92
d572089b80 Refactor out repetitive agg_func code in vdbe 2024-12-31 07:53:55 -05:00
Pekka Enberg
0aabcddf18 ext/uuid: Convert uuid4() to external function 2024-12-31 13:56:32 +02:00
Pekka Enberg
33dbd6c892 core: External functions 2024-12-31 13:56:32 +02:00
Pekka Enberg
858aecfea2 core: Drop Clone and PartialEq from Func enum
We don't need them anywhere and they make it hard to introduce
GenericFunction.
2024-12-31 13:51:20 +02:00
Pekka Enberg
dca47f62ea core: Don't use Weak reference for connection database
The database object is a way to represent state that's shared across
multiple connections. We don't want to release that object until all
connections are closed.
2024-12-31 13:51:20 +02:00
Pekka Enberg
3046757d09 core/translate: Move prepare_delete_plan() to delete.rs
The planner.rs file is pretty big. Let's make it smaller by moving more
of delete handling to delete.rs.
2024-12-31 11:40:35 +02:00
Pekka Enberg
cb5d86ed8e core/translate: Move prepare_select_plan() to select.rs
The planner.rs file is pretty big. Let's make it smaller by moving more
of select handling to select.rs.
2024-12-31 11:38:13 +02:00
Pekka Enberg
dad3a5b069 core/translate: Move translate_insert() to top
The translate_insert() function is the entry point to translating an
INSERT statement so let's make it the first function in insert.rs.
2024-12-31 11:33:17 +02:00
Pekka Enberg
f6149d3bd7 core/translate: Kill unused lifetimes 2024-12-31 11:33:17 +02:00
Pekka Enberg
f8d408e9a8 Merge 'enable sqpoll by default in io_uring' from Preston Thorpe
EDIT: will continue iterating on these ideas, as discussed on discord.
for now, this has been changed to just enable `IORING_ENABLE_SQPOLL` by
default. This is supported sin `5.11`, and I believe the last debian
release < that reached EOL in July, so shouldn't be an issue.

Closes #557
2024-12-31 10:37:39 +02:00
Pekka Enberg
80e12dfbf7 Merge 'Fixes glob giving wrong results in some cases ' from Vrishabh
Fixes #577
With the previous implementation we weren't escaping the regex meta
characters . And in certain cases glob had a different meaning than
regex.
For e.g , the below shows a glob pattern with its regex equivalent
- `[][]` translates to `[\]\[]`
- `[^][]` translates to `[^\]\[]`

Closes #578
2024-12-31 10:31:49 +02:00
psvri
3ac3fdf0a2 Fix glob 2024-12-30 17:02:31 +05:30
PThorpe92
4e77840ee5 Setup io_uring with sqpoll enabled 2024-12-29 15:34:17 -05:00
Lauri Virtanen
db384c6828 Simplify init of delimiter_exprs
Clippy:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
2024-12-29 19:22:45 +02:00
Lauri Virtanen
10065bda35 Don't use inaccurate pi values, make clippy happy 2024-12-29 19:22:45 +02:00
Lauri Virtanen
55916fdd9d Remove function parameter as it's only used in recursion 2024-12-29 19:22:45 +02:00
Lauri Virtanen
854005b977 Run cargo clippy --fix && cargo fmt 2024-12-29 19:22:28 +02:00
PThorpe92
f6cd707544 Add clippy CI, fix or ignore warnings where appropriate 2024-12-29 10:25:41 -05:00
Pekka Enberg
f87dc7cacc Merge 'Support like function with escape' from Vrishabh
I have added support for like function with escape i.e like(X,Y,Z) .
There is good opportunity to refactor/cleanup the like operations which
can be done in another PR, as I wanted to keep the changes small .

Closes #568
2024-12-29 16:58:06 +02:00
adamnemecek
97647ff056 Clean up code to use Self
Closes #556
2024-12-29 10:07:38 +02:00
psvri
1922b8ea38 Support like function with escape 2024-12-28 13:55:12 +05:30
PThorpe92
ddf229c432 Update COMPAT.md 2024-12-27 15:42:13 -05:00
PThorpe92
f08d62b446 Add Remainder vdbe oppcode 2024-12-27 15:39:02 -05:00
Pekka Enberg
3bc554f27c core: Remove unused import 2024-12-27 18:39:38 +02:00
Pekka Enberg
5b8f00cb8d Merge 'Fixes like function when pattern has regex meta chars' from Vrishabh
Fixes #552
In our construct regex function, we were not escaping the required
characters properly which was causing the failure.
Limbo output with this branch
```
limbo> select like('\%A', '\A');
1
limbo> select like('A$%', 'A$');
1
limbo> select like('%a.a', 'aaaa');
0
```

Closes #553
2024-12-27 18:35:47 +02:00
Pekka Enberg
8352dcd582 Merge 'Fix sqlite_version() out of bound panics' from Diego Reis
#560
Changes to `translate_expr` function:
* [`core/translate/expr.rs`](diffhunk://#diff-
371865d5d7b8bcaed649413c687492e61e94f21387cd9b2c47d989a033888c8bL1558-
R1560): Changed the `amount` parameter in the `Insn::Copy` instruction
from `1` to `0`.
Enhancements to the testing framework:
* [`testing/scalar-functions.test`](diffhunk://#diff-
a046d58ab24eee8207f0ce3199f8d0a609edcef9c24b8ed7f242f7a60e6c1e61R812-
R815): Added a new test `do_execsql_test_regex` to validate that the
`sqlite_version` function returns a valid output.
* [`testing/tester.tcl`](diffhunk://#diff-
316cca92d85df3f78558cc3e60d7420c1fd19a23ecf2bbea534db93ab08ea3ecR29-
R45): Introduced a new procedure `do_execsql_test_regex` to support
regex-based validation of SQL outputs.

Closes #561
2024-12-27 18:34:47 +02:00
Diego Reis
2d0c16c428 Fix sqlite_version() out of bound 2024-12-27 11:39:33 -03:00
김선우
ad2d515ffd Merge branch 'main' into feature/delete-planning 2024-12-27 23:21:35 +09:00
Pekka Enberg
b2f96ddfbd core/translate: Remove unnecessary mut 2024-12-27 10:55:31 +02:00
Pekka Enberg
9680471876 core: Remove unreachable pragma patterns 2024-12-27 10:55:31 +02:00
Pekka Enberg
464508bb29 core/vdbe: Kill unused next_free_register() 2024-12-27 10:55:31 +02:00
Pekka Enberg
244326ee57 core: Remove unused imports 2024-12-27 10:55:31 +02:00
Pekka Enberg
f2ecebc357 Rename RowResult to StepResult
The name "row result" is confusing because it really *is* a result from
a step() call. The only difference is how a row is represented as we
return from VDBE or from a statement.

Therefore, rename RowResult to StepResult.
2024-12-27 10:20:41 +02:00
Pekka Enberg
db0c59413b Merge 'Implement json_array_length' from Peter Sooley
In line with [other work](#127) for JSON support, this PR adds support
for [`json_array_length`](https://www.sqlite.org/json1.html#jarraylen).
This includes a first pass at supporting the JSON path for accessing
values within the JSON.
I've added tests in rust and tcl.
![image](https://github.com/user-
attachments/assets/0d0e3319-317b-4783-bff4-241eb2902255)

Closes #555
2024-12-27 10:08:22 +02: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
Pekka Enberg
937779b8c0 Merge 'core/btree: small refactoring + documentation tweaks' from Jussi Saurio
small follow up to https://github.com/tursodatabase/limbo/pull/539
contains:
- Variable renaming and comments to `btreecursor.insert_into_cell()`
- New utility methods `pagecontent.header_size()`,
`pagecontent.cell_pointer_array_size()`,
`pagecontent.unallocated_region_start()` and
`pagecontent.unallocated_region_size()`
- Refactor of `btreecursor.compute_free_space()` (plus comments and
variable renaming)
- Rename `pagecontent.cell_get_raw_pointer_region()` to
`pagecontent.cell_pointer_array_offset_and_size()` and remove its usage
in `btreecursor.defragment_page()`

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #543
2024-12-27 10:06:30 +02:00
Peter Sooley
28244b10d6 implement json_array_length 2024-12-26 15:08:11 -08:00
psvri
12e49da1d0 fmt fixes 2024-12-26 22:42:46 +05:30
psvri
4368e8767b Fix like function giving wrong results 2024-12-26 22:38:54 +05:30
jussisaurio
c7448d2917 no allocation for serial types 2024-12-26 12:23:53 +02:00
jussisaurio
80933a32e9 remove space allocated for overflow pointer in non-overflow cases 2024-12-25 23:09:23 +02:00
jussisaurio
381335724a add tests for serialize() 2024-12-25 22:57:55 +02:00
jussisaurio
6bf1ab7726 add consts for integer lo/hi values and serial types 2024-12-25 22:34:34 +02:00
jussisaurio
78da71c72a encode integers with proper varint types 2024-12-25 22:08:11 +02:00
jussisaurio
c4e2a344ae parse error instead of assert! for unsupported features 2024-12-25 21:14:58 +02:00
jussisaurio
050b8744ea Dont use coroutine when inserting a single row 2024-12-25 21:14:58 +02:00
jussisaurio
c78a3e952a clean up implementation 2024-12-25 21:14:58 +02:00