Commit Graph

1065 Commits

Author SHA1 Message Date
psvri
3e9f3ae652 Fix all args not being passed to external functions 2025-01-16 23:15:01 +05:30
Pekka Enberg
20ea8fb941 Make Clippy happy 2025-01-16 15:57:08 +02:00
Pekka Enberg
41b8228744 Merge 'Enable all features and targets in clippy for CI' from Jorge Hermo
I think we should run clippy in CI with all the features and targets
enabled.
This would help to get more clippy coverage as with the current CI
command, some code paths were not covered by clippy. For example, `test`
modules were not covered by it as we need at least the `--tests` flag
(or `--all-targets`)

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

Closes #707
2025-01-16 15:10:11 +02:00
Pekka Enberg
9209641a07 cargo fmt 2025-01-16 14:43:23 +02:00
Pekka Enberg
93903555aa Rename limbo_extension crate to limbo_ext 2025-01-16 14:40:52 +02:00
Pekka Enberg
f83b34287e Move limbo_extension crate to extensions/core 2025-01-16 14:39:12 +02:00
Jorge Hermo
15f7928551 chore: enable all features in clippy ci and fix more clippy lints 2025-01-15 23:23:12 +01:00
Levy A.
9b8722f38e refactor: more well rounded implementation
`?0` parameters are now handled by the parser.
2025-01-15 16:53:26 -03:00
Levy A.
5de2694834 feat: more parameter support
add `Statement::{parameter_index, parameter_name, parameter_count,
bind_at}`. some refactoring is still needed, this is quite a rough
iteration
2025-01-15 16:51:04 -03:00
Levy A.
d3582a382f fix: small bugs 2025-01-15 16:51:04 -03:00
Levy A.
6e0ce3dd01 chore: cargo fmt 2025-01-15 16:51:04 -03:00
Levy A.
08c8c655e9 feat: initial implementation of Statement::bind 2025-01-15 16:51:04 -03:00
psvri
845de125db Align MustBeInt logic with sqlite 2025-01-16 00:09:45 +05:30
Pekka Enberg
bdc06f2d66 Merge 'Implement ShiftRight' from Vrishabh
This PR adds support for ShiftRight operator and Opcode.

Closes #703
2025-01-15 18:53:23 +02:00
Pekka Enberg
c01c80baee Merge 'Run all statements from sql argument in cli' from Vrishabh
When we had multiple sql statements in cli/interactive shell, we were
only running one from them as  shown below. This PR fixes them.
One added benefit of this is we can add complex sql in the tcl test
files like the changes in insert.test .
sqlite3 output
```
❯ sqlite3  :memory: "select 1;select 2"
1
2
```
Limbo main branch output
```
❯ ./target/debug/limbo.exe :memory: "select 1;select 2;"
1
```
Limbos output with this PR
```
❯ ./target/debug/limbo.exe :memory: "select 1;select 2;"
1
2
```

Reviewed-by: Preston Thorpe <cory.pride83@gmail.com>

Closes #673
2025-01-15 18:44:17 +02:00
Pekka Enberg
7c549bc978 Merge 'Expr: fix recursive binary operation logic' from Jussi Saurio
I believe this closes #682
```
limbo> CREATE TABLE proficient_barrett (imaginative_etrebilal BLOB,lovely_wilson BLOB);
INSERT INTO proficient_barrett VALUES (X'656E67726F7373696E675F636861636F', X'776F6E64726F75735F626F75726E65');
limbo> SELECT * FROM proficient_barrett
WHERE (
    (
        (
            (
                imaginative_etrebilal != X'6661766F7261626C655F636F726573'
                OR
                (imaginative_etrebilal > X'656E67726F7373696E675F6368616439')
            )
            AND
            (
                imaginative_etrebilal = X'656E676167696E675F6E6163696F6E616C'
                OR
                TRUE
            )
        )
        OR
        FALSE
    )
    AND
    (
        imaginative_etrebilal > X'656E67726F7373696E675F63686164F6'
        OR
        TRUE
    )
);
engrossing_chaco|wondrous_bourne
```
@PThorpe92 I don't think we need the `parent_op` machinery at all, we
just need to not jump to the `jump_target_when_true` label given by the
parent if we are evaluating the first condition of an AND.
related: https://github.com/tursodatabase/limbo/pull/633

