110 Commits

Author SHA1 Message Date
Pekka Enberg
a820079e8e Turso 0.9.0-pre.1 2026-10-15 12:17:20 +03:00
Pekka Enberg
2487f62c37 Merge 'bindings/dotnet: resolve declared column types without per-cell PRAGMA queries' from Marc-André Moreau
## Problem

`Turso.Data.Sqlite.SqliteDataReader.GetValue(ordinal)` resolves each
column's declared type, for example to turn `GUID` columns into
`System.Guid`. It did this through `GetDeclaredTypeName` →
`GetTableColumns`, which ran `PRAGMA table_info`, `PRAGMA index_list`
and `PRAGMA index_info` (plus regexes over the SQL text) for **every
column of every row**, with no cache. Reading a result set with
`GetValues()` or loading a `DataTable` therefore ran dozens of nested
statements per row.

An external benchmark of the published `Turso.Data.Sqlite.Provider`
0.8.1 package used Remote Desktop Manager's SQLite data source: 10,000
entries with 11 columns each, including about 1.3 KB of XML. Loading
every entry took 14.7 s and allocated 2 GB through this path.

## Fix

1. **Ask the engine.** `GetDeclaredTypeName` now calls
`TursoBindings.GetDeclaredTypeName` → `turso_statement_column_decltype`.
Microsoft.Data.Sqlite gets the declared type the same way, through
`sqlite3_column_decltype`, and it costs no query. Like SQLite, it
returns the declared type of direct table-column references (including
through aliases and joins) and nothing for expressions.
2. **Remove the SQL-parsing heuristics.** The regex + `PRAGMA
table_info` / `index_list` / `index_info` path that guessed the declared
type from the SQL text is gone. Compared over direct columns, aliases,
joins, views, subqueries, CTEs and expressions, it never resolved
anything the engine did not, and the test suite passes without it.
3. **Cache per result set.** Resolved declared types are cached per
column for the current result set, so `GetValue` does not cross into
native code for them on every cell. The cache is keyed on the current
statement handle, so `NextResult()` invalidates it and each statement in
a batch resolves its own types. An out-of-range ordinal throws
`ArgumentOutOfRangeException`.

The change is limited to `SqliteDataReader.cs`. It does not change the
public API or the native sdk-kit, and the managed remote/replica path is
untouched. `GetSchemaTable` still uses its existing schema lookup.

One behaviour note: declared types now come from the engine rather than
from parsing the SQL. For queries the heuristics got wrong (for example
an aliased, table-qualified column in a join), `GetDataTypeName`,
`GetFieldType` and the `Guid` conversion in `GetValue` now follow the
engine's declared type, as Microsoft.Data.Sqlite does.

## Measurements

Our own reproduction, so not directly comparable with the 0.8.1 numbers
above: Windows 11, release native build, 10,000 RDM-shaped rows, median
of 3 runs. Baseline: `main`.

| Scenario | Before | After |
| --- | --- | --- |
| Load every entry with `GetValues` | 3.5–4.0 s | about 50 ms |
| `SELECT DATA FROM Connections WHERE ID = @id` on an open connection,
one `GetValue` | 50–90 µs | 21–33 µs |

These numbers come from a build that also had a separate connection-
pooling change, which is not part of this PR. Both rows are dominated by
the reader path changed here, but they were not re-measured on this
change alone.

## Testing

- New test
`SqliteFacadeTests.GetValueResolvesDeclaredTypesForEachResultSet`. In a
two-statement batch, it checks that a `GUID` column comes back as `Guid`
on every row of the first result set, and that after `NextResult()` a
`TEXT` column with the same name comes back as `string`. This confirms
that the cache does not leak between result sets.
- New test
`SqliteFacadeTests.GetValueResolvesDeclaredTypesThroughAliasesAndJoins`.
An aliased, table-qualified `GUID` column in a join comes back as `Guid`
(the old heuristics reported it as `TEXT`), and an out-of-range ordinal
throws.
- New test `SqliteFacadeTests.GetValueUsesStorageTypeWhenNoDeclaredTypeI
sAvailable`. Expressions over a `GUID` column, a column declared without
a type and a constant expression get no declared type, so values come
back as stored (not converted to `Guid`) and `GetDataTypeName` reports
the storage type.
- `dotnet test src/Turso.Tests`: 258 passed, 0 failed, 4 skipped. The
skipped tests are the cloud/remote sync tests, which need credentials.
- `dotnet format Turso.slnx whitespace --verify-no-changes` reports no
changes for the edited files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

