Commit Graph

10339 Commits

Author SHA1 Message Date
Pekka Enberg
e3ec4f7ea2 sql_generation: Add support for predefined columns 2025-10-17 10:47:07 +03:00
Pekka Enberg
2d05d062b2 Merge 'antithesis-tests: don't create CHECK constraints' from Jussi Saurio
we don't support them, and we just started returning parse errors for
trying to do so -> failures in antithesis runs

Closes #3763
2025-10-17 10:46:23 +03:00
Pekka Enberg
62fff37ea6 Merge 'stress: prevent thread from holding write lock and then stopping' from Jussi Saurio
When a stress thread runs out of work, execute COMMIT and ignore the
result.
This prevents the currently extremely common scenario where:
- Thread x does BEGIN
- Thread x does e.g. INSERT ...
Then runs out of iterations and stops. No other threads can write
anything and they just wait for 5 seconds (busy timeout) and then try
again, forever.
Closes #3697

Closes #3762
2025-10-17 09:36:51 +03:00
Jussi Saurio
d187be74a5 antithesis-tests: don't create CHECK constraints
we don't support them, and we just started returning parse errors for
trying to do so -> failures in antithesis runs
2025-10-17 09:25:06 +03:00
Jussi Saurio
56e9ba9eae Merge 'WAL: don't hold shared lock across IO operations' from Jussi Saurio
Without this change and running:
```
cd stress
while cargo run -- --nr-threads=4 -i 1000 --verbose --busy-timeout=0; do; done
```
I can produce a deadlock quite reliably.
With this change, I can't.
Even with 5 second busy timeout (the default), the run makes progress
although it is slow as hell because of the busy timeout.
Full disclosure: i couldn't figure out based on parking lot RwLock
semantics why this would fix it, so maybe it just lessens the
probability

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

Closes #3759
2025-10-17 08:50:26 +03:00
Jussi Saurio
bae3a42564 stress: prevent thread from holding write lock and then stopping
When a stress thread runs out of work, execute COMMIT and ignore
the result.

This prevents the currently extremely common scenario where:

- Thread x does BEGIN
- Thread x does e.g. INSERT ...

Then runs out of iterations and stops. No other threads can write
anything and they just wait for 5 seconds (busy timeout) and then
try again, forever.
2025-10-17 08:47:40 +03:00
Preston Thorpe
a82e8c9c23 Merge 'translate/select: prevent multiple identical non-aliased table references ' from Preston Thorpe
closes https://github.com/tursodatabase/turso/issues/3505

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

Closes #3761
2025-10-16 19:03:23 -04:00
PThorpe92
ddd674c340 Move duplicate table identifier checking to parse_join to allow for natural joins 2025-10-16 18:32:48 -04:00
PThorpe92
79c5234122 Add TCL test for self ambiguous join 2025-10-16 16:43:08 -04:00
PThorpe92
10c69b910e Prevent ambiguous self-join table reference 2025-10-16 16:39:10 -04:00
Preston Thorpe
119984d98b Merge 'Prevent on conflict column definitions on CREATE TABLE or opening DB' from Preston Thorpe
more parse errors!

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

Closes #3760
2025-10-16 16:22:40 -04:00
PThorpe92
edaa1b675e Prevent column definitions on CREATE TABLE or opening DB with ON CONFLICT on column def 2025-10-16 15:45:20 -04:00
Preston Thorpe
563c67dfea Merge 'core/translate: throw parse error on unsupported GENERATED column constraints' from Preston Thorpe
similar to #3755, we do this for #3749

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

Closes #3758
2025-10-16 15:41:39 -04:00
Jussi Saurio
2ca388d78d WAL: don't hold shared lock across IO operations
Without this change and running:

```
cd stress
cargo run -- --nr-threads=4 -i 1000 --verbose --busy-timeout=0
```

I can produce a deadlock quite reliably.

With this change, I can't.

