211 Commits

Author SHA1 Message Date
Pekka Enberg
a820079e8e Turso 0.9.0-pre.1 2026-10-15 12:17:20 +03:00
Pekka Enberg
2829ee1662 Turso 0.8.0 2026-09-28 12:42:08 +03:00
Pekka Enberg
632b58d522 Turso 0.8.0-pre.14 2026-09-28 09:09:16 +03:00
Pekka Enberg
64b8ef5742 Turso 0.8.0-pre.13 2026-09-25 10:54:27 +03:00
Pekka Enberg
e7e77e5957 Turso 0.8.0-pre.12 2026-09-22 17:01:34 +03:00
Pekka Enberg
3971046b2d Merge 'bindings/javascript: update vitest to 4.1.11' from Pekka Enberg
Update vitest from 3.2.7 to 4.1.11 to pick up the fix for the
@vitest/mocker advisory: before 4.1.11, a client that can reach the dev
server can register a redirect mock pointing at any file and read that
file's contents. 4.1.11 checks the target against the dev server's
allowed files.
Vitest 4 moved Playwright browser support into a separate package, so
the wasm packages (`packages/wasm`, `sync/packages/wasm`) now depend on
`@vitest/browser-playwright` instead of `@vitest/browser`, and their
`vitest.config.ts` passes `provider: playwright()`.
Note: vitest 4 resolves its own vite 8.3.0, while our packages still use
vite ^7.3.5 for `vite build`, so both are installed.
Tests: `packages/common` tests pass on vitest 4.1.11. Native and browser
tests are left to CI.

Closes #9097
2026-09-17 13:54:57 +03:00
Pekka Enberg
75c01b6ca1 core/vdbe: add AggStep fast paths for float sum, avg and count
AggStep only had fast paths for integer sum and min/max, so sum() and
total() over floats, every avg() and every count() went through the generic
step. That step matches on the function again, re-reads every payload slot
and writes all of them back for each row. TPC-H Q1 runs seven of its eight
aggregates over 6M rows on that path.

The new fast paths cover a float or an integer below 2^52 added to a float
sum or avg total, and count. Integers below 2^52 convert to a float exactly,
like the non-split branch of SQLite's kahanBabuskaNeumaierStepInt64. Each
fast path produces the same payload as the generic step, which still handles
the first row, non-numeric values, larger integers, integer overflow and
totals that are no longer finite.

Tests: agg-functions/sum-large-float.sqltest covers the rounding error term,
float input after an integer overflow, integers on both sides of 2^52 after
floats in sum and avg, total() over integers, an infinite total and count
over mixed value types.
2026-09-17 12:19:16 +03:00
Pekka Enberg
24682aec7d bindings/javascript: update vitest to 4.1.11
Vitest before 4.1.11 ships a @vitest/mocker that lets a client register a
redirect mock pointing at any file, and then read that file through the dev
server. Version 4.1.11 checks the target against the dev server's allowed
files.

Vitest 4 moved Playwright browser support into @vitest/browser-playwright, so
the wasm packages now depend on it and pass playwright() as the provider.
2026-09-16 18:57:18 +03:00
Pekka Enberg
9434d79235 core: report writes to a read-only database with SQLite's wording
The message for LimboError::ReadOnly was "Error: Resource is read-only".
SQLite says "attempt to write a readonly database", which is what the
upstream tests and the JavaScript binding tests compare against.
2026-09-13 09:43:53 +03:00
Nikita Sivukhin
7cc973fbe3 Turso 0.8.0-pre.11 2026-09-11 09:37:12 +01:00
Pekka Enberg
342dfbe267 Turso 0.8.0-pre.10 2026-09-09 09:06:19 +03:00
Mikaël Francoeur
56208cc073 Turso 0.8.0-pre.9 2026-09-08 10:24:02 -04:00
Pekka Enberg
9384daad3b Turso 0.8.0-pre.8 2026-09-04 07:17:43 +03:00
Preston Thorpe
6ac915124f Merge 'batch API: full per-statement results in every driver, fixing a complaint we've carried since libSQL' from Glauber Costa
Ever since the libSQL days, the batch API has had the same complaint:
you
could not get the result of each individual statement, and when a batch
failed you could not tell which statement failed — or what had already
taken effect. With Turso we have a blank slate, and it turns out the
protocol never was the limitation: a batch response carries complete
per-statement information (results, last insert rowid, error codes, and
the execution statistics `rows_read`, `rows_written`,
`query_duration_ms`; PROTOCOL.md §6.2, §8.4, §9.1). The drivers just
dropped it. This PR takes the opportunity to do it right.
Every driver now exposes one `batch()` API that returns everything the
protocol reports, per statement, in one HTTP round trip:
- **Per-statement results**: rows, affected row count, last insert
  rowid, and the server-side execution statistics.
