Commit Graph

1580 Commits

Author SHA1 Message Date
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
Jussi Saurio
9b7b2f6241 Merge 'Codegen cleanups' from Pekka Enberg
Some random cleanups to make planner.rs smaller.

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

Closes #582
2024-12-31 12:18:08 +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
c4b0eb398c Limbo 0.0.11 2024-12-31 10:43:24 +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
21a9f293fd Merge 'simulator: allow failure assertions' from Alperen Keleş
- add creating the same table two times to the list of checked
properties as a failure property example

Reviewed-by: Pekka Enberg <penberg@iki.fi>
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #554
2024-12-31 10:35:43 +02:00
Pekka Enberg
80fe5b0425 Merge 'Add in-memory mode to Python bindings' from Jean Arhancet
Add memory database support in Python bindings and add immediate
statement execution for DDL/DML operations (logic to be confirmed)

Closes #569
2024-12-31 10:33:18 +02:00
Pekka Enberg
d12afe163c Merge 'Document how to add a new SQL function' from Sonny
Suggesting adding a simple guide on how to start contributing a SQL
function.
It would be easier if I had something like this when I started
contributing to Limbo, maybe it will be for others as well.
I'm aware that this will be partly out-of-date over time due to
refactors. However, I think the gist of modifying different layers
(Parser, VDBE bytecode program,...) and how they interact with each
other stays. That part is what I hope this guide can convey to a new
contributor.
What do you think?

Closes #565
2024-12-31 10:32:20 +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
Pekka Enberg
4e8f3de535 Merge 'Clean up more Clippy warnings' from Lauri Virtanen
I ran `cargo clippy --fix` and also fixed some issues manually.
Clippy still warns about some issues - especially in Simulator code.

Closes #574
2024-12-31 10:30:19 +02:00
psvri
3ac3fdf0a2 Fix glob 2024-12-30 17:02:31 +05:30
JeanArhancet
9a70dc8f78 fix: clippy error 2024-12-30 10:22:36 +01:00
JeanArhancet
2a0402ce7f fix: python lint 2024-12-30 10:21:11 +01:00
JeanArhancet
cb69d8b0dd feat(python): add in-memory mode 2024-12-30 10:21:11 +01:00
alpaylan
d8ce88c057 fix clippy warning 2024-12-30 00:41:21 -05:00
alpaylan
58f23983e1 minor changes, add maximum time bound to the simulator, fix bug in the table create shadowing 2024-12-30 00:36:43 -05:00
alpaylan
c01f2d4ac2 fix formatting 2024-12-29 16:09:49 -05:00
alpaylan
8e2a1e4289 Merge remote-tracking branch 'turso/main' 2024-12-29 16:08:35 -05:00
PThorpe92
4e77840ee5 Setup io_uring with sqpoll enabled 2024-12-29 15:34:17 -05:00
alpaylan
d3fee3b331 add empty line at the end of cargo.toml, add create counts to the interaction stats, turn the percentages into f64 2024-12-29 14:00:57 -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
Pere Diaz Bou
b9187d57f6 Merge 'Add clippy CI, fix or ignore warnings where appropriate' from Preston Thorpe
There is no semantic changes in this PR, the clippy command came from
@pereman2's suggestion in #542
There was more to fix than I previously thought. I originally set out to
refactor out some of the logic in `vdbe::step`, but with some actual
semantic changes. That file: `vdbe/mod.rs` is so full that it required
moving the `Insn` enum to another file, so I figured I would just put
some non-semantic changes all together so it's easier to review and get
that done first... and figured I'd fix some clippy warnings while I was
at it. Also adjusted the actions to `checkout/@v3`.
The project is obviously so early that there are going to be a decent
amount of things like unused fields or methods, which is why I was
originally not really pro clippy.. but seeing how many genuinely good
improvements it recommended, I think it's probably the right way to go.

Closes #563
2024-12-29 17:43:18 +01:00
PThorpe92
361e55f858 Fix checkout action for clippy ci 2024-12-29 10:25:49 -05: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
Jussi Saurio
948a2d3358 Merge pull request #572 from tursodatabase/commit-cargo-lock-changes
chore: commit cargo lock changes from #553
2024-12-29 09:09:10 +02:00
Jussi Saurio
8c9bd0deb9 chore: commit cargo lock changes from #553 2024-12-29 08:58:26 +02:00
psvri
1922b8ea38 Support like function with escape 2024-12-28 13:55:12 +05:30
Pekka Enberg
a8e2f48ab2 Merge 'Remainder vdbe opcode' from Preston Thorpe
Reviewed-by: Sonny <14060682+sonhmai@users.noreply.github.com>

Closes #562
2024-12-28 09:46:53 +02:00
sonhmai
38e9ed7d5b make functions contrib doc better 2024-12-28 12:48:04 +07:00
Sonny
2a3f4fd02a Merge branch 'tursodatabase:main' into feat/doc-functions-contributing 2024-12-28 11:26:17 +07:00
PThorpe92
ddf229c432 Update COMPAT.md 2024-12-27 15:42:13 -05:00
PThorpe92
82de59dd88 Add compatability tests for mod operator 2024-12-27 15:39:02 -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
Pekka Enberg
ae47665a25 Merge 'Add support for DELETE query planning ' from Kim Seon Woo
### Purpose of this PR
Support for DELETE query execution planning
### Implementation Details
The main entry point for planning DELETE queries is the
`translate_delete` function. It is composed of three primary steps:
- `prepare_delete_plan`:
  - Reuses the existing SELECT query's WHERE clause parsing logic to
interpret and construct the initial delete plan.
- `optimize_delete_plan`:
  - eliminating BETWEEN expressions
  - usage of indexes
- `emit_program_for_delete`:
  - Add instructions for delete operation
I've tried to reuse existing logic(mostly on SELECT operations) as much
as I can, so that we can automatically incorporate new changes
automatically.
### Delete planning debug
I've used `println!(...)` to specify the rows to delete. Example below
<img width="374" alt="image" src="https://github.com/user-
attachments/assets/f109e1c6-6b69-43b9-bb23-4bee3a835767" />
### Bytecode compatibility
`EXPLAIN DELETE FROM users WHERE id = 1;`
<img width="1724" alt="image" src="https://github.com/user-
attachments/assets/ce2995d7-6947-493e-ad3d-224df7f4e7c2" />
`EXPLAIN DELETE FROM users WHERE id > 3`
<img width="1726" alt="image" src="https://github.com/user-
attachments/assets/ac516bd2-fe80-44c5-9a4b-8e35d574c47d" />
`EXPLAIN DELETE FROM users WHERE id < 3`
<img width="1711" alt="image" src="https://github.com/user-
attachments/assets/29d0ccba-c373-483e-bb6b-9344289cae02" />
### TODO(future works)
- Add support for `Clear` opcode
- Add test when `delete` is implemented in `Cursor`
<img width="1728" alt="image" src="https://github.com/user-
attachments/assets/28d371fc-90f5-42e5-8add-d5218f830234" />

Closes #538
2024-12-27 18:34:02 +02:00
psvri
5470ea2344 Add tests in like.test 2024-12-27 21:49:26 +05:30
Diego Reis
2d0c16c428 Fix sqlite_version() out of bound 2024-12-27 11:39:33 -03:00