Closes #9536
2026-10-06 18:04:45 +03:00
awakecoding
edf774f34e bindings/dotnet: test columns without a declared type
Cover expressions and a column declared without a type, where
turso_statement_column_decltype returns nothing: values come back as
stored and are not converted to Guid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 09:29:40 -04:00
awakecoding
7b6a6c8962 bindings/dotnet: drop the SQL-parsing declared-type fallback
turso_statement_column_decltype already resolves every direct table-column
reference, including through aliases and joins, and the regex/PRAGMA
fallback returned nothing extra for expressions. Remove it along with the
table-schema cache it needed, and throw ArgumentOutOfRangeException for an
out-of-range ordinal instead of resolving it.

Add a test covering an aliased GUID column in a join, which the old
heuristics reported as TEXT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:20:13 -04:00
awakecoding
2d5cddd11a bindings/dotnet: rename SqliteConnectionPool to SqliteDatabasePool
The pool keeps native databases open and hands every SqliteConnection a
fresh native connection; it never reuses connections. Name it after what
it pools. The public ClearPool/ClearAllPools API keeps its ADO.NET names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 17:09:16 -04:00
awakecoding
1dbf1623dd bindings/dotnet: pool local databases in Turso.Data.Sqlite
SqliteConnection had no pool: ClearAllPools and ClearPool were empty,
and every Open created, opened and connected a new native database. The
core only shares a Database while one of its connections is alive, and
closing the last connection runs a full checkpoint. With one connection
per operation, every Open re-read the schema and replayed the WAL, and
every Close checkpointed.

Add SqliteConnectionPool, which keeps one opened database per full path
(case-insensitive on Windows). With Pooling=True, the existing builder
default, each Open gets a fresh native connection on the pooled
database, so PRAGMAs, functions, temp state and open transactions never
leak between opens. Each entry also holds one idle anchor connection so
the database's connection count never drops to zero and Close no longer
checkpoints every time.

ClearPool and ClearAllPools now release pool entries. A database that
still has open connections closes when the last one does. Entries are
also released on AppDomain.ProcessExit so the WAL gets its final
checkpoint. :memory: and shared in-memory databases, which are temp
files deleted when their last connection closes, are never pooled.

As with Microsoft.Data.Sqlite, a pooled file stays open after Close,
so on Windows it cannot be deleted or replaced until ClearPool or
ClearAllPools is called. EnsureDeleted already calls ClearAllPools.
Tests that delete database files now call ClearAllPools first, and the
Readme describes the Pooling keyword.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 09:48:12 -04:00
awakecoding
26e4cb34d5 bindings/dotnet: add shared database handles to Turso.Raw
TursoBindings.OpenDatabase always pairs one native database with one
connection, so a caller that wants several connections on the same
opened database has to open the file again, which re-reads the schema
and replays the WAL every time.

Add TursoBindings.OpenSharedDatabase, which returns a new
TursoSharedDatabaseHandle for an opened database with no connection,
and TursoBindings.Connect(TursoSharedDatabaseHandle), which creates a
connection on it. The connection holds a SafeHandle reference on the
database through TursoDatabaseHandle.FromConnectionPtr, so disposing
the shared handle only frees the native database after every
connection made from it has closed.

