Commit graph

2962 commits

Author SHA1 Message Date
pedrocarlo
20115c1e74 return parse error when calling unimplemented pragma checkpoint modes 2025-06-17 11:42:20 -03:00
Luca Muscat
a5ac1884c1 core: Stop treating the contents of a Value::Blob as a String
By encoding a Vec<u8> (vector of bytes), a lossy conversion from a
`Vec<u8>` to a `String` occurs. The lossy conversion leads to an
incorrect hex value to be displayed.

Avoid the lossy conversion and let the `hex` crate do its thing.
2025-06-16 21:10:17 +02:00
Pekka Enberg
db4945eada Merge 'Fix update queries to set n_changes ' from Kim Seon Woo
- `Update` query doesn't update `n_changes`. Let's make it work
- Add `InsertFlags` to add meta information related to insert operations
- For update query, add `UPDATE` flag
- Currently, the update query executes `Insn::Delete` and `Insn::Insert`
internally, it increases `n_change` by 2. So, for the update query,
let's skip increasing `n_change` for the `Insn::Insert`
https://github.com/tursodatabase/limbo/issues/1681

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

Closes #1683
2025-06-16 16:30:20 +03:00
Pekka Enberg
4496a0d08a core: Clean up integrity_check()
Suggested by Jussi.
2025-06-16 14:46:36 +03:00
Pekka Enberg
882c5ca168 Merge 'Simple integrity check on btree' from Pere Diaz Bou
This PR adds support for the instruction `IntegrityCk` which performs an
integrity check on the contents of a single table. Next PR I will try to
implement the rest of the integrity check where we would check indexes
containt correct amount of data and some more.
<img width="1151" alt="image" src="https://github.com/user-
attachments/assets/29d54148-55ba-480f-b972-e38587f0a483" />

Closes #1719
2025-06-16 13:46:26 +03:00
Pekka Enberg
dd001f9444 Merge 'Return parse error instead of corrupt error for no such table' from Pedro Muniz
This is more in line with SQLite:
```sql
sqlite> insert into t values (randomblob(1024*1024 * 6));
Parse error: no such table: t
```

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1744
2025-06-16 11:04:50 +03:00
Pekka Enberg
90c1e3fc06 Switch Connection to use Arc instead of Rc
Connection needs to be Arc so that bindings can wrap it with `Mutex` for
multi-threading.
2025-06-16 10:43:19 +03:00
pedrocarlo
fef9add773 emit parse error instead of corrupt error for no such table 2025-06-14 18:45:23 -03:00
meteorgan
b910fd0012 drop unused code in op_column 2025-06-15 00:50:16 +08:00
Jussi Saurio
30e4511d62 Merge 'NOT NULL constraint' from Anton Harniakou
Some checks failed
Python / sdist (push) Has been cancelled
Python / macos-arm64 (aarch64) (push) Has been cancelled
JavaScript / stable - x86_64-apple-darwin - node@20 (push) Has been cancelled
JavaScript / stable - x86_64-pc-windows-msvc - node@20 (push) Has been cancelled
JavaScript / stable - x86_64-unknown-linux-gnu - node@20 (push) Has been cancelled
Rust / cargo-fmt-check (push) Has been cancelled
Python / configure-strategy (push) Has been cancelled
Python / lint (push) Has been cancelled
Python / check-requirements (push) Has been cancelled
Python / linux (x86_64) (push) Has been cancelled
Python / macos-x86_64 (x86_64) (push) Has been cancelled
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Has been cancelled
Rust / build-native (macos-latest) (push) Has been cancelled
Rust / build-native (windows-latest) (push) Has been cancelled
Rust / clippy (push) Has been cancelled
Rust / build-wasm (push) Has been cancelled
Rust / test-limbo (push) Has been cancelled
Rust / test-sqlite (push) Has been cancelled
Rust Benchmarks+Nyrkiö / bench (push) Has been cancelled
Rust Benchmarks+Nyrkiö / clickbench (push) Has been cancelled
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Has been cancelled
Rust Benchmarks+Nyrkiö / tpc-h (push) Has been cancelled
JavaScript / Test bindings on x86_64-apple-darwin - node@18 (push) Has been cancelled
JavaScript / Test bindings on x86_64-apple-darwin - node@20 (push) Has been cancelled
JavaScript / Test bindings on Linux-x64-gnu - node@18 (push) Has been cancelled
JavaScript / Test bindings on Linux-x64-gnu - node@20 (push) Has been cancelled
JavaScript / Build universal macOS binary (push) Has been cancelled
JavaScript / Publish (push) Has been cancelled
Python / test (push) Has been cancelled
Python / Release (push) Has been cancelled
Implements basic support for `NOT NULL` contraint check.

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