- **Failure visibility**: statements execute in order and stop at the
  first failure; the error identifies the failing statement by index
  *and* carries one entry per statement — the completed statement's
  result, or null/None for the failing statement and the ones that never
  ran. In a non-atomic batch the completed statements are committed, and
  the caller can finally see exactly what took effect.
- **Atomic mode**: the transactional variant wraps the statements in
  `BEGIN <mode>` / `COMMIT` with a conditional `ROLLBACK`, carried by
the
  same single request.
Per driver:
- **JavaScript** (`serverless/javascript`, existing public API —
extended
  compatibly): each `ResultSet` gains `lastInsertRowid`, `rowsRead`,
  `rowsWritten`, `queryDurationMs`; the thrown `DatabaseError` gains
  `batchIndex` and `batchResults`. `batch()` moves from the cursor
  endpoint to a pipeline batch request because the cursor stream's
  `step_end` does not carry the statistics. Non-atomic batches are now
  gated on the previous statement succeeding — previously statements
  after a failure kept executing server-side.
- **Rust** (new API, `bindings/rust` + `serverless/rust` in one commit
  per the driver-parity rule): `Connection::batch` /
  `Connection::transactional_batch`,
`BatchStatement`/`IntoBatchStatement`
  inputs, `BatchResult` with stats accessors, and
  `Error::BatchStatementFailed { index, error, results }`. The sync
  driver shares the embedded `Connection`, so all three backends expose
  the same API.
- **Python** (new API, `bindings/python` + `serverless/python` in one
  commit): `Connection.batch(statements, mode=None)` on the DB-API
  surface (sync, aio, and the sync-database driver via inheritance),
  raising the classified DB-API exception with `batch_index` and
  `batch_results` attributes.
The parity requirement itself is codified first, in
`serverless/conformance/differential/README.md` ("Driver API parity")
with a pointer from the AGENTS.md core principles.
**Deliberately skipped: Go.** The Go serverless driver is a plain
`database/sql` driver, and `database/sql` has no batch surface, so it is
less obvious what to do there: libsql-client-go's precedent is splitting
multi-statement SQL client-side (with a vendored ANTLR SQLite parser)
inside `Exec`, while the alternative is a driver-specific `Batch` API
outside the standard interface. That trade-off deserves its own
discussion and PR.
The batch behavior is property-tested: a `param_batch` operation in the
shared differential vocabulary (`spec/ops.json`) generates 1-4
parameterized statements — including planted failures and atomic modes —
and all three language harnesses (fast-check, hypothesis, hegel) assert
that the embedded and serverless drivers agree on every statement's
result, the failing index, and the partial results carried by the error.
Building those harnesses caught two real driver bugs before the tests
ever ran: the embedded JS driver had no batch error surface at all, and
the embedded Rust driver reported the connection's stale change counter
for row-returning statements inside a batch.
Follow-ups, out of scope here:
- Whether the JS `compat` (libsql-compat) layer should surface the new
  per-statement `ResultSet` fields on success; it is kept libsql-shaped
  here (the error path does preserve `batchIndex`/`batchResults`).
- Driver-wide preservation of `extended_code` on errors (today only the
  Python serverless `ServerError` keeps it).
- A batch entry containing multi-statement SQL ("a; b") errors on the
  embedded drivers but the server prepares only the first statement — an
  embedded/serverless divergence worth its own discussion.
Also rides along in the JS commit: four env-gated integration tests
still
asserted positional access on expanded rows, which f52724d45 removed on
purpose; CI never runs those tests, so they had drifted.
Tested against a live libsql-server and against Turso Cloud: Rust 44
unit + 58 conformance tests plus the hegel parity property, Python 73
serverless + 236 embedded plus the hypothesis parity property,
JavaScript 42 integration tests plus the fast-check parity property, and
protocol-level coverage asserting a parameterized multi-statement batch
in a single pipeline POST.
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Closes #8535
2026-08-29 08:36:30 -07:00
Amp
d2e40e82f0 bindings/js: update vulnerable development dependencies
Raise the Vitest and Vite minimum versions and refresh both npm and Yarn locks. This also updates the vulnerable js-yaml, nanoid, postcss, and ws transitive resolutions named by the security report.

