Skip to content
maragudkPublic

About

Resources

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

3,012 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

s4ql

Warning

This project is currently an experiment. It is not ready for use, and anything in it may change.

Docs CI

s4ql ("simple storage service + structured query language") is an embedded SQL database engine for Go, in the spirit of SQLite, but with all data stored in S3. It is ACID per database, speaks a strict subset of SQLite's SQL, and serves reads from a local SQLite cache that can be rebuilt from S3 at any time.

What has been agreed is in docs/spec.md, and the supported SQL is in docs/roadmap.md.

Made with ✨sparkles✨ by maragu: independent software consulting for cloud-native Go apps & AI engineering.

Contact me at markus@maragu.dk for consulting work, or perhaps an invoice to support this project?

Status

As of 2026-12-04:

  • Works now, through database/sql, with the package maragu.dev/s4ql as the driver:
    • create table and drop table of a strict table with one or more columns, exactly one of them the primary key, and a default with a literal on a column.
    • The column types int, integer, real, text, and blob. A value must have the exact type of its column.
    • Columns that are not null, and columns that take null.
    • insert of one row, with literals and arguments, with or without a list of columns. A column that the list leaves out gets its default.
    • select of named columns, *, and expressions, each with an optional as alias, with a where of comparisons, of is null and is not null, and of exists (select ...), joined by and. A comparison, is null, is not null, and exists (select ...) may also be result columns. A comparison may have its value on either side. Rows without order by come in a varying order. A select without from gives one row of values.
    • order by of one or more columns or aliases, each ascending or descending, and limit with a number or ?, on select. A limit needs an order by that holds the primary key, so that it gives the same rows every time.
    • A scalar subquery in a where, on the right or the left of a comparison, in a select, an update, and a delete. It is not correlated, and runs once before the statement changes anything. It fails when it finds more than one row.
    • Arithmetic: +, -, *, /, and a unary - on integers and reals, in the set of an update and in a where. An overflow, a division by zero, and an infinite result are errors. A column may be compared with a column of the same type.
    • Text: ||, lower, and hex, where arithmetic runs.
    • strftime of the current time, which is read once for each statement.
    • randomblob of the host's random bytes, which are new for each row and each call.
    • Upserts: insert ... on conflict (key) do nothing and do update set ... [where ...], with excluded.<column>, also in arithmetic and text.
    • update and delete, with or without that where. An update may change the primary key, and RowsAffected is what SQLite reports.
    • returning at the end of an insert, an update, and a delete, with column names or *. Outside a transaction, the statement commits before it gives its first row.
    • create index and drop index, on one or more columns, each ascending or descending, not unique. The engine picks the index for a where by fixed rules.
    • if not exists on create table and create index, and if exists on drop table and drop index.
    • Arguments for a plain ?, directly and through prepared statements.
    • Transactions, also read-only ones.
    • Several statements in one Exec, run one after another. Query and Prepare take one.
    • Storage: a database is a log of commits in S3, with a local SQLite cache. One instance at a time holds a lease on it. Commits, recovery after a crash, and replay of the log work.
    • Observability: structured log events through log/slog, and, if the caller passes a tracer provider in the options, OpenTelemetry spans for statements, transactions, commits, the lease, and each request to S3.
  • How it is checked: against SQLite with generated statements, in the engine and through database/sql, in a deterministic simulation with planted bugs, and with mutation testing and fuzzing. The storage is also tested against a real S3-compatible bucket in CI.
  • Not built: or, other functions and operators in a where, arithmetic and text in returning and values, aggregates, offset, more than one row per insert, and a statement while rows of the same transaction are open.
  • Next: what is decided next is in the roadmap by area: more operators and functions, and expressions in more places, grouping and joining, and a limit on the memory of an operator.

The roadmap by area, and the slices that were built with how each is checked, are in docs/roadmap.md. What is open in detail is in docs/todo.md.

About

Resources

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages