Commit Graph

5774 Commits

Author SHA1 Message Date
Pekka Enberg
8d844c13da Merge 'stress: add a way to run stress with indexes enabled' from Jussi Saurio
Previously all constraints were disabled with an `if false {}` hack.
In this PR:
- enable PRIMARY KEYs and UNIQUE constraints if `experimental_indexes`
compile-time feature is enabled.
- Also enable PRIMARY KEY for exactly INTEGER columns, as INTEGER
PRIMARY KEY does not require an index
- NOT NULL constraint is also now enabled in both cases, as it doesn't
require an index

Closes #1981
2025-07-07 13:18:10 +03:00
Pekka Enberg
4aa987d65c Merge 'core/translate: Unify no such table error messages' from Pekka Enberg
We're now mixing different error messages, which makes compatibility
testing pretty hard. Unify on a single, SQLite compatible error message
"no such table".

Closes #1978
2025-07-07 13:17:59 +03:00
Jussi Saurio
0762c8f780 stress: add a way to run stress with indexes enabled 2025-07-07 13:04:52 +03:00
Pekka Enberg
7f91768ff6 core/translate: Unify no such table error messages
We're now mixing different error messages, which makes compatibility
testing pretty hard. Unify on a single, SQLite compatible error message
"no such table".
2025-07-07 11:10:46 +03:00
Pekka Enberg
99a23330a5 testing/glob.test: Run in-memory mode
Let's run the test case with in-memory mode to avoid the (unrelated) WAL
checksum errors that we're hitting.
2025-07-07 11:09:54 +03:00
Pekka Enberg
afa0052921 Merge 'sim: add feature flags (indexes,mvcc) to CLI args' from Jussi Saurio
Closes #1979
2025-07-07 10:58:21 +03:00
Jussi Saurio
ec939eaaa9 sim: add feature flags (indexes,mvcc) to CLI args 2025-07-07 10:27:15 +03:00
Pekka Enberg
34021134fe Fix Antithesis Docker image 2025-07-06 19:19:05 +03:00
Pekka Enberg
eb95ce89d1 Merge 'Fix ScalarFunc::Glob to handle NULL and other value types' from Krishna Vishal
Previously `ScalarFunc::Glob` only handled Text based values. After this
fix it will be able to handle all types of values.
Now:
```SQL
turso> CREATE TABLE IF NOT EXISTS  t0 (c0 REAL );

turso> UPDATE t0 SET c0='C2IS*24', c0=0Xffffffffbfc4330f, c0=0.6463854797956918 WHERE ((((((((t0.c0)AND(t0.c0)))AND(0.23913649834358142)))OR(CASE t0.c0  WHEN t0.c0 THEN 'j2' WHEN t0.c0 THEN t0.c0 WHEN t0.c0 THEN t0.c0 END)))OR(((((((((t0.c0)AND(t0.c0)))AND(t0.c0)))OR(t0.c0)))AND(t0.c0))));

turso> INSERT INTO t0 VALUES (NULL);
INSERT INTO t0 VALUES ('0&');
UPDATE t0 SET c0=2352448 WHERE ((((t0.c0)GLOB(t0.c0))) NOT NULL);
turso> SELECT * from t0;
┌───────────┐
│ c0        │
├───────────┤
│           │
├───────────┤
│ 2352448.0 │
└───────────┘
```
Fixes: https://github.com/tursodatabase/turso/issues/1953

Closes #1955
2025-07-06 10:51:54 +03:00
Krishna Vishal
f322ab7ab3 Add regression test 2025-07-06 13:18:21 +05:30
Krishna Vishal
fc8403991b Fix Glob ScalarFunc to handle NULL and other Value types.
Fixes: https://github.com/tursodatabase/turso/issues/1953
2025-07-06 13:18:21 +05:30
Pekka Enberg
169af0a23e Remove .editorconfig file 2025-07-06 10:44:49 +03:00
Pekka Enberg
5dfbe8db08 Merge 'bindings/java: Merge JavaScript test suites' from Mikaël Francoeur
I modified the `better-sqlite3.spec.mjs` test suite to use the dual test
runner from https://github.com/tursodatabase/turso/pull/1941 and I
deleted the `limbo.spec.mjs` test suite, because it's now redundant.
I looked carefully at the diff between the two test suites to make sure
that we didn't lose any coverage with this change.

Closes #1959
2025-07-06 10:44:35 +03:00
Pekka Enberg
bbf938041b Fix example in README.md
We currently have indexing disabled by default, which means non-rowid
primary keys are disabled too.

Fixs #1961
2025-07-06 10:37:49 +03:00
Pekka Enberg
a833f9e33a Merge 'Add multi select test in JDBC4StatementTest' from Kim Seon Woo
In reponse to [discord discussion](https://discord.com/channels/12586588
26257961020/1385754749634084885/1390535068401012858), I thought it would
be better to add a test to show how JDBC4Statement can be used.

