Commit graph

1201 commits

Author SHA1 Message Date
Preston Thorpe
b507c884ae
Merge 'Affinity fixes' from Pedro Muniz
Some checks are pending
Build & publish @tursodatabase/database / db-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Python / sdist (push) Waiting to run
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / cargo-fmt-check (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
## Description
Emits Affinity instruction in places SQLite also emits affinity
instructions.
<!--
Please include a summary of the changes and the related issue.
-->
## Motivation and context
Closes https://github.com/tursodatabase/turso/issues/4154
Closes #3481
Closes https://github.com/tursodatabase/turso/issues/3477
<!--
Please include relevant motivation and context.
Link relevant issues here.
-->
## Description of AI Usage
Ai generated with my prompting and guidance.
https://opncd.ai/share/EC7FRkwT
<!--
Please disclose how AI was used to help create this PR. For example, you
can share prompts,
specific tools, or ways of working that you took advantage of. You can
also share whether the
creation of the PR was mainly driven by AI, or whether it was used for
assistance.
This is a good way of sharing knowledge to other contributors about how
we can work more efficiently with
AI tools. Note that the use of AI is encouraged, but the committer is
still fully responsible for understanding
and reviewing the output.
-->

Closes #4300
2025-12-22 10:21:17 -05:00
pedrocarlo
3c782897b4 add tcl tests 2025-12-22 11:14:24 -03:00
pedrocarlo
6f93eba58a add affinity emission code for in list 2025-12-22 11:14:23 -03:00
pedrocarlo
5e691a74c8 delete the correct wal in turso cli test 2025-12-22 11:13:35 -03:00
Jussi Saurio
92e78466c9
Merge 'tcl: run PRAGMA journal_mode=experimental_mvcc with mvcc' from Pere Diaz Bou
## Description
run PRAGMA journal_mode=experimental_mvcc with mvcc
## Motivation and context
After https://github.com/tursodatabase/turso/pull/4294 we need a way run
with mvcc mode.
## Description of AI Usage
it wrote the remove first line

Closes #4298
2025-12-22 15:08:28 +02:00
Pekka Enberg
f598dfa13d
Merge 'core/mvcc: set_null_flag(false) when seek is called' from Pere Diaz Bou
Some checks are pending
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
## Description
BTreeCursor sets null flag to false once `seek` is called. This PR does
the same for MVCC
## Motivation and context
join.test failed with some cases due to this bug
## Description of AI Usage
I asked AI to find the issue but I ended showing the agent why he did
things wrong and that he should be ashamed

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

Closes #4296
2025-12-22 09:15:24 +02:00
Preston Thorpe
d6ceda8dcb
Merge 'fix(core/translate): apply affinity conversion to hash join build and probe keys' from Nuno Gonçalves
## Description
This PR adds missing affinity conversion to hash joins by applying
affinity conversion to build and probe keys before hashing.
```
turso> CREATE TABLE x(a INTEGER);
turso> CREATE TABLE y(b TEXT);
turso> INSERT INTO x VALUES (2),(3);
turso> INSERT INTO y VALUES ('02'),('2'),('2.0'),('3x'),('3.5');
turso> SELECT a, b
  FROM x JOIN y ON a = b
  ORDER BY a, b;
┌───┬─────┐
│ a │ b   │
├───┼─────┤
│ 2 │ 02  │
├───┼─────┤
│ 2 │ 2   │
├───┼─────┤
│ 2 │ 2.0 │
└───┴─────┘
```
## Motivation and context
Fixes #3482.
Currently, Turso returns an empty result set:
```
turso> CREATE TABLE x(a INTEGER);
turso> CREATE TABLE y(b TEXT);
turso> INSERT INTO x VALUES (2),(3);
turso> INSERT INTO y VALUES ('02'),('2'),('2.0'),('3x'),('3.5');
turso> SELECT a, b
  FROM x JOIN y ON a = b
  ORDER BY a, b;
turso>
```
Expected behavior:
```
sqlite> CREATE TABLE x(a INTEGER);
sqlite> CREATE TABLE y(b TEXT);
sqlite> INSERT INTO x VALUES (2),(3);
sqlite> INSERT INTO y VALUES ('02'),('2'),('2.0'),('3x'),('3.5');
sqlite> SELECT a, b
   ...>   FROM x JOIN y ON a = b
   ...>   ORDER BY a, b;
2|02
2|2
2|2.0
```
## Description of AI Usage
This PR was developed with assistance from Claude Sonnet 4.5 through
code completions.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #4317
2025-12-21 21:08:29 -05:00
PThorpe92
9954b096cc
Set all testing dbs to WAL journal mode 2025-12-21 21:02:02 -05:00
Nuno Gonçalves
1b386147c1 fix(core/translate): apply affinity conversion to hash join build and probe keys 2025-12-21 16:59:46 +00:00
Preston Thorpe
71944c9d49
Merge 'Revert "Merge 'fix stack overflow in long unary expressions' from "' from Jussi Saurio
This reverts commit b40cdb1bfd, reversing
changes made to cd22c4dc48.
Closes #4306
Closes #4302
Reopens #4197

Closes #4307
2025-12-20 13:43:40 -05:00
Preston Thorpe
a10051dde4
Merge 'Fix RTRIM ignoring trailing tabs' from Krishna Vishal
`str::trim_end()` removes trailing tabs too. Replaced it with
`trim_end_matches(' ')`. Rust `str::trim` functions seem problematic
because they remove non-ascii whitespace and others.
Behavior now:
```
turso> select 'x' || char(9) = 'x' collate rtrim;
┌─────────────────────────────────────┐
│ 'x' || char (9) = 'x' COLLATE rtrim │
├─────────────────────────────────────┤
│                                   0 │
└─────────────────────────────────────┘
```
Closes: #3480

Reviewed-by: Mikaël Francoeur (@LeMikaelF)

Closes #3891
2025-12-20 10:33:59 -05:00
Preston Thorpe
90e6ed0ba4
Merge 'Fix incorrect conversion from TEXT to INTEGER when text is a number followed by a trailing non-breaking space' from Krishna Vishal
This PR fixes incorrect conversion from TEXT to INTEGER when text is a
number followed by a trailing non-breaking space.
This happens because `str::trim()` trims non-breaking space and unicode
whitespace while SQLite only trims ASCII whitespace.
Closes: https://github.com/tursodatabase/turso/issues/3679

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #3878
2025-12-20 10:33:15 -05:00
Jussi Saurio
3428359a73 Revert "Merge 'fix stack overflow in long unary expressions' from "
This reverts commit b40cdb1bfd, reversing
changes made to cd22c4dc48.
2025-12-20 10:09:34 +02:00
Nuno Gonçalves
21268632eb fix(core): prevent ALTER COLUMN from resulting in tables with only generated columns 2025-12-19 21:52:36 +00:00
Preston Thorpe
b40cdb1bfd
Merge 'fix stack overflow in long unary expressions' from
## Description
<!--
Please include a summary of the changes and the related issue.
-->
This PR fixes https://github.com/tursodatabase/turso/issues/4197 by
collapsing `+` and `-` operators in unary expressions.
## Motivation and context
<!--
Please include relevant motivation and context.
Link relevant issues here.
-->
By collapsing `+` and `-` operators in unary expressions, we're able to
prevent stack overflow in very long unary expressions. The following
queries can be used to test this change:
```sql
select +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++123;

select - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -123;

select +++++++++++++++++++++++++++++++++++++++++++++++++++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+123;
```
All of the queries above crashes with a stack overflow error prior to
this fix.
## Description of AI Usage
No AI was used in this PR.
<!--
Please disclose how AI was used to help create this PR. For example, you
can share prompts,
specific tools, or ways of working that you took advantage of. You can
also share whether the
creation of the PR was mainly driven by AI, or whether it was used for
assistance.
This is a good way of sharing knowledge to other contributors about how
we can work more efficiently with
AI tools. Note that the use of AI is encouraged, but the committer is
still fully responsible for understanding
and reviewing the output.
-->

Reviewed-by: Mikaël Francoeur (@LeMikaelF)

Closes #4273
2025-12-19 14:41:45 -05:00
Pere Diaz Bou
c98f9efbfe tcl: run PRAGMA journal_mode=experimental_mvcc with mvcc 2025-12-19 17:06:07 +01:00
Pere Diaz Bou
fe94cfc175 core/mvcc: set_null_flag(false) when seek is called 2025-12-19 16:47:33 +01:00
Pere Diaz Bou
2dec8a6e00
Merge ' core/execute: use same code for generating rowid in mvcc as in btree' from Pere Diaz Bou
## Description
in `op_new_rowid` we already have code logic that encodes how to get the
last rowid correctly, this PR uses advantage of it in MVCC too but with
a few `lock` guards in place to not collide rowids
## Motivation and context
It is hard to maintain two ways of getting a new rowid so this tries to
fold mvcc with btree
## Description of AI Usage
None

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

Closes #4228
2025-12-19 16:45:27 +01:00
Pekka Enberg
edd45ff7b8 Improve MVCC DX by dropping --experimental-mvcc flag
The DX is right now pretty terrible:

```
penberg@vonneumann turso % cargo run -- hello.db
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/tursodb hello.db`
Turso v0.4.0-pre.18
Enter ".help" for usage hints.
Did you know that Turso supports live materialized views? Type .manual materialized-views to learn more.
This software is in BETA, use caution with production data and ensure you have backups.
turso> PRAGMA journal_mode = 'experimental_mvcc';
  × Invalid argument supplied: MVCC is not enabled. Enable it with `--experimental-mvcc` flag in the CLI or by setting the MVCC option in `DatabaseOpts`

turso>
```

To add insult to the injury, many SDKs don't even have a way to enable
MVCC via database options. Therefore, let's remove the flag altogether.
2025-12-19 12:59:42 +02:00
Pere Diaz Bou
3141c067ed tcl: exclude partial index for mvcc tcl tests 2025-12-19 10:43:22 +01:00
Krishna Vishal
173baa7e0e Add tests 2025-12-19 08:53:58 +05:30
Jussi Saurio
37a8897bc6
Merge 'triggers: don't rewrite qualified table names' from Pavan Nambi
## Description
closes https://github.com/tursodatabase/turso/issues/4142
<!--
Please include a summary of the changes and the related issue.
-->
## Motivation and context
compatibility, we were  wrongly rewriting table qualified cols, also
added trigger.test to all.test and expect correct values in a test
<!--
Please include relevant motivation and context.
Link relevant issues here.
-->
## AI Disclosure
None
<!--
Please disclose if any LLM's were used in the creation of this PR and to
what extent,
to help maintainers properly review.
-->

Closes #4206
2025-12-18 09:26:46 +02:00
ziord
b6d7144087 add tests 2025-12-17 19:51:57 -05:00
PThorpe92
db60db7d9b
impl cache spilling in pager 2025-12-17 11:57:34 -05:00
Pere Diaz Bou
77841042d0
Merge 'Consider Order by expressions collation when deciding candidate index for iteration' from Pedro Muniz
## Description
Does solve #4154, but I don't want to close it with this PR, because it
does not solve the Affinity issue.
We can only use an index to iterate over if the column collation in the
order by clause matches the index collation
<!--
Please include a summary of the changes and the related issue.
-->
## Motivation and context
Fix a bug in the optimizer
<!--
Please include relevant motivation and context.
Link relevant issues here.
-->
## Description of AI Usage
Used AI to write tests, fuzzers, and help me understand the optimizer
code.
Test prompt:
<details>
can you write tests in tcl that test that the correct collation sequence
is properly maintained.
```
CREATE TABLE "t1" ("c1" TEXT COLLATE RTRIM);
INSERT INTO "t1" VALUES (' ');
CREATE INDEX "i1" ON "t1" ("c1" COLLATE RTRIM DESC);
INSERT INTO "t1" VALUES (1025.1655084065987);
SELECT "c1", typeof(c1) FROM "t1" ORDER BY "c1" COLLATE BINARY DESC, rowid ASC; 
```
this is an example of a query that returned incorrect results because of
this
</details>
<!--
Please disclose how AI was used to help create this PR. For example, you
can share prompts,
specific tools, or ways of working that you took advantage of. You can
also share whether the
creation of the PR was mainly driven by AI, or whether it was used for
assistance.
This is a good way of sharing knowledge to other contributors about how
we can work more efficiently with
AI tools. Note that the use of AI is encouraged, but the committer is
still fully responsible for understanding
and reviewing the output.
-->

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #4248
2025-12-17 14:26:25 +01:00
Pere Diaz Bou
f397481039
Merge 'use cmath from system libraries only in tests in order to be more portable' from Nikita Sivukhin
- not all systems has cmath functions which we import from system
libraries
- let's use external implementation only in tests in order to eliminate
precision errors in the differential tests
- https://discord.com/channels/933071162680958986/933071163184283651/145
0476358005293147

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

Closes #4246
2025-12-17 13:22:57 +01:00
Pere Diaz Bou
996c92ccd3
Merge 'fix(json): properly serialize infinite values' from Nuno Gonçalves
## Description
This PR fixes the JSON serialization of infinite floating-point values,
as reported in #4196. Previously, converting `f64::INFINITY` or
`f64::NEG_INFINITY` to JSON produced a parse error because the `ryu`
crate formats infinity as `"inf"`, which is not valid JSON.
The implementation now correctly serializes infinite values to match
SQLite's behavior, which varies depending on the JSON function used:
- For `json_array()` and `json_object()` with float arguments:
```
turso> create table t(a);
turso> insert into t values (1e309);
turso> insert into t values (-1e309);
turso> select json_object('k', a) from t;
┌────────────────────────┐
│ json_object ('k', t.a) │
├────────────────────────┤
│ {"k":9.0e+999}         │
├────────────────────────┤
│ {"k":-9.0e+999}        │
└────────────────────────┘
turso> select json_array(a) from t;
┌──────────────────┐
│ json_array (t.a) │
├──────────────────┤
│ [9.0e+999]       │
├──────────────────┤
│ [-9.0e+999]      │
└──────────────────┘
```
- For `json()` with bare infinity or JSON5 text containing infinity:
```
turso> select json(a) from t;
┌────────────┐
│ json (t.a) │
├────────────┤
│ 9e999      │
├────────────┤
│ -9e999     │
└────────────┘
turso> SELECT json('{x: Infinity}');
┌────────────────────────┐
│ json ('{x: Infinity}') │
├────────────────────────┤
│ {"x":9e999}            │
└────────────────────────┘
```
## Motivation and context
Fixes #4196.
Currently, Turso produces a parse error when serializing infinite
values:
```
turso> create table t(a);
turso> insert into t values (1e309);
turso> insert into t values (-1e309);
turso> select json_object('k', a) from t;
  × Parse error: malformed JSON

turso> select json_array(a) from t;
  × Parse error: malformed JSON

turso> select json(a) from t;
  × Parse error: malformed JSON

turso> SELECT json('{x: Infinity}');
┌────────────────────────┐
│ json ('{x: Infinity}') │
├────────────────────────┤
│ {"x":9e999}            │
└────────────────────────┘
```
SQLite handles this differently, infinite floating-point values are
serialized using the notations `9.0e+999` and `9e999`, depending on the
JSON function:
```
sqlite> create table t(a);
sqlite> insert into t values (1e309);
sqlite> insert into t values (-1e309);
sqlite> select json_object('k', a) from t;
{"k":9.0e+999}
{"k":-9.0e+999}
sqlite> select json_array(a) from t;
[9.0e+999]
[-9.0e+999]
sqlite> select json(a) from t;
9e999
-9e999
sqlite> SELECT json('{x: Infinity}');
{"x":9e999}
```
## AI Disclosure
This PR was developed with assistance from GitHub Copilot (Claude Sonnet
4.5). The AI helped identify the root cause and assisted in writing the
unit tests.

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

Closes #4209
2025-12-17 13:22:37 +01:00
Nikita Sivukhin
21d7f959e5 remove mod(x, y) function tests which are "unstable" at the argument boundaries
- for x = +-y the value of mod depends a lot on the calculation precision
- for example, atanh(tanh(-1.0)) should be evaluated to -1 but due to precision issues it can be approximately 1
- due to the, value of mod(atanh(tanh(-1.0)), 1.0) will be either approximately -1 or 0 - which is tremendous difference which affect the tests
2025-12-17 14:42:10 +04:00
Nuno Gonçalves
def244e380 fix(core/util): reject integer primary key underflow 2025-12-16 23:49:08 +00:00
pedrocarlo
e20018e78c add tcl tests for collate 2025-12-16 13:11:03 -03:00
Pavan-Nambi
ac7d3597ff
don't rewrite qualified table names 2025-12-16 16:45:40 +05:30
Nuno Gonçalves
f21387efe7 fix(json): properly serialize infinite values 2025-12-16 10:15:29 +00:00
Preston Thorpe
1bcb14f9c5
Merge 'feat(hash-join): add hash matching for equivalent integer and real values' from Nuno Gonçalves
## Description
This PR adds hash matching for equivalent integer and real values in
hash joins. This is achieved by ensuring that integer/real equivalents
(including signed zeros) share the same hash in internal bloom filters
and hash tables.
```
turso> CREATE TABLE IF NOT EXISTS t1 (a INTEGER, b INTEGER);
CREATE TABLE IF NOT EXISTS t2 (a INTEGER, c REAL);
INSERT INTO t1 (a, b) VALUES (1, NULL), (2, 10);
INSERT INTO t2 (a, c) VALUES (1, 10.0), (3, NULL);
SELECT * FROM t1 LEFT JOIN t2 ON t1.b = t2.c;
┌───┬────┬───┬──────┐
│ a │ b  │ a │ c    │
├───┼────┼───┼──────┤
│ 1 │    │   │      │
├───┼────┼───┼──────┤
│ 2 │ 10 │ 1 │ 10.0 │
└───┴────┴───┴──────┘
```
## Motivation and context
This change fixes the `LEFT JOIN` mismatch reported in #4147, where
joins on numerically equal `INTEGER` and `REAL` values failed in Turso
but succeeded in SQLite:
```
turso> CREATE TABLE IF NOT EXISTS t1 (a INTEGER, b INTEGER);
CREATE TABLE IF NOT EXISTS t2 (a INTEGER, c REAL);
INSERT INTO t1 (a, b) VALUES (1, NULL), (2, 10);
INSERT INTO t2 (a, c) VALUES (1, 10.0), (3, NULL);
SELECT * FROM t1 LEFT JOIN t2 ON t1.b = t2.c;
┌───┬────┬───┬───┐
│ a │ b  │ a │ c │
├───┼────┼───┼───┤
│ 1 │    │   │   │
├───┼────┼───┼───┤
│ 2 │ 10 │   │   │
└───┴────┴───┴───┘
```
```
sqlite> CREATE TABLE IF NOT EXISTS t1 (a INTEGER, b INTEGER);
sqlite> CREATE TABLE IF NOT EXISTS t2 (a INTEGER, c REAL);
sqlite> INSERT INTO t1 (a, b) VALUES (1, NULL), (2, 10);
sqlite> INSERT INTO t2 (a, c) VALUES (1, 10.0), (3, NULL);
sqlite> SELECT * FROM t1 LEFT JOIN t2 ON t1.b = t2.c;
1|||
2|10|1|10.0
```
Fixes #4147.
## Description of AI Usage
This PR was developed with assistance from GPT-5.1 Codex Max. The AI
helped analyze the hash join–related codebase (including bloom filters
and hash table implementations), identify the root cause of the issue,
and assist in writing the tests.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #4226
2025-12-15 20:58:32 -05:00
pedrocarlo
adee0e11d6 simplify tokenization of cli sql 2025-12-15 16:54:00 -03:00
pedrocarlo
03108d42a0 remove 1 csv test that is not allowed in the sqlite cli 2025-12-15 16:54:00 -03:00
Nuno Gonçalves
c58c710f17 feat(hash-join): add hash matching for equivalent integer and real values 2025-12-15 15:25:50 +00:00
Pere Diaz Bou
f69cee9dd9 core/mvcc/cursor: return previous max id 2025-12-15 16:15:36 +01:00
Jussi Saurio
0887ebef7d Merge 'ci: run TCL tests for MVCC under CI' from Pere Diaz Bou
Some checks are pending
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
## Description
Run TCL tests for MVCC in the CI. Right now almost everything is
commented out as we need to fix them.
## AI Disclosure
No
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds CI step to run MVCC TCL tests via a custom sqlite wrapper with
experimental flags, and narrows the MVCC test suite to known passing
tests.
>
> - **CI**:
>   - Add `Test mvcc` step in `test-limbo` job to run `make test-compat-
mvcc` in `.github/workflows/rust.yml`.
> - **Makefile**:
>   - Update `test-compat-mvcc` to use `SQLITE_EXEC=scripts/turso-mvcc-
sqlite3`.
> - **Test Runner Script** (`scripts/turso-mvcc-sqlite3`):
>   - Enable experimental flags: `--experimental-mvcc`, `--experimental-
views`, `--experimental-strict`.
> - **Tests**:
>   - Define `testing/all-mvcc.test` with a subset of passing test
files; comment out failing ones.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ee48302e30. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

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

Closes #4178
2025-12-11 23:39:05 +02:00
Jussi Saurio
e67cc999f3 Add run-sqlancer.sh script to run sqlancer using Turso java bindings 2025-12-11 17:18:11 +02:00
Jussi Saurio
82fbc3e0fa fix: INSERT OR IGNORE with NOT NULL constraint failure 2025-12-11 17:18:11 +02:00
Pere Diaz Bou
e048a48bee ci: run TCL tests for MVCC under CI 2025-12-11 11:57:32 +01:00
Preston Thorpe
fd2a03dbdc
Merge 'fix: JSON_INSERT now correctly inserts new keys in nested objects' from Mikaël Francoeur
Some of the tests that were added pass only on this branch. I was
surprised to see that there didn't seem to be any TCL tests for
`json_insert()`.
## AI-generated description
When using JSON_INSERT with a path like '$.a.b.d' on an object like
'{"a": {"b": {"c": 5}}}', the function was incorrectly returning the
input unchanged instead of inserting the new key.
The root cause was that InsertNew mode was being applied to all path
segments. The fix uses Upsert mode for intermediate segments and only
applies InsertNew for the final segment.
🤖 Generated with [Claude Code](https://claude.com/claude-code), and
cleaned up by Mikaël
## AI Disclosure
This was written by Claude, and then I cleaned it up manually.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #4166
2025-12-10 14:55:07 -05:00
Mikaël Francoeur
b3f0947acd
fix: JSON_INSERT now correctly inserts new keys in nested objects
When using JSON_INSERT with a path like '$.a.b.d' on an object like
'{"a": {"b": {"c": 5}}}', the function was incorrectly returning the
input unchanged instead of inserting the new key.

The root cause was that InsertNew mode was being applied to all path
segments. The fix uses Upsert mode for intermediate segments and only
applies InsertNew for the final segment.

🤖 Generated with [Claude Code](https://claude.com/claude-code), and cleaned up by Mikaël
2025-12-10 13:58:58 -05:00
PThorpe92
bb7b8aa935
Add/expand tcl tests for analyze 2025-12-09 20:02:07 -05:00
PThorpe92
fe38b006f7
Update analyze TCL tests 2025-12-09 14:46:12 -05:00
Preston Thorpe
9e75e23eb6
Merge 'feat: adding check for unquoted literals in values()' from Rohith Suresh
Some checks are pending
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Python / configure-strategy (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Closes #3949
Closes #4018
```
turso> values(asdf);
  × Parse error: Unquoted identifier in VALUES clause: asdf
  
turso> select * from users;
┌────┬──────┐
│ id │ name │
├────┼──────┤
│  1 │ jack │
├────┼──────┤
│  2 │ jill │
└────┴──────┘
  turso> select id, (values(name)) as name_again from users;
┌────┬────────────┐
│ id │ name_again │
├────┼────────────┤
│  1 │ jack       │
├────┼────────────┤
│  2 │ jill       │
└────┴────────────┘
```

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #4003
2025-12-09 10:15:11 -05:00
Jussi Saurio
0156fa55b6
Merge ' tcl,makefile: add tcl test infraestructure for mvcc ' from Pere Diaz Bou
The idea is to have a custom `all-mvcc.test` so we can add `.test` files
that we expect to work with MVCC. In cases where files are not enough we
have  `is_turso_mvcc` to check if we want to run a test.
For example we skip partial index tests like this:
```
if {![is_turso_mvcc]} {
    do_execsql_test_on_specific_db {:memory:} autoinc-conflict-on-nothing {
        CREATE TABLE t (id INTEGER PRIMARY KEY AUTOINCREMENT, k TEXT);
        CREATE UNIQUE INDEX idx_k_partial ON t(k) WHERE id > 1;
        INSERT INTO t (k) VALUES ('a');
        INSERT INTO t (k) VALUES ('a');
        INSERT INTO t (k) VALUES ('a') ON CONFLICT DO NOTHING;
        INSERT INTO t (k) VALUES ('b');
        SELECT * FROM t ORDER BY id;
    } {1|a 2|a 4|b}
}
```
`test-mvcc-compat` is not run under CI for now as we need to fix every
test anyways so no point in making every PR fail for now.

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

Closes #4139
2025-12-09 09:40:20 +02:00
Pere Diaz Bou
c5f6c3d5c0 tcl,makefile: add tcl test infraestructure for mvcc 2025-12-08 18:05:45 +01:00
Jussi Saurio
027ebe33fe Fix descending index scan returning rows when seek key is NULL
Take e.g.

CREATE TABLE t(x); CREATE INDEX txdesc ON t(x desc);
INSERT INTO t values (1),(2),(3);

SELECT * FROM t WHERE x > NULL;

--

Our plan, like Sqlite, was to start iterating the descending index
from the beginning (Rewind) and stop once we hit a row where x is
<= than NULL using `IdxGe` instruction (GE in descending indexes
means LE).

However, `IdxGe` and other similar instructions use a sort comparison
where NULL is less than numbers/strings etc, so this would incorrectly
not jump.

Fix: we need to emit an explicit NULL check after rewinding.
2025-12-08 13:19:58 +02:00
Jussi Saurio
40898b8cf9
Merge 'Added dot product vector distance' from Tejas
Closes #3826
This PR adds dot product distance implementation.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #4055
2025-12-08 06:24:39 +02:00