Reviewed-by: Preston Thorpe <cory.pride83@gmail.com>

Closes #698
2025-01-15 18:32:59 +02:00
psvri
d3f28c51f4 Implement ShiftRight 2025-01-15 21:21:51 +05:30
psvri
5b4d82abbf Implement ShiftLeft 2025-01-15 18:54:07 +05:30
psvri
9cc9577c91 Run all statements from sql argument in cli 2025-01-15 18:19:39 +05:30
Jussi Saurio
84ef8a8951 translate_condition_expr(): unify how the AND and OR cases look 2025-01-15 14:24:40 +02:00
Jussi Saurio
f8b3b06163 Expr: fix recursive binary operation logic 2025-01-15 14:12:08 +02:00
Pekka Enberg
ca2333d0c4 Merge 'Add load_extension function, resolve shared lib extensions' from Preston Thorpe
This PR adds the `load_extension` function, and allows for platform
agnostic arguments: e.g. `select
load_extension('target/debug/liblimbo_uuid');` omitting the file
extension.

Closes #680
2025-01-15 09:14:34 +02:00
Pekka Enberg
256c0d4604 Merge 'Add support for rowid keyword' from Kould
https://github.com/tursodatabase/limbo/issues/241
support keyword `rowid`
check if rowid exists when creating table
```shell
explain SELECT rowid FROM users WHERE rowid = 1;

addr  opcode             p1    p2    p3    p4             p5  comment
----  -----------------  ----  ----  ----  -------------  --  -------
0     Init               0     12    0                    0   Start at 12
1     OpenReadAsync      0     2     0                    0   table=users, root=2
2     OpenReadAwait      0     0     0                    0
3     RewindAsync        0     0     0                    0
4     RewindAwait        0     11    0                    0   Rewind table users
5       RowId            0     2     0                    0   r[2]=users.rowid
6       Ne               2     3     9                    0   if r[2]!=r[3] goto 9
7       RowId            0     1     0                    0   r[1]=users.rowid
8       ResultRow        1     1     0                    0   output=r[1]
9     NextAsync          0     0     0                    0
10    NextAwait          0     5     0                    0
11    Halt               0     0     0                    0
12    Transaction        0     0     0                    0
13    Integer            1     3     0                    0   r[3]=1
14    Goto               0     1     0                    0
```

Closes #596
2025-01-14 21:10:20 +02:00
PThorpe92
23d9d09b70 Add load_extension function, resolve shared lib extensions 2025-01-14 12:01:07 -05:00
Pekka Enberg
d355ce785c core/storage: Remove debug printout 2025-01-14 17:54:17 +02:00
Kould
1bf651bd37 chore: rollback using rowid(sqlite3 unsupported) 2025-01-14 22:56:49 +08:00
Kould
5305a9d0fd feat: support keyword rowid 2025-01-14 22:41:40 +08:00
Jussi Saurio
fcfee24c50 Remove mark_last_insn_constant() from places where it is not safe to do so 2025-01-14 16:06:49 +02:00
PThorpe92
9c208dc866 Add tests for first extension 2025-01-14 07:27:35 -05:00
PThorpe92
e4ce6402eb Remove previous uuid implementation 2025-01-14 07:20:50 -05:00
PThorpe92
3099e5c9ba Improve api, standardize conversions between types, finish extension 2025-01-14 07:20:50 -05:00
PThorpe92
6e05258d36 Add safety comments and clean up extension types 2025-01-14 07:20:50 -05:00
PThorpe92
98eff6cf7a Enable passing arguments to external functions 2025-01-14 07:20:50 -05:00
PThorpe92
c565fba195 Adjust types in extension API 2025-01-14 07:20:49 -05:00
PThorpe92
3412a3d4c2 Rough design for extension api/draft extension 2025-01-14 07:20:48 -05:00
PThorpe92
0a10d893d9 Sketch out runtime extension loading 2025-01-14 07:18:07 -05:00
Pekka Enberg
537aea590f Merge 'Clean up license management ' from Kim Seon Woo
## Purpose of this PR
- Set up on how to manage licenses in limbo project
## Changes
- Move all licenses under `licenses` directory in the root path
- Add `NOTICE.md`
- Update `CONTRIBUTING.md` to explain how to add licenses to project
## Reference
https://github.com/tursodatabase/limbo/issues/615