The private OpenDatabase now shares the new/open code with
OpenSharedDatabase and behaves as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 09:16:00 -04:00
awakecoding
c8f38e1726 bindings/dotnet: resolve declared column types without per-cell PRAGMA queries
SqliteDataReader.GetValue() resolved each column's declared type through
GetDeclaredTypeName -> GetTableColumns, which ran PRAGMA table_info,
PRAGMA index_list and PRAGMA index_info (plus regexes over the SQL) for
every column of every row, with no caching. Reading a result set with
GetValues() or loading a DataTable therefore ran dozens of nested
statements per row. Loading 10,000 rows of 11 columns took seconds and
allocated gigabytes through this path.

Ask the engine first, through turso_statement_column_decltype, as
Microsoft.Data.Sqlite does with sqlite3_column_decltype. This costs no
query. The existing SQL/PRAGMA heuristics remain as the fallback for
columns the engine leaves unresolved.

Cache the resolved declared types and the table-column maps for each
result set. The cache is keyed on the current statement handle, so
NextResult() invalidates it. A new test checks that declared types are
resolved separately for each result set of a multi-statement batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 09:15:52 -04: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
2befa059ad bindings/dotnet: let native code own function callback handles
The SQLite facade freed every GC handle behind its scalar, aggregate,
and collation registrations as soon as the connection closed, while
the native side could still reach those handles through statements
that had not been finalized. A freed handle slot gets reused by the
next registration, which is how LocalDatabaseKeepsSqliteHelpersAndTursoHistoryRepository
fails intermittently with "Unable to cast object of type
'AggregateFunctionRegistration' to type 'ScalarFunctionRegistration'".

Free each handle from the context destructor that core invokes when a
registration is dropped instead. The handle then lives exactly as long
as native code can call it, and the per-connection handle list and its
eager cleanup go away. Callbacks now check the context type and report
what they received, so a future mismatch names the problem instead of
surfacing as a cast failure.

Tests: bindings/dotnet Turso.Tests in CI
2026-09-21 13:04:40 +03:00
Nikita Sivukhin
7cc973fbe3 Turso 0.8.0-pre.11 2026-09-11 09:37:12 +01:00
awakecoding
f2c8086d4a github: satisfy ruff on the Android ELF export checker
Split the dynsym parser so ruff 0.5.4 stays under the line-length and
complexity limits that failed PR lint.

Tests: python bindings/dotnet/scripts/check_elf_dynsym_exports.py --self-test; uvx ruff@0.5.4 check bindings/dotnet/scripts/check_elf_dynsym_exports.py
2026-09-09 14:45:13 -04:00
awakecoding
3358f32f2a github: check Android native sync exports from ELF dynsym
The NDK llvm-readelf listing is not a stable end-of-line match for
turso_sync_database_new, so validate-android-package failed even when
the packaged Android library exported the symbol.

Parse .dynsym directly for the consumer APK and the Native nupkg.

Tests: python bindings/dotnet/scripts/check_elf_dynsym_exports.py --self-test; checked Turso.Data.Native 0.8.0-pre.10 android-arm64/arm libraries from run 34318638325
2026-09-09 14:06:02 -04:00
Pekka Enberg
342dfbe267 Turso 0.8.0-pre.10 2026-09-09 09:06:19 +03:00
awakecoding
b6fa585040 bindings/dotnet: validate packaged consumers
Exercise the completed replica API through packed NativeAOT, Android, and iOS consumers so package layout, native asset resolution, trimming, and sync exports are checked before NuGet publication.

Keep the published turso_sdk_kit filenames and package version unchanged while allowing samples to select locally packed package versions.

