Commit Graph

3994 Commits

Author SHA1 Message Date
Jussi Saurio
6463448fdc Merge 'Fix incompatibility AND Operation' from Pedro Muniz
Sqlite reference implementation: https://github.com/sqlite/sqlite/blob/8
37dc09bce7de8971c7488b70cf5da93c60fbed0/src/vdbe.c#L2558
We did not support blobs before and our ordering of the match statements
were incorrect when one of the arguments was NULL

Closes #1337
2025-04-15 14:37:29 +03:00
Jussi Saurio
57816a12f6 Merge 'Fix: comment out incorrect assert in fuzz' from Pedro Muniz
Currently, to run the fuzz test you need to remove an assert statement.
EDIT: @diegoreis42 pointed it out to me that the method had just changed
actually. Made the change to use `row.len()` instead
# Problem
```
cargo +nightly fuzz run --target=aarch64-apple-darwin expression
   Compiling limbo_core v0.0.19-pre.4 (/Users/pedro/Projects/limbo/core)
   Compiling limbo-fuzz v0.0.0 (/Users/pedro/Projects/limbo/fuzz)
error[E0599]: `&limbo_core::vdbe::Row` is not an iterator
   --> fuzz_targets/expression.rs:198:36
    |
198 |                     assert_eq!(row.count(), 1, "expr: {:?}", expr);
    |                                    ^^^^^
    |                                    |
    |                                    `&limbo_core::vdbe::Row` is not an iterator
    |                                    private field, not a method
    |
   ::: /Users/pedro/Projects/limbo/core/vdbe/mod.rs:221:1
    |
221 | pub struct Row {
    | -------------- doesn't satisfy `limbo_core::vdbe::Row: std::iter::Iterator`
    |
    = note: the following trait bounds were not satisfied:
            `&limbo_core::vdbe::Row: std::iter::Iterator`
            which is required by `&mut &limbo_core::vdbe::Row: std::iter::Iterator`
            `limbo_core::vdbe::Row: std::iter::Iterator`
            which is required by `&mut limbo_core::vdbe::Row: std::iter::Iterator`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `limbo-fuzz` (bin "expression") due to 1 previous error
Error: failed to build fuzz script: ASAN_OPTIONS="detect_odr_violation=0" RUSTFLAGS="-Cpasses=sancov-module -Cllvm-args=-sanitizer-coverage-level=4 -Cllvm-args=-sanitizer-coverage-inline-8bit-counters -Cllvm-args=-sanitizer-coverage-pc-table -Cllvm-args=-sanitizer-coverage-trace-compares --cfg fuzzing -Clink-dead-code -Zsanitizer=address -Cdebug-assertions -C codegen-units=1" "cargo" "build" "--manifest-path" "/Users/pedro/Projects/limbo/fuzz/Cargo.toml" "--target" "aarch64-apple-darwin" "--release" "--config" "profile.release.debug=true" "--bin" "expression"
```

Closes #1334
2025-04-15 14:36:12 +03:00
Jussi Saurio
5a38b38e71 Merge 'Feature: VDestroy for Dropping Virtual Tables' from Pedro Muniz
Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1274
2025-04-15 14:34:30 +03:00
Jussi Saurio
e0e031d8af Merge 'Fix two issues with indexes' from Jussi Saurio
Fixes #1298
- Fixes Limbo trying to use an index using a WHERE clause constraint
that refers to the same table on both sides, e.g. `WHERE t.x = t.x`
- Fixes not using indexes when the relevant expression is paren wrapped,
e.g.
    - `SELECT * FROM t WHERE (indexcol) > 5`
    - `SELECT * FROM t WHERE (indexcol > 5)`
- Changes existing table logical expr fuzz test to have primary keys
(which helped me find both issues above)

Closes #1300
2025-04-15 14:00:58 +03:00
Pere Diaz Bou
0518107443 Merge 'Feat balance shallower' from Lâm Hoàng Phúc
Fixed is_empty assertion in #1203 , but simulator still has error.
```sh
[ERROR] error Internal error: select '(engrossing_berger < X'6566651A3C70278D4E200657551D8071A1' AND competitive_petit > 1236742147.9451914)' should return no values for table 'super_becky'
```

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