Tests: npm ci --ignore-scripts; yarn install --immutable --mode=skip-build; yarn workspace @tursodatabase/database-common test; npm audit --package-lock-only
Co-authored-by: pedro muniz <pedro.muniz.carlo@gmail.com>
2026-08-29 14:51:38 +03:00
PThorpe92
9fe63ac8f0 SDK/drivers: make parameterized batches safe and consistent
Parameterized batches could produce different effects across embedded and
serverless drivers when a later bind value was invalid. Embedded Rust also
allowed cloned connections to interleave work with a batch, and managed
batches allowed transaction-control statements to escape their wrapper.
Rollback failures were hidden, while serverless Rust could retain a stale
last-insert rowid when COMMIT failed after a successful insert.

Validate every batch input before execution, reject transaction-control SQL
before opening a managed transaction, and hold an operation-wide gate for
embedded Rust batches. Preserve both the primary and rollback errors, and
carry successful statement rowids through serverless batch decoding even
when a synthetic transaction step fails. Reject malformed serverless batch
responses instead of treating incomplete transaction steps as success.
2026-08-28 10:40:26 -07:00
Glauber Costa
a368eab3af js: return full per-statement details from batch() in every driver
The protocol reports complete per-statement information for a batch —
results, last insert rowid, error codes, and the execution statistics
rows_read, rows_written, and query_duration_ms — but batch() dropped
most of it. Extend the batch API compatibly, in the serverless driver
and in the embedded driver (@tursodatabase/database, whose
DatabasePromise is shared by the wasm and sync drivers), per the driver
API parity requirement:

- Each ResultSet also carries lastInsertRowid, plus rowsRead,
  rowsWritten, and queryDurationMs on the serverless driver (the
  embedded engine does not report those per statement). The
  lastInsertRowid key is present only on entries whose statement
  inserted, so `"lastInsertRowid" in resultSet` detects an insert.
- The serverless batch() uses a pipeline batch request instead of the
  cursor endpoint, because the cursor stream does not carry the
  statistics, and gates each statement on its predecessor succeeding,
  so execution stops at the first failure instead of running the
  remaining statements against a failed batch — the embedded driver's
  sequential semantics.
- The thrown error carries batchIndex (the zero-based index of the
  failing statement) and batchResults (one entry per statement: the
  completed statement's ResultSet, or null for the failing and skipped
  ones; empty when a bind value fails to encode client-side before
  anything is sent), so callers can tell exactly which statements took
  effect.
- The libsql-compat batch() returns the full libSQL ResultSet shape —
  lastInsertRowid and toJSON() included, matching @libsql/client, whose
  batch() returns the same ResultSet as execute() — and both of its
  batch entry points preserve batchIndex and batchResults on the
  LibsqlError they throw.

The JavaScript conformance contract covers the per-statement detail
fields. Also update the serverless integration tests that still
asserted positional access on expanded rows, removed in f52724d45.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-28 10:40:25 -07:00
Pekka Enberg
277ddd050b Turso 0.8.0-pre.7 2026-08-21 08:50:47 +03:00
Pekka Enberg
e8aef1923d Turso 0.8.0-pre.6 2026-08-19 10:18:12 +03:00
Pekka Enberg
a3e6627ebc Turso 0.8.0-pre.5 2026-08-19 07:18:14 +03:00
Pekka Enberg
ce276e4218 Turso 0.8.0-pre.4 2026-08-11 15:55:09 +03:00
Nikita Sivukhin
201ea4fdce fix JS bindings 2026-08-11 13:15:26 +02:00
Pekka Enberg
ed15b13f8e Turso 0.8.0-pre.3 2026-08-06 15:59:00 +03:00
Pekka Enberg
47b0635417 Turso 0.8.0-pre.2 2026-07-26 11:55:13 +03:00
Pekka Enberg
7b5fbf8aa1 Merge 'bindings/js, serverless/js: collapse duplicate column names in expanded rows' from Pekka Enberg
Expanded rows grew hidden non-enumerable positional properties ("0",
"1", ...) in 4c0febfed ("Preserve JS row positional values") to work
around duplicate column names collapsing in object rows. That is a
Turso-only extension: neither better-sqlite3 nor libsql attaches
positional keys to expanded rows, so the conformance suite failed under
PROVIDER=better-sqlite3 and PROVIDER=libsql, and a result column
literally named "0" would collide with the synthetic property.
Remove the positional properties from the native binding's expanded row
mode and the serverless driver's createExpandedRow so expanded rows are
plain objects where duplicate names collapse, exactly like
better-sqlite3 and libsql. Positional access remains available through
raw mode, and the libsql-client compat surface keeps its genuine hybrid
rows built by Session.createRowObject.
The divergence went unnoticed because CI only ran the conformance suite
under PROVIDER=turso; the workflow now also runs it against
better-sqlite3 so drop-in incompatibilities fail in CI.
Tests: rewrote the positional-value tests to assert the collapsing
behavior plus raw-mode access, so they pass identically under the
turso, better-sqlite3, and libsql providers.

