Commit Graph

57 Commits

Author SHA1 Message Date
Pekka Enberg
19a348c91a Merge 'Print seed for failed fuzz tests' from Pedro Muniz
Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1047
2025-03-04 10:25:47 +02:00
Pekka Enberg
936ae307b7 core: Kill value type
We currently have two value types, `Value` and `OwnedValue`. The
original thinking was that `Value` is external type and `OwnedValue` is
internal type. However, this just results in unnecessary transformation
between the types as data crosses the Limbo library boundary.

Let's just follow SQLite here and consolidate on a single value type
(where `sqlite3_value` is just an alias for the internal `Mem` type).
The way this will eventually work is that we can have bunch of
pre-allocated `OwnedValue` objects in `ProgramState` and basically
return a reference to them all the way to the application itself, which
extracts the actual value.
2025-02-26 10:57:45 +02:00
pedrocarlo
521d4d85ca adding seed to output of failed tests 2025-02-19 14:23:09 -03:00
alpaylan
39b11812ea bump rusqlite to 0.33.0 from 0.29.0 2025-02-18 15:13:15 -05:00
Jussi Saurio
55ff1d2061 remove comment 2025-02-17 10:59:04 +02:00
Jussi Saurio
7eaa3f4da0 Extract variable 2025-02-17 10:58:38 +02:00
Jussi Saurio
6940ca84bd Add more column <op> column binary op possibilities to fuzzer 2025-02-17 10:57:58 +02:00
Jussi Saurio
e07007896f tests/fuzz: use mostly the same expression options in select and predicate position 2025-02-17 07:43:09 +02:00
Nikita Sivukhin
0679357fda insert numbers from different categories in order to cover cases of different serial type usage 2025-02-16 12:33:26 +04:00
Nikita Sivukhin
77d4bb6e0e fix after merge 2025-02-15 23:00:30 +04:00
Nikita Sivukhin
db7544fe7a Merge branch 'tursodatabase:main' into fix-and-predicate 2025-02-15 22:57:56 +04:00
Nikita Sivukhin
becc58565d run IO in fuzz tests 2025-02-15 22:48:01 +04:00
Jussi Saurio
01f51a4c20 Merge 'Fix math binary' from Nikita Sivukhin
Fix codegen for binary functions and add fuzz test for math functions
(we need to compile `rusqlite` with `-DSQLITE_ENABLE_MATH_FUNCTIONS` in
order to bundle sqlite with math functions compiled)

Reviewed-by: Jussi Saurio (@jussisaurio)

Closes #1015
2025-02-15 18:17:08 +02:00
Nikita Sivukhin
3233d60bea trying to debug hungs in CI 2025-02-15 18:03:29 +04:00
Nikita Sivukhin
e7c501a3be add simple fuzz test with table data 2025-02-15 16:27:11 +04:00
Nikita Sivukhin
32ec8f64d5 move .config to the top level in order to have rusqlite dep built identically across multiple projects 2025-02-15 14:54:19 +04:00
Nikita Sivukhin
610d41ae9e add fuzz test for math functions 2025-02-15 14:33:37 +04:00
Nikita Sivukhin
aa3cafba51 add fuzz test for replace and substr 2025-02-15 13:21:40 +04:00
wyhaya
351a032cc1 core: Add default column name 2025-02-11 07:03:51 +00:00
Pekka Enberg
604ca4085d Merge 'Make record values private' from Tiago
This is an attempt to move towards #881. I am not sure this is the
direction you want to take. In any case, I thought I would take a crack
at converting `values` from `Record` to private and see how bad it would
be.
In the end, as you can see, it is not so bad. I think performance-wise
it shouldn't be a bad hit with Rust's zero-cost abstraction. Also,
during the process I noticed a couple improvements that could be made
here and there but I honestly wanted to start with something small
enough that wouldn't be too hard to review.
Anyway, let me know if this is really how you would like to proceed.

Closes #962
2025-02-10 11:23:21 +02:00
Pekka Enberg
00a546e775 Merge 'Fix string funcs' from Nikita Sivukhin
Add fuzz test for string functions and fix 2 bugs in implementation of
`LTRIM/RTRIM/TRIM` and `QUOTE`:
- `QUOTE` needs to escape internal quote(`'`) symbols
- `LTRIM`/`RTRIM`/`TRIM` needs to check if they have additional argument

Closes #958
2025-02-10 11:17:51 +02:00
sonhmai
faab51ac35 remove flaky pragma cli tests.
Tests for similar behavior already covered in TCL and Rust connection api tests. So flaky problem in these is not worth exploring. We just removed them.
2025-02-10 16:01:29 +07:00
Pekka Enberg
55058cade3 Merge 'Fix cast' from Nikita Sivukhin
Fix codegen for `CAST` expression and also adjust implementation of
`CAST: Real -> Int` because `SQLite` use "closest integer between the
REAL value and zero" as a CAST result.

Closes #956
2025-02-10 10:53:56 +02:00
Pekka Enberg
09b402e261 Merge 'Fix coalesce' from Nikita Sivukhin
Add `COALESCE` function in fuzz test and fix bug (found by fuzzer with
`COALESCE`) related to the resolution of labels which needs to be
resolved to next emitted instruction.
Before, code assumed that no two labels will need to be resolved to next
emitted instruction. But this assumption is wrong (at least in current
codegen logic) for example for following expression `COALESCE(0,
COALESCE(0, 0))`. Here, both `COALESCE` functions will create label and
resolve it to next emitted instruction in the end of generation. So, in
this case one of the labels will be actually "orphaned" and never be
assigned any position in the emitted code.

