resta

SQL support and limits

Resta databases speak the SQLite dialect and store data in the SQLite file format; a few statements that could reach outside the database file are blocked, and every request runs under size and time limits. Most SQLite SQL works unchanged: tables, indexes, views, triggers, CTEs, JSON functions, generate_series, transactions and savepoints.

Engine

Resta runs Turso 0.8, an SQLite-compatible engine written in Rust. Turso tracks SQLite 3.50 and is not yet 100% compatible; its compatibility list shows what is missing. Database files are SQLite files: a snapshot opens in the sqlite3 command-line tool.

Blocked statements

These return the error code BLOCKED, because they could read or write files on the server other than the database’s own:

StatementWhy
ATTACH, DETACHWould open another file.
VACUUM, VACUUM INTOVACUUM INTO writes to any path. Snapshots use it internally.
CREATE VIRTUAL TABLENo modules are offered.
CREATE TEMP TABLE / VIEW / TRIGGERTemp objects live in server memory, outside the size limit.
load_extension(), sqlite_dbpageNative code and raw pages.
Most PRAGMAsOnly those that touch the database’s own data or session are allowed.

Allowed pragmas: application_id, defer_foreign_keys, encoding, foreign_key_check, foreign_key_list, foreign_keys, freelist_count, function_list, ignore_check_constraints, index_info, index_list, index_xinfo, integrity_check, page_count, page_size, quick_check, recursive_triggers, schema_version (read), table_info, table_list, table_xinfo, user_version. Of these, only application_id, defer_foreign_keys, foreign_keys, ignore_check_constraints, recursive_triggers and user_version can be set.

Limits

LimitDefaultWhat happens
Database size1 GiBWrites past it fail with SQLITE_FULL.
Statement time5 sThe statement fails with SQLITE_INTERRUPT.
Request time30 sThe request fails with 408.
Request body10 MiB413.
Response size (pipeline)10 MiBRESPONSE_TOO_LARGE; use LIMIT or the cursor endpoint, which streams.
Statements per pipeline, steps per batch1,000 each400.
Concurrent requests per server256503; retry with backoff.

The defaults can be changed: see Configuration.

Writers

Each database allows one writer at a time, as in SQLite. Writes to the same database queue; writes to different databases run in parallel. This is one reason to split data into many databases.

Error codes

SQL errors use SQLite’s codes: SQLITE_CONSTRAINT (with extended_code such as SQLITE_CONSTRAINT_UNIQUE), SQLITE_ERROR, SQLITE_BUSY, SQLITE_FULL, SQLITE_INTERRUPT, plus SQL_PARSE_ERROR, SQL_INPUT_ERROR (wrong argument count), SQL_MANY_STATEMENTS, and BLOCKED.

Updated · View as Markdown