Commit Graph

4479 Commits

Author SHA1 Message Date
Jussi Saurio
51b097fa3d perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
Pekka Enberg
4553adf317 Merge 'Rename OwnedValue -> Value' from Pekka Enberg
We have not had enough merge conflicts for a while so let's do a tree-
wide rename.

Closes #1488
2025-05-15 10:31:36 +03:00
Pekka Enberg
b07738e54b sqlite3: Update sqlite3.h with cbindgen
...people have been manually tweaking the header, but it's out of date.
Let's just use "cbindgen", which is the sensible thing to do.
2025-05-15 10:07:54 +03:00
Pekka Enberg
e3f71259d8 Rename OwnedValue -> Value
We have not had enough merge conflicts for a while so let's do a
tree-wide rename.
2025-05-15 09:59:46 +03:00
Pekka Enberg
75b1649aeb Merge 'Improve SQLite3 C API tests' from Pekka Enberg
We have tests both in C and Rust, but the latter is never run with
SQLite. Unify them.

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

Closes #1481
2025-05-15 09:59:01 +03:00
Pekka Enberg
12238870b7 sqlite3/tests: Make Clippy happy
There nothing more important to me personally than keeping the computer happy.
2025-05-15 09:38:41 +03:00
Pekka Enberg
d3e7dd2224 Merge 'github: Disable setup-node yarn cache' from Pekka Enberg
The setup-node fails sporadically with the following error:
```
Error: Could not get yarn cache folder path for /home/runner/work/limbo/limbo/bindings/javascript/docs
```
This seems to be a known issue that's not fixed despite the issue being
closed: https://github.com/actions/setup-node/issues/887
Let's disable yarn caching for setup-node in an attempt to reduce CI
failing randomly.

Closes #1487
2025-05-15 09:37:35 +03:00
Pekka Enberg
dde897d172 sqlite3/tests: Remove test case from test_wal_checkpoint_v2 2025-05-15 09:30:42 +03:00
Pekka Enberg
de8d4dfe4f sqlite3/tests: Remove test case from test_wal_checkpoint
Turns out SQLite SIGSEGVs on CI runs for this...
2025-05-15 09:15:47 +03:00
Pekka Enberg
cac464b49a sqlite3: Switch error to trace-level logging
...it's pretty pointless to spam the logs for this.
2025-05-15 09:15:35 +03:00
Pekka Enberg
7458848a56 sqlite3/tests: Remove C-based compat tests
...they're now just duplicating the Rust ones.
2025-05-15 09:15:35 +03:00
Pekka Enberg
0db542171f Makefile: Update test-sqlite3 target to run Rust tests
The API compat test suite is now all in Rust.
2025-05-15 09:15:35 +03:00
Pekka Enberg
0e5234ee86 sqlite3/tests: Skip compat test on Windows
We have linking issues with the static libraries so skip them for now.
2025-05-15 09:15:35 +03:00
Pekka Enberg
358a40928f sqlite3/tests: Make Clippy happy 2025-05-15 09:15:35 +03:00
Pekka Enberg
18dbf033d8 sqlite3/tests: Enable all test cases 2025-05-15 09:15:35 +03:00
Pekka Enberg
cf66dfcdaf sqlite3/tests: Remove invalid test_open_misuse test case
You can pass NULL to `sqlite3_open()` and it will open a private,
temporary on-disk database. Therefore, drop the broken test.
2025-05-15 09:15:35 +03:00
Pekka Enberg
fde5484e93 sqlite3/tests: Relax test_libversion_number assertion
...make it less dependent on specific version of SQLite.
2025-05-15 09:15:35 +03:00
Pekka Enberg
41e9d7f9b8 sqlite3/tests: Run Rust-based test suite also with SQLite
You can now run the tests with SQLite with:

```
cargo test --test compat --features sqlite3
```
2025-05-15 09:15:35 +03:00
Pekka Enberg
77cc78f7d2 github: Disable setup-node yarn cache
The setup-node fails sporadically with the following error:

```
Error: Could not get yarn cache folder path for /home/runner/work/limbo/limbo/bindings/javascript/docs
```

This seems to be a known issue that's not fixed despite the issue being closed: https://github.com/actions/setup-node/issues/887

Let's disable yarn caching for setup-node in an attempt to reduce CI
failing randomly.
2025-05-15 09:13:19 +03:00
Jussi Saurio
d086ab29a6 Merge 'Update Unique constraint for Primary Keys and Indexes' from Pedro Muniz
This PR attempts to implement Primary Key and Indexes. It supports
Update for Primary Keys as a RowId Alias, Composite Primary Keys, and
Indexes. I tried to resemble as much as possible how SQLite emits the
Opcodes.
~Additionally, to support this I had to fix a bug in the how we searched
for the next records in the `Next` opcode, by introducing a Set of seen
row id's. The problem was that, you need to delete the previous record
and then insert the new record to update. When we did that in a `Rewind`
loop, the current cell index in the cursor was always pointing to the
incorrect place because we were searching for the next record without
checking if we had seen it before. However, I am not sure how this
affects the Btree.~
EDIT: After seeing how bad my fix was, I tried a different approach that
is more in line with what SQLite does. When performing a `Delete` in the
btree, we can save the current `rowid` (`TableBtree`) or the current
`record` for (`IndexBtree`), and then restore the correct position later
in the `next` function by seeking to the saved context. I'm just not
knowledgeable enough yet to be efficient  of when we can avoid saving
the context and doing the seek later.