Closes #1308
2025-04-15 11:02:31 +02:00
pedrocarlo
fab2ddc8cf Fix: incorrect assert in fuzz 2025-04-14 16:52:13 -03:00
TcMits
96112f8e54 missing check for balance-shallower 2025-04-14 18:30:32 +07:00
TcMits
18d779924b post validation should be after balance-shallower 2025-04-14 18:13:47 +07:00
Jussi Saurio
e07a6fc5c0 Merge 'Add Ansi Colors to tcl test runner' from Pedro Muniz
Closes #1336. I really do not like only black and white text. Have a
look in CI to see the colors

Closes #1338
2025-04-14 11:59:40 +03:00
Jussi Saurio
d20782350d Merge 'support modifiers for julianday()' from meteorgan
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1321
2025-04-14 11:52:43 +03:00
Jussi Saurio
79b08a80ab Merge 'Parse hexidecimal integers' from Anton Harniakou
Fixes #1304
Maybe I should add tests?

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

Closes #1329
2025-04-14 11:49:10 +03:00
Jussi Saurio
4b7a5f39b3 Merge 'Implement Once and OpenAutoindex opcodes' from Jussi Saurio
Some enabler work for enabling autoindexing, which means creating a
transient in memory index when a persistent index is not found. This is
used to avoid nested full table scans.
@pereman2 I added some functionality to your `SmallVec` so would
appreciate a review of those parts

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

Closes #1340
2025-04-14 11:45:41 +03:00
Jussi Saurio
23f8fffe12 Add Insn::OpenAutoindex, which is just an alias for OpenEphemeral 2025-04-14 11:23:37 +03:00
Jussi Saurio
9dadc58194 Add support for Insn::Once 2025-04-14 11:23:37 +03:00
Jussi Saurio
f79da7194f implement Iterator for SmallVec and add const generic for array size 2025-04-14 11:23:37 +03:00
Jussi Saurio
f5523e7a23 Merge pull request #1339 from tursodatabase/yeet-async-await-opcodes
refactor: fold Async/Await insns into a single instruction
2025-04-14 10:37:53 +03:00
TcMits
ee660187dc fix negative free space after balance-shallower 2025-04-14 14:25:18 +07:00
Jussi Saurio
d286a56e15 refactor: fold Async/Await insns into a single instruction 2025-04-14 09:40:20 +03:00
TcMits
b3c2593980 btree balance-shallower 2025-04-14 12:49:30 +07:00
pedrocarlo
f3a07c86a0 Add Ansi Colors to tcl test runner 2025-04-13 23:36:09 -03:00
pedrocarlo
af456513d1 Fix incompatibility AND Expression 2025-04-13 22:38:43 -03:00
pedrocarlo
6249cd67e9 added print statement to test that VDestroy is being called 2025-04-13 17:10:43 -03:00
pedrocarlo
2181de79de add destroy function to vtab 2025-04-13 17:06:12 -03:00
pedrocarlo
c0747e8064 update COMPAT.md 2025-04-13 17:06:12 -03:00
pedrocarlo
000d8756ec Implment VDestroy opcode 2025-04-13 17:06:12 -03:00
Anton Harniakou
499d9b8d45 Add integration tests for hex numbers 2025-04-13 21:50:48 +03:00
Jussi Saurio
472afdd841 Merge 'Add support for OpenEphemeral bytecode' from Diego Reis
First ~actual~ step to close #741, this time I'm following an approach
way closer to what SQLite does by just creating a normal `BTreeCursor`
and using an in-memory pager (thanks @krishvishal for the insight
🤝).

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

