Commit Graph

9318 Commits

Author SHA1 Message Date
Pekka Enberg
042a8dd031 core: Wrap Connection::wal_auto_checkpoint_disabled with AtomicBool 2025-09-24 09:12:46 +03:00
Pekka Enberg
aa95cb24ea core: Wrap Connection::page_size with AtomicU16 2025-09-24 09:12:46 +03:00
Pekka Enberg
60d3a837b7 core: Wrap Connection::cache_size with AtomicI32 2025-09-24 09:12:46 +03:00
Pekka Enberg
0b6f535f4a core: Wrap Connection fields with AtomicI64 2025-09-24 09:12:46 +03:00
Pekka Enberg
f72600431b Turso 0.2.0-pre.8 2025-09-24 09:08:34 +03:00
Jussi Saurio
73571d9c55 Merge 'Don't allow duplicate columns and get column type as passed ' from Pavan Nambi
fixes #3231
```zsh

❯ sqlite3
SQLite version 3.50.4 2025-07-30 19:33:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite>   CREATE TABLE t1 (a);
    ALTER TABLE t1 ADD COLUMN a;
Parse error: duplicate column name: a
sqlite>   ALTER TABLE t1 ADD COLUMN name varchar(255);
    SELECT sql FROM sqlite_schema WHERE name = 't1';
CREATE TABLE t1 (a, name varchar(255))
sqlite>
```
```zsh
turso>
turso>  CREATE TABLE t1 (a);
    ALTER TABLE t1 ADD COLUMN a;
  x Parse error: duplicate column name: a

turso>  ALTER TABLE t1 ADD COLUMN name varchar(255);
    SELECT sql FROM sqlite_schema WHERE name = 't1';
┌─────────────────────────────────────────┐
│ sql                                     │
├─────────────────────────────────────────┤
│ CREATE TABLE t1 (a, name varchar (255)) │
└─────────────────────────────────────────┘
turso>
```

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

Closes #3249
2025-09-24 09:04:08 +03:00
Jussi Saurio
c697638413 Merge 'Simulator Runtime generation' from Pedro Muniz
Closes #3253
Had to do some slight changes in how we shadow interactions and changed
some of the execution code to accommodate both runtime generation and
pre-run generation (pre-run generation is needed for instance when
running the shrunk plans). This behavior is abstracted by the
`InteractionPlanIterator` trait

Closes #3272
2025-09-24 09:03:19 +03:00
Jussi Saurio
75a989a215 Merge 'fix: CTE alias resolution in planner' from Mayank
Closes #3182

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

Closes #3243
2025-09-24 09:01:45 +03:00
Pekka Enberg
a372e07bb8 Merge 'Use SQL over HTTP batch statements for sync push' from Nikita Sivukhin
Use SQL over HTTP batch statement in the push logic of sync-engine with
additional condition for `!auto_commit` for every step except from
initial `BEGIN` of txn.
This is needed to avoid non-transactional update if SQLite will decide
to close transaction due to some error and reset state to autocommit
mode.

Closes #3271
2025-09-24 09:01:26 +03:00
Pekka Enberg
89b9439b1d Merge 'JavaScript bindings browser tests' from Nikita Sivukhin
Closes #3266
2025-09-24 09:00:22 +03:00
Pekka Enberg
248b38b6a9 Merge 'core: Wrap Connection::transaction_state with RwLock' from Pekka Enberg
Closes #3269
2025-09-24 08:44:40 +03:00
Jussi Saurio
d5de088abe Merge 'translate: implement Sequence opcode and fix sort order' from Preston Thorpe
This PR implements the `Sequence` and `SequenceTest` opcodes, although
does not yet add plumbing to emit the latter.
SQLite has two distinct mechanisms that determine the final row order
with aggregates:
Traversal order of GROUP BY, and ORDER BY tiebreaking. When ORDER BY
contains only aggregate expressions and/or constants, SQLite has no
extra tiebreak key, but when ORDER BY mixes aggregate and non-aggregate
terms, SQLite adds an implicit, stable row `sequence` so “ties” respect
the input order.
This PR also fixes an issue with a query like the following:
```sql
SELECT u.first_name, COUNT(*) AS c
FROM users u
JOIN orders o ON o.user_id = u.id
GROUP BY u.first_name
ORDER BY c DESC;
```
Because ORDER BY has only an aggregate (COUNT(*) DESC) and no non-
aggregate terms, SQLite traverses the group key (u.first_name) in DESC
order in this case, so ties on c naturally appear with group keys in
descending order.
Previously tursodb would return the group key sorted in ASC order,
because it was used in all cases as the default