Tests: dotnet format whitespace; local NuGet pack inspection; win-x64 NativeAOT packaged consumer run
2026-09-08 17:26:18 -04:00
Pekka Enberg
039f8c0d34 Merge 'bindings/dotnet: enable EF Core remote and replica backends' from Marc-André Moreau
## Summary
- enable `Turso.EntityFrameworkCore.Sqlite` over the merged
`Turso.Data.Sqlite` local, direct-remote, and embedded-replica backends
- preserve connection settings and ownership for EF-created, external,
and read-only cloned connections
- make database creation, existence checks, table checks, deletion,
migrations, and migration locking backend-aware
- register SQLite helpers only on local handles and reject direct-remote
`REGEXP`, decimal `ef_*`, and `EF_DECIMAL` SQL before it reaches the
server
- cover direct remote and replica CRUD, generated keys,
transactions/savepoints, migrations/history, creator semantics, helper
behavior, memory replicas, and replica deletion boundaries
This surgically extracts the EF provider layer from the closed source
draft #8504 after the merged extraction PRs #8514, #8519, #8523, #8530,
#8555, #8557, #8609, #8621, and #8633. NativeAOT/mobile/package-consumer
samples, package-version plumbing, smoke programs, and CI remain
deferred to the final package-validation layer; this PR contains no Rust
changes.
## Backend behavior
- Direct remote creation is a no-op with an existence probe. Direct
remote deletion fails clearly and points callers to the Turso platform
API.
- Embedded-replica deletion removes only the local replica/database
files and known sidecars; it never implies remote deletion. `:memory:`
replicas are treated as existing without filesystem access.
- Local and replica connections keep EF's SQLite helper functions and
collations. Direct remote connections fail early for helpers that
require a local native handle.
## Validation
- `dotnet format` on the changed provider and test files
- `dotnet build bindings\dotnet\Turso.slnx -c Debug` (net8.0, net9.0,
net10.0)
- focused EF local/remote/replica tests: 20 passed
- full .NET suite: 258 passed, 1 skipped
- live Cloud EF direct-remote and embedded-replica smoke: passed

Closes #8676
2026-09-08 18:57:26 +03:00
Mikaël Francoeur
56208cc073 Turso 0.8.0-pre.9 2026-09-08 10:24:02 -04:00
awakecoding
89a103913e bindings/dotnet: enable EF Core remote and replica backends
Route EF Core connection, creator, migration, and helper behavior through the merged Turso.Data.Sqlite backend modes so direct remote and embedded-replica connection strings work without changing local semantics.

Reject client-only SQLite helper SQL before direct-remote execution and keep replica deletion limited to local database sidecars.

Tests: net8/net9/net10 solution build; focused EF local/remote/replica tests; full .NET suite; live Cloud direct/replica EF smoke
2026-09-04 09:26:37 -04:00
Pekka Enberg
c86f4e4d1b Merge 'bindings/dotnet: route sqlite facade through managed backends' from Marc-André Moreau
## Summary
This continues the focused .NET extraction from the closed source draft
#8504 after #8514, #8519, #8523, #8530, #8555, #8557, #8609, and #8621.
- preserve the existing native local path while recognizing direct
remote and embedded-replica connection strings in `Turso.Data.Sqlite`
- route remote and replica commands, readers, parameters, transactions,
savepoints, and public `SqliteBatch` APIs through the merged
`Turso.Data` backend
- parse multi-statement SQL across quotes, comments, trigger bodies, and
statement-local parameters
- preserve SQLite-compatible records-affected, schema/type,
`NextResult`, timeout/cancellation, read-only, active-reader locking,
and error behavior
- reject client-only helpers on direct remote connections while
registering supported callbacks against replica-local handles
- document facade migration and remote/replica connection strings
The only internal bridge is a narrow
`InternalsVisibleTo("Turso.Data.Sqlite")` entry. It is required for
replica callback registration against the managed connection's local
native handle and sync-operation gate; direct remote execution otherwise
uses public `Turso.Data` command and batch APIs.
## Deferred
The `Turso.EntityFrameworkCore.Sqlite` provider, EF migrations/database
creator/options behavior, generated keys, package-consumer and
NativeAOT/mobile samples, CI packaging jobs, and all Rust changes remain
deferred to later ordinary PRs.
## Validation
- `dotnet format bindings/dotnet/Turso.slnx --no-restore --verify-no-
changes` for the changed projects/files
- `dotnet build bindings/dotnet/Turso.slnx -c Debug --no-restore
--nologo` (`net8.0`, `net9.0`, `net10.0`)
- focused facade tests: 92 passed
- full .NET suite: 250 passed, 1 existing skipped test
- live Cloud smoke test through `Turso.Data.Sqlite`: direct remote
transaction/write plus embedded-replica sync/read passed