Closes #677
2025-01-14 14:15:53 +02:00
김선우
8ed2d14ca4 Reposition licenses in core package 2025-01-14 19:42:09 +09:00
Jorge López
a16282ea62 core: remove nix as a dependency 2025-01-14 11:06:13 +01:00
Jorge López
55e06b0c72 core/io: make file locks non-blocking so they fail right away 2025-01-14 11:01:11 +01:00
Jussi Saurio
d3c2868fcb Merge 'refactor: json functions vdbe code should be consistent with scalar functions' from Jorge Hermo
While working to include new json functions (related to #127) I noticed
that the program step code for json functions https://github.com/tursoda
tabase/limbo/blob/0dceb02ec04241b3772332853bcbfb9eb559adb9/core/vdbe/mod
.rs#L1346 was a bit different from scalar functions's code, where the
match to the inner function is nested https://github.com/tursodatabase/l
imbo/blob/0dceb02ec04241b3772332853bcbfb9eb559adb9/core/vdbe/mod.rs#L142
4
I added the same nesting to the json functions so it is more consistent

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #663
2025-01-14 10:30:33 +02:00
Pekka Enberg
5c9505e8f7 Revert "core/io/io_uring: replace nix and libc calls with their rustix counterparts."
This reverts commit b146f5d4cb because it
causes tests to hang.
2025-01-14 10:25:23 +02:00
Pekka Enberg
d223c72d03 Revert "core: Previous commits didn't actually remove nix as dependency, so do that here"
This reverts commit cca3846f95, we need to
bring it back unfortunately.
2025-01-14 10:25:11 +02:00
Pekka Enberg
945a91dee5 Merge 'core: Consolidate libc implementations' from Jorge López Tello
This shaves off `nix` as a dependency in core, which was only being used
in the io_uring backend for the `fcntl` advisory record locking. Since a
previous PR made `rustix` a dep not only for Mac but for any Unix, and
`rustix` also has `fcntl`, `nix` becomes redundant.
Furthermore, it reduces `libc` usage across core. The only remaining
uses are:
```rust
io_uring::opcode::Readv::new(fd, iovec as *const iovec as *const libc::iovec, 1)
io_uring::opcode::Writev::new(fd, iovec as *const iovec as *const libc::iovec, 1)
```
These two are a little ugly, but sadly the `io_uring` crate requires
both opcodes to take a `libc::iovec` while it doesn't export the type.
See tokio-rs/io-uring#259 for a request to use `std::io::IoSlice` or to
export the type directly.
Apart from those two, there are no other usages of libc, so if those are
resolved, we could also drop the dependency on libc.

Closes #668
2025-01-14 10:07:20 +02:00
Pekka Enberg
f1b6003d2a Merge 'Fix the rest of the flaky datetime tests' from Preston Thorpe
seeing #660 made me realize I shouldn't have used `now` in any
circumstances in these tests, tolerance or not ;)
they should all be deterministic now

Closes #671
2025-01-14 09:18:17 +02:00
PThorpe92
abb3fda19f Fix all the flaky datetime tests 2025-01-13 19:51:34 -05:00
Levy A.
2f2c96fa2c chore: cargo fmt 2025-01-13 21:31:33 -03:00
Levy A.
eff5de50c5 refactor: make translate_* functions accept ProgramBuilder
simplifies function signatures and allows attaching more context to
ProgramStatus on `translate::translate`, useful for query parameters.
2025-01-13 20:41:56 -03:00
Jorge Hermo
df3123e128 Merge with main 2025-01-13 22:20:17 +01:00
Jorge López
cca3846f95 core: Previous commits didn't actually remove nix as dependency, so do that here 2025-01-13 21:15:36 +01:00