Database support — 0.18.0 Developer Preview
Redis basic-key operations are now callable from ThreadOne programs. PostgreSQL now has native record lookup/execute bindings with strict scalar/Optional codecs and bound parameters. Published 0.16.0 adds a bounded pool; 0.17.0 adds transaction callbacks. See PostgreSQL records and transactions. SDK0.18.0 adds MySQL/MariaDB find/execute language bindings with separate live-server evidence and49 passing exact-ZIP installed tests. The same artifact passed six generated-language tests per engine without failures or skips; the versioned report identifies its hash and exact scope. The current source adds MongoDB typed-document language bindings; consult the matching release report before treating source tests as final SDK artifact evidence. SQL Server remains an experimental Rust adapter without a language binding. Five adapter groups compile. Redis has historical real-server evidence from 0.4; current-release results and any new failure cases are recorded separately in the versioned validation report. None is being presented as complete production driver support.
| Database | Native foundation | Available today | Real-server evidence |
|---|---|---|---|
| Redis | redis-rs asynchronous client | .one PING, GET/find, SET with TTL, DEL; verified TLS by default, bounded admission/deadlines | Historical 0.4 basic-key round-trip against isolated Redis 8.4.8 on macOS arm64; see the release validation report for current checks |
| Dragonfly | Redis protocol adapter | Same basic-key native adapter; compatibility remains a target | Not verified |
| PostgreSQL | tokio-postgres + verified TLS | Published single-record find/execute, bounded pool and 0.17.0 named Bool! transaction callbacks | Versioned PostgreSQL17.6 source/live and exact SDK evidence; see the release report |
| MySQL / MariaDB | mysql_async + verified TLS | 0.18.0 single-record find/execute; positional values, strict result records and per-call sessions; no language pool/transaction API | Exact ZIP:49 installed tests plus six generated-language tests on each of MySQL8.4.8 and MariaDB11.8.9; no failures/skips; see versioned report |
| MongoDB | Official MongoDB Rust driver with strict scalar BSON codecs | Native typed find/insert/replace/delete by application String _id; shared client, bounded admission and verified TLS; no transaction API | Typed Rust foundation: 11 unit, five typed live and one raw live test on owned MongoDB 7.0.48; language and exact-artifact results belong in the matching release report |
| SQL Server | Tiberius asynchronous TDS client with rustls | Experimental Rust session; SQL authentication, bound parameters, bounded rows, verified TLS and cancellation poisoning | Not verified |
| SQLite | Planned maintained library with an explicit blocking boundary | Design only | Not verified |
The native workspace is drivers/. SDK 0.18.0 contains the Redis, PostgreSQL and MySQL/MariaDB adapters needed by its generated applications. The MongoDB source integration must also carry its complete vendored graph and pass exact-artifact gates before a new SDK is considered released. A compiled adapter is not proof of wire compatibility, transaction behavior, recovery or platform support. The PostgreSQL binding has a bounded pool; other SQL adapters do not yet provide an equivalent language-level pool/transaction lifecycle. MongoDB's driver can perform topology monitoring/background work; the single application executor does not make every dependency single-threaded.
PostgreSQL transaction API
postgres_transaction(handler [, record]) -> Bool! runs a named Bool! function on one exclusive pooled transaction. A successful true or false commits; fail requests rollback. Database errors or nested transaction attempts prevent commit even if handled. Callback database calls use task-local state, keeping concurrent HTTP requests separate. The SQL subset is one prepared SELECT/INSERT/UPDATE/DELETE/WITH statement per call; explicit transaction control, DDL, CALL and DO are rejected inside the callback. This is an ownership boundary, not a SQL security sandbox.
The language uses READ COMMITTED / READ WRITE with a 30-second total cooperative deadline and operations bounded to five seconds or remaining time. It does not expose transaction handles, savepoints, anonymous callbacks or the Rust adapter's isolation/read-only options. Cancellation disposes the local connection but does not prove immediate server query termination. A lost COMMIT response can leave unknown outcome; no write or transaction is automatically retried. See the complete contract and example. Versioned fixture/artifact evidence defines the tested release scope.
MySQL and MariaDB language API
mysql_find(sql, [parameters,] RecordType) -> RecordType?! and mysql_execute(sql [, parameters]) -> Int! use one verified-TLS session per call. Parameter-record fields bind positionally to ?; strict result metadata/NULL decoding applies even to empty results. MySQL/MariaDB may still coerce bound values into target columns, and Optional none loses its scalar kind in protocol NULL encoding. This is not the PostgreSQL parameter-kind contract.
The binding has no MySQL pool or transaction language API. There are eight active binding slots,32 pending waiters, a five-second acquisition wait and five-second connect/statement budget, plus one-second established-session cleanup; upstream handshake-cancellation cleanup is not fully tracked by the adapter. Cancellation/disconnect does not prove immediate server stop, and writes are never automatically retried. Separate source-generated tests passed against MySQL8.4.8 and MariaDB11.8.9. The exact SDK passed49 installed tests with no skips; the same artifact passed six generated-language tests per engine with no failures or skips, recorded separately in the versioned report. Broader server/platform support requires independent validation. See the bilingual contract and [example setup](../sdk/examples/mysql-README.md).
MongoDB document API
mongodb_find(collection, id, RecordType) -> RecordType?! finds one exact application-supplied String _id. mongodb_insert(collection, record) -> String! returns that supplied ID; mongodb_replace(collection, record) -> Int! replaces the whole document without upsert and returns matched count; mongodb_delete(collection, id) -> Int! returns deleted count. The API accepts flat Int/Bool/String/Optional records with required _id: String. Reads match fields by name, reject unknown/unsupported fields, and distinguish missing documents from errors. Missing Optional fields and BSON NULL intentionally share none; Optional none writes NULL.
Configure THREADONE_MONGODB_URL and the separately required THREADONE_MONGODB_DATABASE outside source. Verified TLS is mandatory; a private CA can use tlsCAFile in the URI. The shared client retains its first successful configuration until process exit. Limits are eight active calls, 32 admission waiters, five seconds waiting plus five seconds initialization/operation, and a 1 MiB BSON document. Read limits apply after driver decoding and before cumulative arena copies. Driver background tasks and per-server pools are additional; eight calls is not a global connection or server-work cap.
No automatic ObjectId conversion, arbitrary filters, multi-document results, sessions or transaction API is exposed. MongoDB calls do not join PostgreSQL transactions. Driver retries are disabled; timeout or cancellation can leave an applied write's outcome unknown. Reconcile by _id rather than assuming rollback. See the English/Thai contract and [example setup](../sdk/examples/mongodb-README.md). Server/version and source/exact-artifact evidence remain separate.
Use the Redis language binding
Configure THREADONE_REDIS_URL outside source code, then run this as a normal ThreadOne program:
fn main():
print(redis_ping() or "Redis unavailable")
saved = redis_set("threadone:example", "Hello from ThreadOne", 60_000) or false
if saved:
print(redis_get("threadone:example") or "Key missing or read failed")
print(redis_delete("threadone:example") or 0)
Remote connections require a rediss:// URL and verified server certificates/hostnames. For an isolated local development server only, opt into plaintext with both THREADONE_REDIS_ALLOW_LOCAL_PLAINTEXT=1 and a loopback redis:// URL. Do not place real credentials in source, shared examples or the browser playground.
| Built-in | Preview contract |
|---|---|
redis_ping() -> String! | Returns the server response or a handled error |
redis_get(key: String) -> String! | Compatibility API: UTF-8 text; missing key, invalid UTF-8 and command failure are errors |
redis_find(key: String) -> String?! | UTF-8 text when present; successful missing key is none; command/connection, invalid UTF-8 and oversized-value failures remain errors |
redis_set(key: String, value: String, ttl_ms: Int) -> Bool! | Positive TTL in milliseconds is required; success returns true |
redis_delete(key: String) -> Int! | Returns the number of keys removed |
The binding uses a shared client and an admission limit of 32. Each adapter operation has a five-second deadline; the first call also initializes the shared connection before issuing its command. GET/find/SET/DEL reject keys over 4,096 UTF-8 bytes before connection setup. SET rejects values over 1 MiB and nonpositive TTL; adapter durations must fit positive signed milliseconds. Redis may also reject an expiry that overflows its absolute timestamp. GET/find and PING reject decoded replies over 1 MiB before copying to the request arena. Empty keys and empty text remain valid. Reply limits apply after the driver receives/decodes the value; they do not bound wire allocations or total process RSS. These are preview limits, not complete resource isolation.
See the library completion plan for the implementation queue and the current release report for named suites and platform evidence.
No await is required in source. Calls suspend cooperatively in generated code. The preview does not expose typed database error variants yet.
Distinguish a cache miss from an outage
redis_find returns a fallible Optional. A missing key is a successful none; a present UTF-8 value is some(text), including an empty string. Handle the command error first and absence second:
fn cached_text(key: String) -> String:
result = redis_find(key) or return "Cache unavailable"
return result or "Cache miss"
fn main():
print(cached_text("threadone:example"))
The first or chooses the application's failure response. The second chooses its cache-miss response, and is not evaluated for a present value. Connection/protocol failure, invalid UTF-8 and a returned value over 1 MiB stay on the error channel. This distinction prevents an outage from being silently treated as normal absence. redis_get keeps its original missing-key-as-error behavior for existing programs. See sdk/examples/redis-optional.one.
A timed-out or cancelled write may already have reached the server. There is no automatic safe-write retry guarantee: reconcile the result or use a documented idempotency strategy. Cancelling a client future does not prove the server cancelled its command.
Native adapter validation
The Rust workspace has opt-in real-server tests. They must target dedicated fixtures and be explicitly enabled; ordinary unit tests do not contact existing databases. The historical 0.4 run used an isolated native Redis fixture because Docker was unavailable. An older MySQL fixture initialization attempt failed before queries; SDK0.18.0 has separate successful MySQL8.4.8 and MariaDB11.8.9 fixtures. The historical0.14.1 release was checked on Linux x86_64: all five adapter groups compile, 18 library unit tests pass, and the exact SDK passes 21 native HTTP/Redis cases against an isolated Redis 8.4.0. That 0.14.1 evidence did not include non-Redis live tests. SDK0.15.0 separately adds12 actual PostgreSQL17.6 TLS adapter tests and7 generated-language tests, including typed NULL, schema/input/result bounds, authentication/TLS rejection and cancellation/deadline behavior. See the current versioned report for exact-artifact results. The separate0.18.0 MySQL8.4.8/MariaDB11.8.9 source fixtures are newer evidence, not a reinterpretation of those historical tests. The later MongoDB typed Rust foundation passed its independently recorded MongoDB 7.0.48 verified-TLS fixture; this is not a retrospective pass for an older SDK or an exact-artifact language pass. SQL Server and Dragonfly still need their own live evidence.
Redis protocol compatibility is not full Dragonfly compatibility. Verify the actual server versions and the exact commands, transactions, Lua, cluster, pub/sub and failure behavior needed by an application. These features are not implied by the current basic-key API.
MongoDB 7.0.48 foundation evidence is recorded in docs/validation/2026-12-04-mongodb-foundation. MongoDB 8.0.38 could not start in that environment because TCMalloc required unavailable sysfs CPU files, so no 8.x compatibility pass is claimed. Current language-binding, package and publication status belongs to the checkpoint and matching release report.
Required before stable database support
- Strict database codecs using the implemented records/Optional model, plus decimal, timestamp and byte types that remain missing. SQL NULL must map to Optional without silent narrowing or precision loss. Bind values; never construct SQL by concatenating user input. Treat BSON operator documents as application code rather than trusting arbitrary input.
- A bounded connection pool per runtime shard: acquisition deadline, maximum size, idle/lifetime expiry, health checks, graceful close, leaked-lease detection and metrics. Define which state belongs to a connection and which can be shared.
- Transaction-scoped leases and explicit commit/rollback effects. Commit cancellation or disconnection can have an unknown outcome. Reuse only sessions whose protocol and transaction state is known; retry only under an explicit idempotency contract.
- Verified TLS by default, tested authentication modes, secrets/rotation, redacted diagnostics and explicit trust-store configuration. No production insecure mode.
- End-to-end connect/acquire/query/transaction deadlines, cancellation behavior, backpressure, per-request budgets and arena lifetime tests. Bound result bytes and support streaming without retaining unbounded rows.
- Versioned migrations with checksums, locking, dry-run, rollback/forward-recovery strategy and compatible rollout. Require an explicit target and operator action; never auto-migrate at server start.
- Real PostgreSQL, MySQL, MariaDB, MongoDB, SQL Server, Redis and Dragonfly compatibility tests on supported Linux and Windows versions. Cover invalid TLS/auth, restart, network drop, saturation, rollback, commit ambiguity and cancellation.
- Tracing and metrics with query fingerprints rather than values, slow-query sampling and bounded logs. Do not log credentials or personal data by default.
The full backend roadmap also needs further HTTP/JSON protocol hardening, authentication/authorization, request IDs, health/readiness, rate limits, outbox/idempotent background jobs, configuration/secrets, deployment runbooks and security review. See Production release gates.