Closes #8633
2026-09-04 13:50:56 +03:00
Pekka Enberg
9384daad3b Turso 0.8.0-pre.8 2026-09-04 07:17:43 +03:00
awakecoding
28c088f76e bindings/dotnet: route sqlite facade through managed backends
Make Turso.Data.Sqlite preserve its local provider path while routing direct remote and embedded-replica connection strings through Turso.Data. Add multi-statement parsing, managed readers, transactions, batches, SQLite-compatible errors and locking, and reject helpers that need a local handle in direct remote mode.

Keep one narrow friend-assembly bridge so replica callbacks can register against the managed connection's local native handle.

Tests: dotnet build bindings/dotnet/Turso.slnx -c Debug --no-restore
Tests: dotnet test bindings/dotnet/src/Turso.Tests/Turso.Tests.csproj -c Debug -f net9.0 --no-build
2026-09-02 15:48:00 -04:00
awakecoding
47da6137f9 bindings/dotnet: complete ADO.NET compatibility and stream recovery
Expose stable reader schema metadata while preserving SQLite storage classes, and support GUID and enum conversions expected by ADO.NET consumers.

Recover an expired stateless Hrana stream once without replaying batches. Poison active transactions with the original failure so commit, rollback, and later commands cannot mask it.

Tests: dotnet test bindings/dotnet/src/Turso.Tests/Turso.Tests.csproj --no-restore -- NUnit.NumberOfTestWorkers=0
2026-09-01 22:52:42 -04:00
awakecoding
e83f1dd861 bindings/dotnet: support batches on embedded replicas
Execute replica batch commands in order through the existing local connection and expose their buffered results through DbDataReader. Keep replica batches non-atomic unless callers attach an explicit transaction, and keep active batch readers inside the sync-operation lifetime gate.

Reset expired remote batch sessions without replaying a possibly partially applied batch. Invalidate an expired transaction stream rather than allowing later statements to escape its transaction.

Tests: dotnet build Turso.Data.csproj (net8.0, net9.0, net10.0); dotnet test Turso.Tests.csproj (207 passed, 1 skipped)
2026-08-31 17:07:05 -04:00
Preston Thorpe
f774881565 Merge 'bindings/dotnet: pool replicas and schedule automatic pulls' from Marc-André Moreau
## Summary
- add a process-wide registry for file-backed embedded replicas with
normalized path identity, single-flight initialization, opt-in pooling,
exclusive non-pooled leases, and safe last-lease shutdown
- keep `:memory:` replicas private and reject incompatible pooled
options using fingerprints that hash auth and encryption secrets
- share one automatic pull schedule per pooled replica, retry only
transient transport/I/O/timeout failures, and expose immutable status
plus status-change events on `TursoConnection`
- make close/dispose and sync/async open failure paths release leases
exactly once, isolate observer failures, avoid shutdown deadlocks,
suppress stale queued status after close/reopen, and surface terminal
automatic-sync failures on close
- add focused pooling, registry, retry, lifecycle, observability, and
live cloud convergence coverage; document `Pooling=True` and `Sync
Interval`
## Context
This is the next regular extraction from source draft #8504 and builds
on the connection-string replica and sync groundwork merged in #8514,
#8519, #8523, #8530, and #8555.
Pooling remains opt-in. Existing connections keep `Pooling=False`
behavior unless callers explicitly request sharing.
## Deferred
- replica `DbBatch` and changes to `TursoBatch` / `CanCreateBatch`
- Hrana stream-expiry and transaction-fault recovery, related test HTTP
plumbing, and broader ADO.NET schema/DataTable/GUID/enum/isolation
compatibility
- `Turso.Data.Sqlite` managed remote/replica backend and EF Core
integration
- NativeAOT/mobile/package-consumer samples and CI jobs
- Rust changes
## Validation
- formatting verification for all changed C# files
- full multi-target .NET solution build
- focused replica pooling and automatic-sync tests: 24 passed
- full .NET suite: 198 passed, 1 skipped
- live Turso Cloud automatic pull convergence passed with configured
credentials