Closes #7907
2026-07-21 07:43:32 +03:00
Nikita Sivukhin
4b8518232c Turso 0.8.0-pre.1 2026-07-21 01:16:04 +04:00
Pekka Enberg
f52724d450 bindings/js, serverless/js: collapse duplicate column names in expanded rows
Expanded rows grew hidden non-enumerable positional properties ("0",
"1", ...) in 4c0febfed ("Preserve JS row positional values") to work
around duplicate column names collapsing in object rows. That is a
Turso-only extension: neither better-sqlite3 nor libsql attaches
positional keys to expanded rows, so the conformance suite failed under
PROVIDER=better-sqlite3 and PROVIDER=libsql, and a result column
literally named "0" would collide with the synthetic property.

Remove the positional properties from the native binding's expanded row
mode and the serverless driver's createExpandedRow so expanded rows are
plain objects where duplicate names collapse, exactly like
better-sqlite3 and libsql. Positional access remains available through
raw mode, and the libsql-client compat surface keeps its genuine hybrid
rows built by Session.createRowObject.

The divergence went unnoticed because CI only ran the conformance suite
under PROVIDER=turso; the workflow now also runs it against
better-sqlite3 so drop-in incompatibilities fail in CI.

Tests: rewrote the positional-value tests to assert the collapsing
behavior plus raw-mode access, so they pass identically under the
turso, better-sqlite3, and libsql providers.
2026-07-20 20:11:59 +03:00
Nikita Sivukhin
149635b0c8 use transactionAsync instead of transaction 2026-07-17 16:09:13 +02:00
Nikita Sivukhin
6931576650 wip 2026-07-17 15:28:14 +02:00
Nikita Sivukhin
5f60c5a8ee adjust signature of transaction API for TS/JS tursodb async SDK 2026-07-17 14:54:29 +02:00
Nikita Sivukhin
144a704f1b add test 2026-07-17 14:26:12 +02:00
Pekka Enberg
e7cb62a8bd Turso 0.7.0 2026-07-13 18:12:11 +03:00
Pekka Enberg
4b18962902 Turso 0.7.0-pre.22 2026-07-13 17:38:12 +03:00
Pekka Enberg
3c2148f734 Turso 0.7.0-pre.20 2026-07-12 12:50:15 +03:00
Pekka Enberg
d115b414ad Merge 'Drop the beta warning' from Glauber Costa
0.7 ships next week, and Turso now runs in production at multiple
organizations — the top-of-page "this software is in BETA, use caution
with production data" warning no longer reflects reality, and it's the
first thing every visitor reads.
## What changed
- **About**: the ⚠️ BETA warning blockquote is gone. In its place, a
one-line status note: Turso runs in production today, with a pointer to
the FAQ for where the project stands on the way to 1.0.
- **FAQ "Is Turso Database ready for production use?"**: now opens with
"Yes" and the production users, followed by the testing story (DST,
Antithesis). The honest caveats stay, but softened: not yet 1.0, some
features explicitly experimental, and backups recommended as "the same
discipline you would apply to any database" rather than as a data-loss
threat.
- **New FAQ "How compatible is Turso Database with SQLite?"**: we're not
at 100% yet, COMPAT.md tracks the details, the gap is closing quickly,
and full compatibility is a requirement for 1.0.
- **libSQL FAQ**: still flatly said "libSQL is production ready, Turso
Database is not", contradicting the rest of the page. Now: both run in
production; libSQL is more battle-tested, Turso Database is where
development effort is focused.
The goal is to neither scare nor oversell: no data-loss warning up top,
but the README still says clearly that we are pre-1.0 and that some
SQLite differences remain.
🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