Closes #1675
2025-06-13 14:25:24 +03:00
Anton Harniakou
25d0584b19 Fix typo 2025-06-13 11:57:39 +03:00
Jussi Saurio
3f90fad131 Merge 'Simulator Ast Generation + Simulator Unary Operator + Refactor to use limbo_core::Value in Simulator for massive code reuse' from Pedro Muniz
This PR is a Drop-In replacement to the Predicate defined in the
Simulator. Predicate is basically the same as our ast::Expr, but it
supports a small number of the SQL expression syntax. By creating a
NewType that wraps ast::Expr we can tap into our already mostly
correctly defined parser structs. This change will enable us to easily
add generation for more types of sql queries.
I also added an ArbitraryFrom impl for ast::Expr that can be used in a
freestyle way (for now) for differential testing.
This PR also aims to implement Unary Operator logic similar to the
Binary Operator logic we have for predicate. After this change we may
need to adjust the Logic for how some assertions are triggered.
<s>Sometimes the `Select-Select-Optimizer` property thinks that these
two queries should return the same thing:
```sql
SELECT (twinkling_winstanley.sensible_federations > x'66616e7461737469625e0f37879823db' AND twinkling_winstanley.sincere_niemeyer < -7428368947470022783) FROM twinkling_winstanley WHERE 1;

SELECT * FROM twinkling_winstanley WHERE twinkling_winstanley.sensible_federations > x'66616e7461737469625e0f37879823db' AND twinkling_winstanley.sincere_niemeyer < -7428368947470022783;
```
However after running the shrunk plan manually, the simulator was
incorrect in asserting that. Maybe this a bug a in the generation of
such a query? Not sure yet. </s>
<b>EDIT: The simulator was correctly catching a bug and I thought I was
the problem. The bug was in `exec_if` and I fixed it in this PR.</b>
I still need to expand the Unary Operator generation to other types of
predicates. For now, I just implemented it for `SimplePredicate` as I'm
trying to avoid to bloat even more this PR.
<b>EDIT: I decided to just have one PR open for all the changes I'm
making to make my life a bit easier and to avoid merge conflicts with my
own branches that I keep spawning for new code.</b>
PS: This should only be considered for merging after
https://github.com/tursodatabase/limbo/pull/1619 is merged. Then, I will
remove the draft status from this PR.

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

Closes #1674
2025-06-13 11:23:10 +03:00
PThorpe92
33b52bfb84 Replace refcel in wal sync, add counter timeout to conn close shutdown 2025-06-13 11:12:42 +03:00
PThorpe92
e134bd19da Remove close from Drop impl 2025-06-13 11:11:30 +03:00
PThorpe92
eecf6ae6e6 Wait till we write the page to increment current page in wal checkpoint 2025-06-13 11:11:30 +03:00
PThorpe92
9f966910bc Add manual wal sync before checkpoint in connection Drop 2025-06-13 11:11:30 +03:00
meteorgan
c0d260fd54 revise some comments 2025-06-13 10:39:36 +03:00
meteorgan
fd09675d8c clean up 2025-06-13 10:39:36 +03:00
meteorgan
6179d8de23 refactor compound select 2025-06-13 10:39:32 +03:00
Jussi Saurio
efed4bc07d Merge 'Complete ALTER TABLE implementation' from Levy A.
Resolves #895
- [x] `ALTER TABLE _ ADD _`
- [x] `ALTER TABLE _ DROP _`
- [x] `ALTER TABLE _ RENAME _ TO _`