Closes #8557
2026-08-31 13:25:16 -07:00
Pekka Enberg
dadff8df16 bindings/dotnet: rename iOS sync dylib to the public sdk kit name
Every native target builds turso_sync_sdk_kit and then renames the output
to the public libturso_sdk_kit name, but the two iOS targets skipped the
rename while IOS_DYLIB_FILE pointed at the sync name. The publish
workflow only uploads libturso_sdk_kit.*, so the sync dylib never left
the iOS build jobs and XCFramework packaging died on a missing file.

The iOS artifacts were not empty: they carried the libturso_sdk_kit.dylib
that cargo builds incidentally for the dependency crate, which has no
sync ABI symbols. Matching the other platforms makes the uploaded file
the one that was actually built.
2026-08-29 13:00:20 +03:00
awakecoding
749d0c5c12 bindings/dotnet: pool replicas and schedule pulls
Share file-backed replicas only when Pooling=True while keeping non-pooled paths exclusive and :memory: replicas private. Normalize path identity, hash credential fingerprints, single-flight initialization, and release the shared sync database after the last lease.

Run one automatic pull coordinator per replica with bounded transient retries and immutable status notifications. Keep observer callbacks outside lifecycle locks, preserve stopped status across queued events, and surface terminal failures during close.

Tests: dotnet build bindings\\dotnet\\Turso.slnx --no-restore --configuration Debug; dotnet test bindings\\dotnet\\src\\Turso.Tests\\Turso.Tests.csproj --no-restore --no-build (198 passed, 1 skipped; includes live cloud convergence)
2026-08-28 16:14:32 -04:00
awakecoding
45025f82b8 bindings/dotnet: add connection-string replicas
Route remote Data Source connections with Replica Path through the managed sync database using direct per-connection ownership. Map explicit sync options while rejecting deferred pooling, automatic sync, and replica batches.

Keep explicit TursoSyncDatabase connections caller-owned and close active readers before releasing replica resources.

Tests: focused provider build, replica/remote/managed sync tests, and live Cloud pull convergence
2026-08-28 12:46:35 -04:00
awakecoding
e907db302d bindings/dotnet: add advanced sync database options
Expose partial bootstrap, remote encryption, sync thresholds, logical MVCC pull, and experimental feature settings through the explicit TursoSyncDatabase API. Validate incompatible configurations and preserve the Windows partial-sync guard before mapping options to the native sync configuration.

Tests: dotnet test bindings/dotnet/src/Turso.Tests/Turso.Tests.csproj --filter FullyQualifiedName~TursoAdvancedSyncOptionsTests|FullyQualifiedName~TursoManagedSyncTests
2026-08-27 08:05:01 -04:00
awakecoding
70f506d714 bindings/dotnet: expose managed sync controls
Add explicit push, checkpoint, and statistics operations to the managed replica API while reusing the lifecycle and transport machinery introduced for pull replicas. Keep all sync operations serialized through the existing database gate and surface operation-specific failures.

Tests: dotnet test bindings/dotnet/src/Turso.Tests/Turso.Tests.csproj
2026-08-26 20:15:46 -04:00
awakecoding
46f7f55714 bindings/dotnet: add managed pull replica API
Expose the minimum managed embedded-replica lifecycle on top of the native sync ABI: create or open a replica, connect locally, and pull remote changes safely. Drive HTTP and file I/O with cancellation while coordinating local statement, reader, connection, and database lifetimes.

Advanced sync configuration, push, checkpoint, and statistics remain deferred to focused follow-up changes.
2026-08-26 16:34:14 -04:00
awakecoding
0e4834af97 bindings/dotnet: expose native sync ABI
Expose the existing Rust sync SDK C ABI through Turso.Raw with exact native layouts, SafeHandle ownership, and low-level operation and I/O wrappers.