Closes #7735
2026-07-12 08:52:00 +03:00
Pekka Enberg
9f13ffbecd Turso 0.7.0-pre.19 2026-07-12 08:39:31 +03:00
Pekka Enberg
17f12b104c bindings/javascript: pin better-sqlite3 to 12.9.0
better-sqlite3 12.11.0 dropped its Node 20 (node-v115) prebuilt binaries
while still advertising engines.node "20.x", so `yarn install` on the
Node 20 CI runners falls back to compiling from source. That source build
is fragile across platforms: on macOS arm64 the bundled node-gyp@13 loads
an undici that calls webidl.util.markAsUncloneable (Node 22+ only) and
crashes, and on Windows older node-gyp can't detect the Visual Studio
version on the runner.

Pin better-sqlite3 to 12.9.0, the last release that publishes node-v115
prebuilds for every target platform (darwin-arm64/x64, win32-x64/arm64,
linux-x64/arm64, musl). With a prebuilt binary there is no source compile,
so node-gyp, Visual Studio, and undici never enter the picture.
2026-07-06 10:38:59 +03:00
Pekka Enberg
11ab464138 Turso 0.7.0-pre.18 2026-07-05 19:30:07 +03:00
Glauber Costa
1679062d8c docs: drop the beta warning for 0.7
Turso runs in production at multiple organizations, so the "this
software is in BETA, use caution with production data" warning no
longer reflects reality. It appeared in the main README, was
copy-pasted in 11 bindings READMEs (what users see on npm, PyPI, and
pkg.go.dev), and was printed by tursodb at every shell startup.

- README: remove the warning blockquote from About, leaving a one-line
  status pointer. Rewrite the production-readiness FAQ to lead with
  production use and the testing story, keeping the honest caveats in
  softer form: not yet 1.0, some features experimental, keep backups
  as with any database. Add a FAQ on SQLite compatibility (gap tracked
  in COMPAT.md, closing quickly, required for 1.0), and fix the libSQL
  FAQ, which still claimed Turso Database is not production ready.
- bindings READMEs: replace the warning with the same softened status
  line, linking to the FAQ.
- cli: remove the startup banner line entirely, matching the SQLite
  shell.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 10:56:57 -05:00
Nikita Sivukhin
0fd4fb8b7b Turso 0.7.0-pre.14 2026-06-29 11:58:42 +04:00
Pekka Enberg
5fa8222f39 Turso 0.7.0-pre.13 2026-06-25 17:06:04 +03:00
Pekka Enberg
92e8498d26 Turso 0.7.0-pre.12 2026-06-25 16:40:54 +03:00
Pekka Enberg
2e1a41772b Turso 0.7.0-pre.11 2026-06-25 10:22:15 +03:00
Pekka Enberg
1ebe80ff22 Turso 0.7.0-pre.10 2026-06-18 20:48:10 +03:00
Nikita Sivukhin
93dddea459 Turso 0.7.0-pre.9 2026-06-17 22:27:57 +04:00
Pekka Enberg
bfcf68f992 Turso 0.7.0-pre.8 2026-06-17 10:05:39 +03:00
Pekka Enberg
cdd3c057e7 Turso 0.7.0-pre.7 2026-06-11 19:48:55 +03:00
Pekka Enberg
e9c74edadc Turso 0.7.0-pre.6 2026-06-09 12:34:27 +03:00
Pedro Muniz
7715979bd0 Merge 'Preserve JS row positional values' from Pedro Muniz
I think JS has problems overall. But my guess here is that there is some
positional property that we were not adding.
Closes https://github.com/tursodatabase/turso/issues/7278
Vibed as Im not quite a JS script kiddie

Reviewed-by: Mikaël Francoeur (@LeMikaelF)
Reviewed-by: Pekka Enberg <penberg@iki.fi>

Closes #7285
2026-06-08 16:22:28 -03:00
Jussi Saurio
0cdf1f0060 feat: REINDEX 2026-06-08 10:06:19 +03:00