Closes #1429
2025-05-14 19:54:05 +03:00
pedrocarlo
9fc9415b20 use Jussi's code to avoid cloning immutable record 2025-05-14 13:30:39 -03:00
pedrocarlo
72cc0fcdcb fixes and comments 2025-05-14 13:30:39 -03:00
pedrocarlo
b2615d7739 add CursorValidState and only save context in delete when rebalancing 2025-05-14 13:30:39 -03:00
pedrocarlo
814508981c fixing more rebase issues and cleaning up code. Save cursor context when calling delete for later use when needed 2025-05-14 13:30:39 -03:00
pedrocarlo
c69f503eac rebase adjustments 2025-05-14 13:30:39 -03:00
pedrocarlo
05f4ca28cc btree rewind and next fix. Keep track of rowids seen to avoid infinite loop 2025-05-14 13:30:39 -03:00
pedrocarlo
c146877344 add sqlite debug cli for nix. Fix cursor delete panic. Add tracing for cell indices in btree 2025-05-14 13:30:39 -03:00
pedrocarlo
6588004f80 fix incorrectly detecting if user provided row_id_alias to set clause 2025-05-14 13:30:39 -03:00
pedrocarlo
482634b598 adjust null opcode emission based in rowid_alias 2025-05-14 13:30:39 -03:00
pedrocarlo
758dfff2fe modified tests as we do not have rollback yet. Also correctly raise a contraint error on primary keys only 2025-05-14 13:30:39 -03:00
pedrocarlo
3aaf4206b7 altered constraint tests to create bad update statements. Tests caught a bug where I was copying the wrong values from the registers 2025-05-14 13:30:39 -03:00
pedrocarlo
cf7f60b8f5 changed from resolve_label to preassign_label 2025-05-14 13:30:39 -03:00
pedrocarlo
6457d7675a instruction emitted should be correct, but having an infinite loop bug 2025-05-14 13:30:39 -03:00
pedrocarlo
60a99851f8 emit NoConflict and Halt. Already detects unique constraints 2025-05-14 13:30:39 -03:00
pedrocarlo
5f2216cf8e modify explain for MakeRecord to show index name 2025-05-14 13:30:39 -03:00
pedrocarlo
9aebfa7b5d open cursors for write only once 2025-05-14 13:30:39 -03:00
pedrocarlo
5bae32fe3f modified OpenWrite to include index or table name in explain 2025-05-14 13:30:39 -03:00
pedrocarlo
e7fa023c26 Adding indexes to the update plan 2025-05-14 13:30:39 -03:00
Jussi Saurio
76b29c2909 Merge 'Fix: unique contraint in auto index creation' from Pedro Muniz
Closes #1457 .
```sql
limbo> CREATE table t2 (x INTEGER PRIMARY KEY, y INTEGER UNIQUE);
limbo> SELECT * FROM sqlite_schema;
┌───────┬───────────────────────┬──────────┬──────────┬───────────────────────────────────────────────────────────┐
│ type  │ name                  │ tbl_name │ rootpage │ sql                                                       │
├───────┼───────────────────────┼──────────┼──────────┼───────────────────────────────────────────────────────────┤
│ table │ t2                    │ t2       │        2 │ CREATE TABLE t2 (x INTEGER PRIMARY KEY, y INTEGER UNIQUE) │
├───────┼───────────────────────┼──────────┼──────────┼───────────────────────────────────────────────────────────┤
│ index │ sqlite_autoindex_t2_1 │ t2       │        3 │                                                           │
└───────┴───────────────────────┴──────────┴──────────┴───────────────────────────────────────────────────────────┘
```

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

Closes #1458
2025-05-14 19:26:03 +03:00
pedrocarlo
4dc1431428 handling edge case when passing duplicate a multi-column unique index 2025-05-14 11:46:24 -03:00
pedrocarlo
ea15b1f617 extract primary key detection 2025-05-14 11:34:39 -03:00
pedrocarlo
b93156ee9d simplify unique sets creation 2025-05-14 11:34:39 -03:00
pedrocarlo
e75e20c9e9 fix incorrect matching in column name 2025-05-14 11:34:39 -03:00
pedrocarlo
5dee1adab8 panic when on_conflict is specified for Unique constraint 2025-05-14 11:34:39 -03:00
pedrocarlo
e7d0962a6c adjust order of indices and add tests 2025-05-14 11:34:39 -03:00
pedrocarlo
3526a206e4 support Unique properly by creating a vec of auto indices 2025-05-14 11:34:39 -03:00
pedrocarlo
c5f004c1d6 added test and adjustments 2025-05-14 11:34:39 -03:00
pedrocarlo
e4ca1bb55e modify automatic index creation to account for unique columns 2025-05-14 11:34:11 -03:00
pedrocarlo
bb158a5433 add unique field to Column 2025-05-14 11:34:11 -03:00
pedrocarlo
002acbb9dc add check for unique contraint in auto index creation 2025-05-14 11:34:11 -03:00