Even with 5 second busy timeout (the default), the run makes progress although it is slow as hell because of the busy timeout.
2025-10-16 22:00:01 +03:00
PThorpe92
9de9927b52 fix clippy warning 2025-10-16 14:47:40 -04:00
PThorpe92
04c9eee4f1 Throw parse error on GENERATED constraint when creating new table 2025-10-16 14:27:22 -04:00
PThorpe92
75e86b2c20 Throw parse error on GENERATED constraint in create table when opening new db 2025-10-16 14:26:58 -04:00
Preston Thorpe
b31908fe99 Merge 'translate/select: Fix rewriting Rowid expression when no btree table exists in joined table refs ' from Preston Thorpe
closes https://github.com/tursodatabase/turso/issues/3667

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

Closes #3754
2025-10-16 14:22:51 -04:00
Preston Thorpe
06dc2b5376 Merge 'Throw parse error on CHECK constraint in create table' from Preston Thorpe
RE: https://github.com/tursodatabase/turso/issues/3753
Let's throw parse error until this feature is supported.
Should we throw parse error if we open a DB up that has CHECK
constraints on the columns?

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

Closes #3755
2025-10-16 14:22:21 -04:00
PThorpe92
959df4c4bc Add TCL test for rowid from clause subquery panic 2025-10-16 13:40:10 -04:00
PThorpe92
e417188cb2 Fix panic when selecting explicit rowid from FROM clause subquery 2025-10-16 13:40:01 -04:00
PThorpe92
f033af4a93 Throw parse error on CHECK constraint in create table when opening new db 2025-10-16 13:30:05 -04:00
PThorpe92
bd33b3fa83 Throw parse error on CHECK constraint in create table 2025-10-16 13:07:12 -04:00
Pekka Enberg
9d4813df04 Reduce Antithesis runtime to 4 hours 2025-10-16 19:00:40 +03:00
Preston Thorpe
79e4176163 Merge 'cli: .tables and .indexes to show data from attached tables aswell' from Konstantinos Artopoulos
Closes #3545

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

Closes #3627
2025-10-16 11:42:29 -04:00
Pekka Enberg
6e34c505e1 Fix build after I/O many completions removal 2025-10-16 17:19:16 +03:00
Jussi Saurio
44fa0a4f6e Merge 'bindings/rust: propagate the DropBehavior of a dropped tx to next access of DB, instead of panicing' from Jussi Saurio
Closes #3748
Right now if any error happens during an interactive tx that causes the
`Transaction` to drop, the program will panic.
To prevent this, we store the `DropBehavior` of the transaction on the
`Connection` when it drops and issue the corresponding action (ROLLBACK
/ COMMIT / IGNORE / PANIC) the next time `Connection` is used to access
the database. This defaults to `IGNORE`.
I don't know how good this solution is, but we can at least prevent a
panic by storing whether the connection has a dangling transaction and
roll it back automatically the next time the connection tries to do
something.

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

Closes #3750
2025-10-16 17:18:31 +03:00
Pekka Enberg
afa89c66c0 Merge 'Replace io_yield_many with completion groups' from Pekka Enberg
Reviewed-by: Pedro Muniz (@pedrocarlo)

Closes #3703
2025-10-16 17:17:43 +03:00
Pekka Enberg
08cd93caca Merge 'core/bree: remove duplicated code in BTreeCursor' from Pere Diaz Bou
Forgot to remove some functions from BTreeCursor moved to CursorTrait.

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

Closes #3751
2025-10-16 17:05:50 +03:00
Jussi Saurio
a1b6eafd03 Merge 'Fix: rolling back tx on Error should set autocommit to true' from Jussi Saurio
Rolling back a transaction on Error should result in
`connection.auto_commit` being set back to true.
Added a regression test for this where a UNIQUE constraint violation
rolls back the transaction and trying to COMMIT will fail.
Currently, our default conflict resolution strategy is ROLLBACK, which
ends the transaction. In SQLite, the default is ABORT, which rolls back
the current statement but allows the transaction to continue.
We should migrate to default ABORT once we support subtransactions.
Closes #3746

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

Closes #3747
2025-10-16 16:55:54 +03:00
Jussi Saurio
7728f3ab58 Update DropBehavior related documentation to reflect reality 2025-10-16 16:40:02 +03:00
Jussi Saurio
3929322061 Propagate DropBehavior to dangling_tx so DropBehavior makes sense 2025-10-16 16:38:42 +03:00
Jussi Saurio
455f0fbc46 Set in_progress to false AFTER executing the statement 2025-10-16 15:53:58 +03:00
Pere Diaz Bou
57eb63cee0 core/bree: remove duplicated code in BTreeCursor 2025-10-16 14:50:08 +02:00
Jussi Saurio
d77dd8400d bindings/rust: rollback dangling tx on next access of DB, instead of panicing
Closes #3748