Closes #1139
2025-04-13 17:25:37 +03:00
Diego Reis
fd79ad2644 core/vdbe: Change is_btree to is_table in OpenEphemeral 2025-04-13 11:15:01 -03:00
Diego Reis
4c315e1bb6 core/vdbe: Update OpenEphemeral to use CreateBtreeFlags 2025-04-13 11:13:25 -03:00
Diego Reis
135330b736 core/pager: Fix page handling issue due change in wal type 2025-04-13 11:10:06 -03:00
Diego Reis
035e6dcef4 core/vdbe: Fix logic error during btree creation
I do thing we should change this 1,2 flag to 0,1 or just an enum, to be more rustacean. The current state can be very misleading
2025-04-13 11:10:06 -03:00
Diego Reis
61c324cca5 core/vdbe: Add missing work to get cursor and transient table usable 2025-04-13 11:10:06 -03:00
Diego Reis
bcac1fe778 core/vdbe: Rename page_io to db_file in OpenEphemeral 2025-04-13 11:10:06 -03:00
Diego Reis
09d83aadf3 Fix dumb conflict errors 2025-04-13 11:10:06 -03:00
Diego Reis
d9bf383507 core/io: Untie MemoryIO's lifetime of the IO layer 2025-04-13 11:10:06 -03:00
Diego Reis
79f8b83cbe Fix dumb clippy errors 2025-04-13 11:10:06 -03:00
Diego Reis
66e12e1c2d core/vdbe: Create OpenEphemeral bytecode
"Open a new cursor P1 to a transient table. The cursor is always opened read/write even if the main database is read-only. The ephemeral table is deleted automatically when the cursor is closed.

If the cursor P1 is already opened on an ephemeral table, the table is cleared (all content is erased)."

There is still some work to do, but this is a basic setup
2025-04-13 11:10:06 -03:00
Diego Reis
e5144bb6a9 core/storage: Create FileMemoryStorage
This is basically a copy of DatabaseStorage but outside the fs compilation flag, this way, we can access MemoryIO regardless the storage medium.
2025-04-13 11:10:06 -03:00
Diego Reis
b519509349 core/io: Add internal in-memory MemoryIO to all IO layers
Honestly I don't have 100% sure if this is a good idea, the reasoning is that in any IO we'll want to do memory only operations like creating tables etc, so may want a common way to access it
2025-04-13 11:10:05 -03:00
Diego Reis
65d4c68cf2 core/pager: Wrap wal with Option 2025-04-13 11:10:05 -03:00
Jussi Saurio
8e601959ad Merge 'Fuzz fix some operations' from Pedro Muniz
Me and @diegoreis42 were late at night, running the new fuzzer and saw
some errors with `Bit-Not` and `Not` operations. Added some tests as
well for those fixes.

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

Closes #1328
2025-04-13 17:02:19 +03:00
Jussi Saurio
cbe3500b7e Merge 'Code clean-ups' from Diego Reis
While developing I found that some things could be improved :)

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

Closes #1325
2025-04-13 17:02:12 +03:00
Jussi Saurio
b51f9bba23 Merge 'Return null when parameter is unbound' from Levy A.
Fix #1323.

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

Closes #1324
2025-04-13 17:02:03 +03:00
Jussi Saurio
f660c65199 Merge 'Enhance robusteness of optimization for Binary expressions' from Diego Reis
fix #1318

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

Closes #1322
2025-04-13 17:01:53 +03:00
Anton Harniakou
9ed34924e6 Parse hexidecimal integers 2025-04-13 11:52:25 +03:00
meteorgan
f3f7a722a7 avoid converting double to string in datetime 2025-04-13 16:41:30 +08:00
pedrocarlo
1297cb107c bit-not and boolean-not
Co-authored-by: Diego Reis <79876389+diegoreis42@users.noreply.github.com>
2025-04-13 02:45:12 -03:00
Diego Reis
51eb2af06a core(refactor): Add CreateBTreeFlags
Passing 1s and 0s with comments is not rustacean, and since we already follow the pattern of struct flags in other sections of the codebase it's better use it here too.
2025-04-13 01:46:30 -03:00
Diego Reis
da484b33aa core/storage: Add asserts to check invariants for current_page
While developing, I had an underflow issue during the casting: `current as usize`. Which could be found way faster with proper asserts.
2025-04-12 22:29:29 -03:00
Levy A.
d210ee1497 cargo fmt 2025-04-12 18:55:48 -03:00