Closes #955
2025-02-10 10:53:44 +02:00
Pekka Enberg
31886e8f4c Merge 'Fix case and emit' from Nikita Sivukhin
(after fixing complicated b-tree bugs - I want to end my day with the
joy of fixing simple bugs)
This PR fix bug in emit (which was introduced after switch from
`HashMap` to `Vec`) and also align `CASE` codegen in case of `NULL`
result from `WHEN` clause with SQLite behaviour.

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

Closes #953
2025-02-10 10:53:31 +02:00
Tiago Ribeiro
d00b44d7cd Update integration tests to use the new retrieval methods to access Record values. 2025-02-10 00:31:31 -07:00
Nikita Sivukhin
f22bfad695 reduce amount of iterations in fuzz test 2025-02-09 23:44:38 +04:00
Nikita Sivukhin
459a78bc64 add fuzz test for few string functions 2025-02-09 23:43:34 +04:00
Nikita Sivukhin
d2fb772936 adjust CAST fuzzing options 2025-02-09 22:47:06 +04:00
Nikita Sivukhin
e3e399f9b1 fixup fuzz 2025-02-09 22:31:13 +04:00
Nikita Sivukhin
9a3af4bd06 add CAST expression in the fuzz test 2025-02-09 22:20:13 +04:00
Nikita Sivukhin
abcebf7915 add coalesce in fuzz test 2025-02-09 21:55:43 +04:00
Nikita Sivukhin
c3b7938266 add case expr in fuzzer and adjust probabilities 2025-02-09 21:33:14 +04:00
Aarni Koskela
eaea02c567 Fix a handful of typos 2025-02-09 18:08:29 +02:00
meteorgan
a99d9a8988 chore: remove unused dependencies 2025-02-09 21:05:06 +08: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
Jussi Saurio
795576b2ec dont eagerly allocate result column name strings 2025-02-05 17:53:23 +02:00
Pekka Enberg
f69804969c Merge 'Adding checkpoint result' from Sonny
### What?
adding checkpoint result returning number of pages in wal and num pages
checkpointed.
Part of #696
### Context
SQLite returns in checkpoint result of calling `pragma wal_checkpoint;`
`0|3|3` while limbo returns `0|0|0`.
https://sqlite.org/pragma.html#pragma_wal_checkpoint
- 1st col: 1 (checkpoint SQLITE_BUSY) or 0 (not busy).
- 2nd col: # modified pages written to wal file
- 3rd col: # pages moved to db after checkpoint
This PR aims to add 2nd and 3rd column to the checkpoint result.
SQLite
```
sqlite3 test.db
sqlite> pragma journal_mode=wal;
wal
sqlite> pragma journal_mode;
wal
sqlite> create table t1 (id text);
sqlite> insert into t1(id) values (1),(2);
sqlite> select * from t1;
1
2
sqlite> pragma wal_checkpoint;
0|3|3
```
Limbo
```
./target/debug/limbo test.db
Limbo v0.0.13
Enter ".help" for usage hints.
limbo> pragma journal_mode;
wal
limbo> create table t1(id text);
limbo> insert into t1(id) values (1),(2);
limbo> select * from t1;
1
2
# current the 2nd and 3rd columns are hard coded in limbo to 0
limbo> pragma wal_checkpoint;
0|0|0
```

Closes #827
2025-02-04 18:26:24 +02:00
Levy A.
dcd32e1ec8 fix: clippy + new errors 2025-02-03 16:58:13 -03:00
Levy A.
9df0b01689 refactor: lower ownership requirement 2025-02-03 16:52:42 -03:00
sonhmai
022a8d7a83 core: return checkpoint result 2025-02-03 19:02:16 +07:00
Nikita Sivukhin
f43a326649 add examples of tests found by fuzzer 2025-02-03 11:25:14 +04:00
Nikita Sivukhin
529c2df6f6 add few scalar function with binary result in logical fuzz test 2025-02-03 11:25:14 +04:00
Nikita Sivukhin
17d06a1d28 adjust options for logical fuzz test 2025-02-03 11:25:14 +04:00
Nikita Sivukhin
c2950d144e add logical expression fuzz tests 2025-02-03 11:25:14 +04:00
Pekka Enberg
9458d1ed14 Merge 'Fix shr instruction' from Nikita Sivukhin
This PR fixes implementation of binary shift right/left instructions.
Before there were a minor incompatibility between limbo and sqlite
implementation in case when right shift second argument were more than
64 and first argument were negative. As sqlite implementation of right
binary shift is sign-extended - so `-1` should be returned in such case
when limbo returned zero.
This PR fixes this bug and also introduce a fuzz tests for arithemtic
expressions. This fuzz test were written with a help of
`GrammarGenerator` which allows to easily define probabilistic context-
free grammar and then later sample random strings from it.

Closes #867
2025-02-03 09:22:39 +02:00
Nikita Sivukhin
41419ab11a add env logger and fix range 2025-02-02 20:12:56 +04:00
Nikita Sivukhin
e63d84ed50 refine assertions 2025-02-02 20:10:38 +04:00
Nikita Sivukhin
6cc1b778b4 add test with rowid=-1
- now limbo attempts to add with overflow and panic in this case
2025-02-02 20:02:59 +04:00
Nikita Sivukhin
3ff76e657e allow a bit of dead code for now 2025-02-02 19:55:04 +04:00