Right now if any error happens during an interactive tx that causes the
`Transaction` to drop, the program will panic.

I don't know how good this solution is, but we can at least prevent a panic
by storing whether the connection has a dangling transaction and roll it back
automatically the next time the connection tries to do something.
2025-10-16 15:44:44 +03:00
Preston Thorpe
1f70345dc1 Merge 'core: Unsafe Send and Sync pushdown' from Pekka Enberg
This patch pushes unsafe Send and Sync to individual components instead
of doing it at Database level. This makes it easier for us to
incrementally fix thread-safety, but avoid developers adding more thread
unsafe code.

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

Closes #3745
2025-10-16 08:19:45 -04:00
Preston Thorpe
7cc351afff Merge 'translate/insert: more refactoring and support INSERT OR IGNORE' from Preston Thorpe
`INSERT OR IGNORE INTO t VALUES (...)` can trivially be rewritten to
`INSERT INTO t VALUES (..) ON CONFLICT DO NOTHING`
This PR does this rewriting, as well as finishes a large refactor on
INSERT translation in general.. I just need a break from the rest of
this feature tbh.. just was getting under my skin and I have been in
`translate` land for too long.

Closes #3742
2025-10-16 08:18:28 -04:00
Jussi Saurio
e8e583ace6 Default ON CONFLICT behavior should be ROLLBACK 2025-10-16 14:28:18 +03:00
Jussi Saurio
213af28cf3 rust bindings: make Statement::query:row() finish execution
otherwise the statement will be considered to be in progress,
and its Drop implementation will roll back the transaction it
is in.
2025-10-16 14:03:17 +03:00
Jussi Saurio
6f1bda1438 Instrument test_drop() with tracing 2025-10-16 14:01:54 +03:00
Jussi Saurio
4de36d28e6 deps: add tracing to rust bindings 2025-10-16 14:00:26 +03:00
Jussi Saurio
56d5702176 Fix: rolling back tx should set autocommit to true
Rolling back a transaction should result in `connection.auto_commit` being set
back to true.

Added a regression test for this where a UNIQUE constraint violation rolls back
the transaction and trying to COMMIT will fail.

Currently, our default conflict resolution strategy is ROLLBACK,
which ends the transaction. In SQLite, the default is ABORT, which rolls back
the current statement but allows the transaction to continue.

We should migrate to default ABORT once we support subtransactions.
2025-10-16 12:05:53 +03:00
Pekka Enberg
e9c0fdcb4b Turso 0.3.0-pre.2 2025-10-16 11:31:30 +03:00
Pekka Enberg
a450a43d6d dist: Add Linux/arm64 target for install package 2025-10-16 11:30:30 +03:00
Pekka Enberg
bf5de920f2 core: Unsafe Send and Sync pushdown
This patch pushes unsafe Send and Sync to individual components instead
of doing it at Database level. This makes it easier for us to
incrementally fix thread-safety, but avoid developers adding more thread
unsafe code.
2025-10-16 11:26:50 +03:00
Pekka Enberg
b64ce77e47 Merge 'core: Don't run build.rs in debug mode' from Pedro Muniz
Hopefully this will help a bit with compile times when developing and
with `cargo check`

Closes #3744
2025-10-16 10:52:03 +03:00
Pekka Enberg
f8e8ed6228 Merge 'Run SQLite integrity check after stress test run' from Pedro Muniz
Closes #2916

Closes #3730
2025-10-16 10:07:09 +03:00
Jussi Saurio
95f375791b refactor: move condition outside init_autoincrement 2025-10-16 09:34:13 +03:00
Jussi Saurio
25339a5200 rename: CheckConstraints -> ConstraintsToCheck
CHECK constraints is a separate SQL concept, so let's remove some
potential confusion from the naming.
2025-10-16 09:30:41 +03:00
Pekka Enberg
012ac00e46 Merge 'Document ThreadSanitizer in CONTRIBUTING.md' from Pekka Enberg
Closes #3739
2025-10-16 08:43:33 +03:00