Reviewed-by: Preston Thorpe (@PThorpe92)
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1527
2025-06-13 10:23:43 +03:00
Jussi Saurio
04c590f5a6 Add comment about re-entrancy of op_idx_insert() 2025-06-12 12:36:53 +03:00
Jussi Saurio
bdbd021bbb Fix large inserts to unique indexes hanging
We were incorrectly setting `moved_before` as `false` after checking
for unique constraint violation, but the reality is that after the
uniqueness check, we are already correctly positioned -- if no match
was found, the cursor is positioned at either:

a) no row, or
b) at the first entry that is greater than the key we are inserting.

This means we don't have to move anymore and can just insert.
2025-06-12 12:25:17 +03:00
pedrocarlo
8dbf09bb42 betters instrumentation for btree operations 2025-06-11 23:34:32 -03:00
Levy A.
5d60d82499 fix: add default 2025-06-11 14:19:06 -03:00
Levy A.
43db84e6ea fix: broken rebase 2025-06-11 14:19:06 -03:00
Levy A.
96e3f7bc5c refactor: remove magic number 2025-06-11 14:19:06 -03:00
Levy A.
8ecc561cd3 refactor: dereference impl Copy 2025-06-11 14:19:06 -03:00
Levy A.
e7ccb0b707 fix: prevent duplicate columns 2025-06-11 14:19:06 -03:00
Levy A.
e3da5a1f09 fix: clippy 2025-06-11 14:19:06 -03:00
Levy A.
3b36c3e771 refactor 2025-06-11 14:19:06 -03:00
Levy A.
01a680b69e feat(fuzz)+fix: add schema fuzz testing and fix some bugs 2025-06-11 14:19:06 -03:00
Levy A.
54e8e7f097 fix spacing 2025-06-11 14:19:06 -03:00
Levy A.
b88cb99ff0 fix warnings and some refactoring 2025-06-11 14:19:06 -03:00
Levy A.
1881cd04b5 chore: fmt 2025-06-11 14:19:06 -03:00
Levy A.
49a6ddad97 wip 2025-06-11 14:19:04 -03:00
Levy A.
c2f25b6a1d fix: proper identifier normalization and column constraints 2025-06-11 14:18:41 -03:00
Levy A.
0bb725899d fix: set is_rowid_alias 2025-06-11 14:18:41 -03:00
Levy A.
d65fe0f978 refactor: simplification and better names 2025-06-11 14:18:41 -03:00
Levy A.
a7761e431b fix: escape string literals 2025-06-11 14:18:41 -03:00
Levy A.
41cb13aa74 fix: ignore non-constants 2025-06-11 14:18:41 -03:00
Levy A.
15e0cab8d8 refactor+fix: precompute default values from schema 2025-06-11 14:18:39 -03:00
Levy A.
7638b0dab7 fix: use default value on empty columns added via ALTER TABLE 2025-06-11 14:18:19 -03:00
Levy A.
326a8b39db fix: default values not being converted to SQL 2025-06-11 14:17:36 -03:00
Levy A.
6945c0c09e fix+refactor: incorrect label placement
also added a `cursor_loop` helper on `ProgramBuilder` to avoid making
this mistake in the future. this is zero-cost, and will be optimized to
the same thing (hopefully).
2025-06-11 14:17:36 -03:00
Levy A.
3bc24eb86f feat: proper column definition parsing 2025-06-11 14:17:36 -03:00
Levy A.
587cf345cc refactor: merge branches 2025-06-11 14:17:36 -03:00
Levy A.
65b6984c2a fix: make sure to not modify a index 2025-06-11 14:17:36 -03:00
Levy A.
5f25ed0738 fix UNIQUE constraints 2025-06-11 14:17:36 -03:00
Levy A.
de2ac89ad2 feat: complete ALTER TABLE implementation 2025-06-11 14:17:36 -03:00
Pere Diaz Bou
9edbfa436a fmt again 2025-06-11 19:12:19 +02:00