Commit graph

628 commits

Author SHA1 Message Date
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
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
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
Levy A.
49a6ddad97 wip 2025-06-11 14:19:04 -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.
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.
6d0a3c95c6 more tests! 2025-06-11 14:17:36 -03:00
Levy A.
d8bc8c48c3 add constraint dropping tests 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
81d566cd1c integrity test with tcl 2025-06-11 18:39:06 +02:00
Anton Harniakou
4b0b119f70 Add UPDATE tests 2025-06-11 14:24:35 +03:00
Jussi Saurio
4794b022a5 Merge 'Fix incorrect handling of OR clauses in HAVING' from Jussi Saurio
thanks to @pedrocarlo for reminding me we have this old-ass bug I never
bothered to fix

Closes #1708
2025-06-10 18:14:39 +03:00
pedrocarlo
0da9d65d3e test 2025-06-10 12:07:38 -03:00
Jussi Saurio
18dd87eff1 Fix incorrect handling of OR clauses in HAVING 2025-06-10 18:02:14 +03:00
pedrocarlo
3e05496078 add integrity check to write tests 2025-06-09 17:44:00 -03:00
pedrocarlo
c7799c8ec5 add sleep to allow file lock to be removed 2025-06-09 16:29:58 -03:00
Anton Harniakou
f20e83eea1 Run tests in memory 2025-06-09 12:45:17 +03:00
Anton Harniakou
4b97d49f75 Rewrite tests using do_execsql_test_any_error
There's some kind of a bug unrelated to the feature
implemented,
which results in test different results between sqlite3 and limbo
if do_execsql_test_on_specific_db is used to get an error message content.

For example in limbo:
```sql
do_execsql_test_on_specific_db {:memory:} not_null_primary_key {
    CREATE TABLE t2 (y INT PRIMARY KEY NOT NULL);
    INSERT INTO t2 (y) VALUES (1);
    INSERT INTO t2 (y) VALUES (NULL);
    SELECT * FROM t2;
} {"Runtime error: NOT NULL constraint failed: t2.y (19)"
1} # notice the 1
```

And in sqlite3 we get
```sql
do_execsql_test_on_specific_db {:memory:} not_null_primary_key {
    CREATE TABLE t2 (y INT PRIMARY KEY NOT NULL);
    INSERT INTO t2 (y) VALUES (1);
    INSERT INTO t2 (y) VALUES (NULL);
    SELECT * FROM t2;
} {"Runtime error: NOT NULL constraint failed: t2.y (19)"} # notice the
absense of 1
```
therefore this commit rewrites tests to use do_execsql_test_any_error
instead.
2025-06-09 12:32:22 +03:00
Jussi Saurio
51abeca896 Add regression test for updating indexes 2025-06-09 08:51:23 +03:00
Jussi Saurio
9c9869f485 Merge 'Support sqlite_master schema table name alias' from Anton Harniakou
Related to #1641. Adds support for `sqlite_master` schema table name.

Reviewed-by: Diego Reis (@el-yawd)

Closes #1669
2025-06-09 08:23:58 +03:00
김선우
3b67130250 Add total_changes test 2025-06-07 17:37:36 +09:00
Anton Harniakou
8d141e5e21 Another error message fix 2025-06-06 13:06:59 +03:00
Anton Harniakou
0e4007c941 Fix contents of the NOT NULL error in tests 2025-06-06 12:59:58 +03:00
Anton Harniakou
5cd0614ac2 Test INSERT INTO with SELECT and VALUES (...), (...) syntax 2025-06-06 11:43:33 +03:00
Anton Harniakou
32b6555c5d Add tests for not null constraint 2025-06-06 10:55:49 +03:00
Anton Harniakou
d52c1461d5 Add tests 2025-06-06 08:55:08 +03:00
meteorgan
5da21fe275 add some tests for pragma cache_size 2025-06-05 17:17:21 +08:00
Pekka Enberg
c6ef19396d Merge 'Add support for pragma table-valued functions' from Piotr Rżysko
This PR adds support for table-valued functions for PRAGMAs (see the
[PRAGMA functions section](https://www.sqlite.org/pragma.html)).
Additionally, it introduces built-in table-valued functions. I
considered using extensions for this, but there are several reasons in
favor of a dedicated mechanism:
* It simplifies the use of internal functions, structs, etc. For
example, when implementing `json_each` and `json_tree`, direct access to
internals was necessary:
https://github.com/tursodatabase/limbo/pull/1088
* It avoids FFI overhead. [Benchmarks](https://github.com/piotrrzysko/li
mbo/blob/pragma_vtabs_bench/core/benches/pragma_benchmarks.rs) on my
hardware show that `pragma_table_info()` implemented as an extension is
2.5× slower than the built-in version.

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

Closes #1642
2025-06-04 09:08:10 +03:00
Jussi Saurio
06626f72eb Fix cursors not being opened for indexes in DELETE 2025-06-03 14:45:01 +03:00
Piotr Rzysko
d1d8ead475 Add support for pragma table-valued functions 2025-06-01 10:25:42 +02:00
pedrocarlo
39434fd20f return_io when restoring context 2025-06-01 03:07:16 -03:00
pedrocarlo
2ddbb7eeed adjust move_to and seek functions to make them truly reentrant + adding return_if_locked_maybe_load in some places so that we read loaded pages 2025-06-01 01:01:35 -03:00
pedrocarlo
d688cfd547 make find_cell and process_overflow_page reentrant 2025-05-31 23:31:59 -03:00
pedrocarlo
e97227ccb9 added delete operations to blobs in memory and write tests 2025-05-31 14:47:49 -03:00
Pere Diaz Bou
da4190a23e Convert u64 rowid to i64
Rowids can be negative, therefore let's swap to i64
2025-05-30 13:07:31 +02:00
Jussi Saurio
d52a9a635c fix: use tempfile as db path in constraint.py 2025-05-29 21:03:10 +03:00
Jussi Saurio
d18ab34193 Fix: dont pollute testing.db in insert tests 2025-05-29 20:51:29 +03:00
Pekka Enberg
1653bfb2b3 Merge 'Fix stress test to ignore unique constraint violation' from krishna sindhur
This should ignore unique constraint violation errors during the stress
test.

Closes #1606
2025-05-29 14:59:34 +03:00
krishna sindhur
4b66bcb2a7 fix: stress test will ignore unique constraint violation 2025-05-29 15:11:43 +05:30
Jussi Saurio
3d42f85c98 tests/python/writes: use tempfile instead of permanent file 2025-05-29 11:23:50 +03:00
meteorgan
86249d9c28 add more tests for pragma user_version 2025-05-28 00:47:09 +08:00
Jussi Saurio
b843ad0a58 Add INSERT INTO ... SELECT * FROM generate_series() regression test 2025-05-27 10:54:55 +03:00
pedrocarlo
1410e57112 correct union result_row or yield emission + test 2025-05-26 01:06:26 -03:00
pedrocarlo
ee93316c46 fix num_values detection + emitting correct column for temp_table + tests 2025-05-25 19:15:28 -03:00
pedrocarlo
90e3c8483d tests with compound select 2025-05-25 19:15:28 -03:00
pedrocarlo
c86e7542ec simple smoke tests 2025-05-25 19:13:40 -03:00
Jussi Saurio
d893a55c55 UNION 2025-05-25 21:23:04 +03:00