Build the combined sync payload while retaining the public turso_sdk_kit filenames and NuGet RID layout.

Tests: cargo test -p turso_sync_sdk_kit --lib; focused Turso.Raw build and Turso.Tests sync/raw tests; debug NuGet package layout inspection
2026-08-26 09:17:02 -04: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
a644dd43d6 Unify SQLite tracking version to 3.50.4
SQLite has lots of variation in behavior across versions. Turso core
already was tracking 3.50.4, but as it turns out, CI and some of the
bindings had different ideas. Fix that to track 3.50.4 consistenty
across the project, and make the version number explicit in README.md
and COMPAT.md
2026-08-18 09:57:57 +03:00
Pekka Enberg
ce276e4218 Turso 0.8.0-pre.4 2026-08-11 15:55:09 +03:00
Marc-André Moreau
409398c1e0 bindings/dotnet: match SDK database config ABI
Keep the existing .NET binding compatible with the expanded SDK-kit database config by carrying explicit zero values for the new page-codec pointer and open-flags fields. Without this, the native side reads stack garbage as open flags and all .NET connection tests fail before opening a database.

Tests: dotnet test .\bindings\dotnet\src\Turso.Tests\Turso.Tests.csproj --filter FullyQualifiedName~ExecutesCommonAdoNetQuery --no-restore --verbosity minimal

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-10 13:54:09 +03:00
Glauber Costa
3ea5725541 bindings/c: statement introspection, column conversions, and a C API oracle
Implements sqlite3_sql, sqlite3_expanded_sql and sqlite3_stmt_busy
(backing SQLite3Stmt::getSQL() and busy() in PHP's ext/sqlite3), SQLite
conversion semantics for the column accessors, and a randomized
differential oracle for the C API.

Introspection:
- sqlite3_sql: original text, retained on the statement, valid until
  finalize.
- sqlite3_expanded_sql: SQL with each parameter marker replaced by its
  bound value's literal (NULL when unbound). Implemented in core as
  Statement::expanded_sql so any binding can expose it; the text is
  re-tokenized with the lexer, and each TK_VARIABLE resolves its index
  from its own text (?N carries the number, names are looked up, bare ?
  is largest-so-far + 1). Does not reuse Value::exec_quote: SQLite
  renders quote() and expanded SQL differently (X'..' vs x'..' blobs).
- sqlite3_stmt_busy: delegates to the statement's busy state in core.

Column accessors: column_int64/int/double/text/blob/bytes apply SQLite's
conversion table when the requested representation differs from the
stored type, via Value::exec_cast and the SQLite-compatible text
rendering. Converted results are cached per column for pointer
stability; column_blob returns NULL for zero-length results.

C API semantics:
- sqlite3_last_insert_rowid returns int64 per its prototype.
- sqlite3_bind_parameter_name returns NULL for anonymous ? and "?N" for
  numbered markers; numbered markers are tracked by a flag on the AST
  variable and in the parameter table, their "?N" name derived from the
  index on demand, so registering one allocates nothing and prepare cost
  for ?N-heavy statements stays flat. bind_parameter_index("?N")
  resolves, as in SQLite. Returned names
  are cached on the statement (valid until finalize).
- The prepare tail points at the first byte past the terminating ';'.
- sqlite3_data_count returns 0 when no row is available.

Oracle: tests/oracle.rs dlopens the system libsqlite3 and the built
cdylib side by side (verifying the export table via dlsym) and drives
both through identical seeded scenarios, comparing every observable in
lockstep. Failures abort with seed + operation trace;
TURSO_ORACLE_SEED/TURSO_ORACLE_ITERS reproduce and extend. Not
exercised (reference behavior is build-dependent, noted in the oracle):
step after SQLITE_DONE (auto-reset vs SQLITE_OMIT_AUTORESET; core
auto-reset is follow-up work) and long values in expanded SQL
(SQLITE_TRACE_SIZE_LIMIT).

Directed tests in sqlite3_tests.c pin the introspection contracts
byte-for-byte against both libraries; a core unit test covers
expanded_sql.

Numbered parameters remain pattern placeholders: index-method patterns
use ?N to share one captured argument across call sites (an FTS pattern
binds the same query text to fts_score and fts_match), and the
placeholder guards in try_capture_parameters/try_substitute_parameters
accept positional markers (Variable::is_positional). The .NET binding's
missing-parameter message takes its position branch for anonymous
markers, which its test asserts. The oracle is excluded on Windows like
the compat suite: no system SQLite to compare against.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 13:27:31 -05:00
Pekka Enberg
ed15b13f8e Turso 0.8.0-pre.3 2026-08-06 15:59:00 +03:00
Marc-André Moreau
993e8218fb bindings/dotnet: split NuGet runtime packages
Separate the SQLite provider facade from shared managed interop and precompiled native runtime packages. Keep the provider package focused on the SQLite API, move shared NativeAOT and platform integration into neutral runtime packages, and update packaging, samples, documentation, and CI for the new dependency graph.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-04 10:14:58 -04:00
Pekka Enberg
47b0635417 Turso 0.8.0-pre.2 2026-07-26 11:55:13 +03:00
Nikita Sivukhin
4b8518232c Turso 0.8.0-pre.1 2026-07-21 01:16:04 +04:00
Preston Thorpe
86bd82d963 Merge 'bindings/dotnet: add HTTP client packages' from Marc-André Moreau
Adds two managed .NET HTTP client packages and wires them into the
existing .NET build, test, packaging, and NuGet publishing paths.
### `Turso.Platform.Client`
- Adds a typed client for the Turso Platform API.
- Keeps the pinned OpenAPI specification, NSwag configuration, and
schema-normalization helper in source control.
- Generates the transformed OpenAPI document and C# client into the
MSBuild intermediate output directory (`obj`) during normal builds,
packs, and tests.
- Does not commit derived generated source files.
- Adds support for the Platform API's `extensions` value, which can be
either `"all"` or a list of extension names.
### `Turso.Serverless.Client`
- Adds a managed SQL-over-HTTP client implementing the Hrana pipeline
and cursor endpoints.
- Provides connection, session, transaction, batch, parameter binding,
result-reading, and streaming-cursor APIs.
- Preserves session baton and redirect state, serializes stateful
connection operations, and waits for in-flight work during disposal.
- Correctly tracks transaction state for both pipeline and cursor/batch
transaction-control statements, rolls back uncommitted transactions on
disposal, and avoids nested atomic batches inside interactive
transactions.
### Packaging and compatibility
- Targets the shared `$(TursoTargetFrameworks)` matrix (`net8.0`,
`net9.0`, and `net10.0`).
- Includes both packages in the NuGet publishing workflow.
- Adds package metadata, READMEs, XML documentation, and NSwag license
attribution.
- Adds regression coverage for Platform extensions serialization and
Serverless transaction/lifecycle behavior.
Provide supported managed .NET clients for Platform API operations and
serverless SQL-over-HTTP workloads, while making Platform client
generation reproducible without committing generated code.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #7834
2026-07-14 09:33:39 -07:00
Marc-André Moreau
2ae71fe902 bindings/dotnet: run NSwag on .NET 10
Align the NSwag build-time runtime with the OpenAPI schema transformation helper.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-07-14 08:31:15 -04:00
Pekka Enberg
e7cb62a8bd Turso 0.7.0 2026-07-13 18:12:11 +03:00
Marc-André Moreau
1e9754dcb2 bindings/dotnet: add HTTP client packages
Add managed clients for the Turso Platform API and serverless SQL-over-HTTP workloads.

Generate the Platform client during MSBuild from the pinned OpenAPI specification, keep generated artifacts out of version control, and use cross-platform generation paths.

Include package metadata, NuGet publishing integration, and regression coverage for Platform extensions plus Serverless transaction and lifecycle behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-07-13 11:05:38 -04:00
Pekka Enberg
4b18962902 Turso 0.7.0-pre.22 2026-07-13 17:38:12 +03:00