Closes #3287
2025-09-24 08:38:08 +03:00
PThorpe92
4cc02dbed1 Add regression test for sort order with aggregate term in orderby with groupby 2025-09-23 23:08:31 -04:00
PThorpe92
58625b1c6d Use expr.is_constant instead of matching for literal directly 2025-09-23 23:08:04 -04:00
PThorpe92
376d2bf7b1 Add plumbing to add sequence column to stabilize tiebreakers in order+group by 2025-09-23 22:35:59 -04:00
PThorpe92
5afebc5f74 Add Sequence and SequenceTest opcode to explain 2025-09-23 22:34:33 -04:00
PThorpe92
3c8216caab Add Sequence and SequenceTest opcodes to vdbe and sorter 2025-09-23 22:34:13 -04:00
PThorpe92
7dccff0bee Update COMPAT.md, add sequence and sequencetest opcodes 2025-09-23 22:32:22 -04:00
pedrocarlo
44c08c02d1 do not shadow interactions when generating the next plan, only after the interaction is ran 2025-09-23 21:57:06 -03:00
pedrocarlo
69d09bcf8c modify code to use runtime generation 2025-09-23 21:57:06 -03:00
pedrocarlo
5f83f3bdfe modify plan generation to generate interactions on demand 2025-09-23 21:57:06 -03:00
Nikita Sivukhin
57c3d783e1 fix clippy 2025-09-23 18:24:52 +04:00
Nikita Sivukhin
e89dac98f3 use hrana batch stmt with Not(IsAutocommit) condition for push operation 2025-09-23 16:33:40 +04:00
Pekka Enberg
f5d3962459 core: Wrap Connection::transaction_state with RwLock 2025-09-23 14:01:31 +03:00
Pekka Enberg
9f96380bbc Merge 'core: Wrap Connection::autocommit in AtomicBool' from Pekka Enberg
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #3268
2025-09-23 13:52:10 +03:00
Nikita Sivukhin
057d2275e5 add browser tests CI step 2025-09-23 14:19:11 +04:00
Pekka Enberg
fa8065ca52 core: Wrap Connection::autocommit in AtomicBool 2025-09-23 13:18:49 +03:00
Pekka Enberg
1ca647fe68 Merge 'use wasm-runtime from NPM instead of patched sources' from Nikita Sivukhin
Latest version 1.0.5 have proper dependencies we need:
https://www.npmjs.com/package/@napi-rs/wasm-
runtime/v/1.0.5?activeTab=code

Closes #3265
2025-09-23 13:07:10 +03:00
Pekka Enberg
2f961d2a41 Merge 'core: Wrap Connection::database_schemas in RwLock' from Pekka Enberg
Closes #3267
2025-09-23 12:30:16 +03:00
Pekka Enberg
1b6050338d core: Wrap Connection::database_schemas in RwLock 2025-09-23 11:50:43 +03:00
Pekka Enberg
233beeb8e7 Merge 'core: Wrap Connection::schema in RwLock' from Pekka Enberg
Closes #3261
2025-09-23 11:50:24 +03:00
Nikita Sivukhin
1faafdb57e use wasm-runtime from NPM instead of patched sources 2025-09-23 12:28:16 +04:00
Pekka Enberg
b94aa22499 core: Wrap Connection::schema in RwLock 2025-09-23 10:31:20 +03:00
Pavan-Nambi
59660f0c25 remove tests for column type spaces 2025-09-23 12:48:35 +05:30
Pekka Enberg
9d395a5a52 Merge 'Stop incrementing n_changes for idx delete' from Preston Thorpe
closes #3259
Previously we were emitting the following:
<img width="483" height="135" alt="image" src="https://github.com/user-
attachments/assets/e12100ed-5815-4619-829a-3230eb8c8f7f" />
After:
<img width="484" height="310" alt="image" src="https://github.com/user-
attachments/assets/28591f52-18b1-4060-8c92-7a3f7194fca0" />

Closes #3258
2025-09-23 07:30:41 +03:00
Pekka Enberg
b857f94fe4 Merge 'core: Wrap Connection::pager in RwLock' from Pekka Enberg
Closes #3247
2025-09-23 07:29:09 +03:00
Pekka Enberg
3bf40560c4 Merge 'Disable extension loading at runtime' from Preston Thorpe
SQLite disables the `load_extension` function by default in the core
library.
There are a couple reasons we should do the same.
1. VTab extensions need up to update the schema, and if there are
multiple connections we can/will corrupt the schema or read garbage
memory if an extension is loaded while another connection changes the
schema.
2. for _general security reasons_ ™️, which is why sqlite disables
this by default.
This PR leaves it enabled in the CLI, where there can be only a single
connection due to the lack of multi-process support right now.

Closes #3250
2025-09-23 07:28:44 +03:00
PThorpe92
efe7891482 Add test to ensure we return proper changes() 2025-09-22 19:18:18 -04:00
PThorpe92
9238584a75 Stop incrementing n_changes for idx delete 2025-09-22 19:10:35 -04:00
Jussi Saurio
04d364d2d0 Merge 'Differential testing fixes' from Pedro Muniz
- Fixed some incorrect code when running interactions in differential
testing. Instead of replacing the state that was used for running the
interaction, I naively just incremented the interaction pointer.
- adjusted the comparison to check returned values without considering
the order of the rows returned
- added differential testing to run in CI
Closes #3235

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

Closes #3255
2025-09-22 22:58:03 +03:00
pedrocarlo
4568e76d0c run differential testing in CI 2025-09-22 15:33:37 -03:00
pedrocarlo
6569d27bdc compare rows order insensitively for differential testing 2025-09-22 15:33:37 -03:00
pedrocarlo
2cd7c68c35 adjust property generation to not panic by always having some property to select from 2025-09-22 15:24:30 -03:00
pedrocarlo
7d1f23dd3a better diffing with similar crate 2025-09-22 15:24:30 -03:00
pedrocarlo
05034e1f9d instead of incrementing interaction counter, just substitue the current state 2025-09-22 15:24:30 -03:00
Pekka Enberg
f6e3beda45 Turso 0.2.0-pre.7 2025-09-22 20:44:08 +03:00
PThorpe92
10662ee5c5 Fix error in test missing DatabaseOpts field 2025-09-22 11:28:20 -04:00
PThorpe92
0c54c2b255 Add turos_cli option to CLI DatabaseOpts 2025-09-22 11:28:19 -04:00
PThorpe92
8420b9be04 Disable runtime extension loading unless enabled 2025-09-22 11:28:19 -04:00
PThorpe92
4ac4aff30c Add a flag to DatabaseOpts, only for cli_only feature to enable rt extension loading 2025-09-22 11:28:19 -04:00