Closes #1962
2025-07-06 10:15:15 +03:00
김선우
c8bb2e73ec Add multi select test in JDBC4StatementTest 2025-07-05 09:36:27 +09:00
Mikaël Francoeur
38c650380c fix nvim messup 2025-07-04 11:19:27 -04:00
Mikaël Francoeur
d8d26463db add new test 2025-07-04 11:18:47 -04:00
Mikaël Francoeur
4b1fdc457d fix typo 2025-07-04 11:17:24 -04:00
Mikaël Francoeur
a427751e3a merge js binding test suites 2025-07-04 10:13:05 -04:00
Pekka Enberg
c28c83fa2c Fix formatting in Cargo.toml 2025-07-04 12:54:58 +03:00
Pekka Enberg
b9bba101d4 Rename limbo_stress to turso_stress 2025-07-04 12:53:58 +03:00
Pekka Enberg
6e79a11dc7 Merge 'bindings/dart initial implementation' from Andika Tanuwijaya
re-upload

Closes #1911
2025-07-04 10:43:19 +03:00
Pekka Enberg
38c6183adf Merge 'bindings/javascript: Implement Database.open' from Lucas Forato
Reviewed-by: Diego Reis (@el-yawd)

Closes #1834
2025-07-04 10:28:50 +03:00
Pekka Enberg
793fa495e8 Merge 'Import JavaScript bindings test suite from libSQL' from Mikaël Francoeur
This PR imports the `sync` test suite from libSQL, and modifies the
export structure match `better-sqlite3`, so that at least a few tests
from the new test suite are passing.
I also changed the `package.json` to expose `wrapper.js` as an
entrypoint. I think the plain `index.js` was probably never meant to be
exposed directly to clients, because the wrapper does some important
transformation. It's also how libSQL-js is
[structured](https://github.com/tursodatabase/libsql-
js/blob/main/package.json#L20).
## DualTest test runner
The test suite that I imported was previously run twice, with different
environment variables: one run for libSQL-js, one run for better-
sqlite3. This worked well with libSQL, because it's compatible with
better-sqlite3. But Turso isn't there yet, so even though all tests need
to run on better-sqlite3, not all tests are passing on Turso.
To make it possible to run the test suite on both implementation, and to
make it possible to track the progress of Turso, I've added a `DualTest`
test runner that emulates the API of the Ava test runner, but instead of
a single `test()` function, it exposes two methods: `both()`, and
`onlySqlitePasses()`. The first one runs the test on both
implementations, and the second one also runs it on both, but expects
that Turso will fail.
When Turso is completely compatible with better-sqlite3, it will be easy
to remove the dual-test runner, since it has the same API as Ava.
## Future development
### Existing tests
The existing tests were divided in two files: `better-sqlite3.spec.mjs`,
and `dual-test.mjs` that are kept in sync manually. The first one is
mostly a superset of the second one, with additional tests indicating
behaviour that isn't implemented in Turso yet. I want to merge these
test suites to also use the dual-test test runner. This will make it
easier to evolve test suites and to track the progress of Turso.
### `SqliteError`
Modifying the test called `errors` to `both()` will show that Turso is
still missing an `SqliteError` type, to be compatible with better-
sqlite3. I have the required changes in a stash and will open a PR
shortly.
-----
as part of https://github.com/tursodatabase/turso/issues/1900

Closes #1941
2025-07-04 10:26:58 +03:00
Pekka Enberg
16a7416d0e cargo dist: s/limbo/turso/ 2025-07-04 10:13:50 +03:00
Pekka Enberg
f46bd6f40d Merge 'bindings/java: Rename to Turso' from Diego Reis
Closes #1936
2025-07-04 10:06:19 +03:00
Pekka Enberg
97ea4f1a80 Merge 'add libsql_disable_wal_checkpoint' from Pedro Muniz
Closes #1894

Closes #1920
2025-07-04 10:04:00 +03:00
Pekka Enberg
6a2404a3ff Merge 'Add a threshold for large page cache values' from Krishna Vishal
Added a threshold to clip input page cache size values to `0`. This
avoid the panic at runtime and also follow's SQLite behavior closely.
Now:
```
Turso v0.1.1
Enter ".help" for usage hints.
This software is ALPHA, only use for development, testing, and experimentation.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
turso> PRAGMA main.cache_size = 5022422913188235998;
turso> PRAGMA main.cache_size;
┌────────────┐
│ cache_size │
├────────────┤
│         10 │
└────────────┘
```
Closes: https://github.com/tursodatabase/turso/issues/1952

Closes #1954
2025-07-04 10:01:06 +03:00
Krishna Vishal
19d949521a Add a threshold to clip large page cache values to 0. This prevents
panic at runtime.
2025-07-04 10:24:10 +05:30
Mikaël Francoeur
50d542b719 expose wrapper and use default import 2025-07-03 15:19:03 -04:00
Mikaël Francoeur
6faa81034c add and adapt test suite from libsql 2025-07-03 15:19:03 -04:00
Pekka Enberg
1aad782271 Merge 'Antithesis schema rollback tests' from Pekka Enberg
Closes #1940
2025-07-03 21:28:17 +03:00
Pekka Enberg
c3e8bfab34 Merge 'Disable adaptive colors when output_mode is list' from meteorgan
As adaptive colors use `OSC 11` to query the terminal's background
color,  the query string may contaminate test result and cause failures
when running tests in a terminal.
```
 make test-vector

SQLITE_EXEC=scripts/limbo-sqlite3 ./testing/vector.test
(testing/testing.db)                        Running test: vector-functions-valid
Test FAILED: SELECT vector_extract(vector('[]'));
  SELECT vector_extract(vector('  [  1  ,  2  ,  3  ]  '));
  SELECT vector_extract(vector('[-1000000000000000000]'));
returned '[]
[1,2,3]
[-1000000000000000000]'
expected '[]
[1,2,3]
[-1000000000000000000]'
^[]11;rgb:158e/193a/1e75^[\make: *** [test-vector] Error 1
```

Closes #1942
2025-07-03 19:35:05 +03:00
Pekka Enberg
82a727bcf2 antithesis: Fix Python linter complaints in parallel_driver_schema_rollback.py 2025-07-03 19:34:23 +03:00
meteorgan
ccfee3f418 disable adaptive colors when output_mode is list 2025-07-03 23:31:51 +08:00
pedrocarlo
56d87cb916 move disable behavior to connection instead of checkpoint 2025-07-03 12:05:53 -03:00
pedrocarlo
3861584edc add test for wal checkpointing correctly 2025-07-03 12:04:17 -03:00
pedrocarlo
44b8275b26 add test + implement sqlite3_column_int64 for test 2025-07-03 12:04:17 -03:00
pedrocarlo
db005c81a0 add option to disable wal checkpoint 2025-07-03 12:04:17 -03:00
Diego Reis
4b32577f80 bind/java: Rename to Turso 2025-07-03 10:56:05 -03:00
Pekka Enberg
6a3042b5d4 antithesis: Add schema rollback parallel driver 2025-07-03 16:50:50 +03:00
Pekka Enberg
9303244f9d bindings/python: Explicit transaction control support 2025-07-03 16:50:21 +03:00
Pekka Enberg
603e57aff8 bindings/python: Fix ROLLBACK 2025-07-03 16:36:18 +03:00
Pekka Enberg
9e92325bad antithesis: Make experiments run for longer
...increases probability of Antithesis finding interesting things.
2025-07-03 15:58:49 +03:00
Pekka Enberg
90e035b6b0 Merge 'Rollback schema support' from Pere Diaz Bou
Fixes #1890
Once rollback was implement we quickly saw that it lacked support for
schema changes so we had to re-estructure things a bit.
## Example of failure:
```bash
turso> begin;
turso> create table t(x);
turso> rollback;
turso> pragma integrity_check;
thread 'main' panicked at core/storage/sqlite3_ondisk.rs:386:36:
called `Result::unwrap()` on an `Err` value: Corrupt("Invalid page type: 83")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
This happened because it thought table `t` existed because we didn't
rollback that schema.
## Changes:
* The most important change: now every connection has a private copy of
schema. On write txn commit we update a global schema shared between
connections in order for new connections to get updated version from
there. In case of rollback, we simply change connection's schema to
previous version. This change allowed us to remove locks for schema
private copy and keeping schema changes locally in case of concurrency.
 Sqlite does things differently, they lazily parse schema in case of
outdated schema, this many schema changes to trigger reading schema from
db file which is slow. If we are able to keep local copy in memory, even
when if we add multiprocessing, it will speed up schema reloading by a
bunch.
* `schema_cookie` is now update for every schema change
* `Insn::ParseSchema` had a nasty bug where it would commit all the
changes made in a query that changed a schema, we fixed that by setting
`auto_commit` to `false` before parsing schema, and setting it back to
previous value once schema is parsed.

Closes #1928
2025-07-03 14:18:00 +03:00
Pekka Enberg
1b3317e6c8 Merge 'core/storage: Switch to turso_assert in btree.rs' from Pekka Enberg
Let's help out Antithesis to find interesting bugs.

Closes #1937
2025-07-03 13:58:34 +03:00
Pere Diaz Bou
5eca507867 fix type null spacing 2025-07-03 12:53:15 +02:00
Pere Diaz Bou
2cfd209e56 clippy 2025-07-03 12:40:08 +02:00
Pere Diaz Bou
151debcb63 fix to_sql btreetable 2025-07-03 12:36:48 +02:00