Documentation
¶
Overview ¶
Package lightsql is a small, embeddable SQL engine that speaks the PostgreSQL dialect and plugs into database/sql.
It is aimed at two situations: unit tests that need a real SQL engine without a container, and small demo deployments whose data fits in memory. It is not a general-purpose database; see the non-goals in README.md.
The engine can be used two ways. The preferred form builds a connector explicitly, which keeps configuration in Go and involves no global state:
db := sql.OpenDB(lightsql.NewConnector(lightsql.WithMemory()))
The convenience form registers a driver under the name "lightsql", where the data source name selects a named in-memory instance or a directory:
db, err := sql.Open("lightsql", "mytest")
db, err := sql.Open("lightsql", "file:./demo.db")
A directory-backed database appends every committed transaction to a write-ahead log before reporting the commit, and rebuilds itself from that log when it is opened again.
The public API is still being built out; today this package only carries the module's documentation and the invariants enforced by its tests.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package driver registers lightsql with database/sql under the name "lightsql".
|
Package driver registers lightsql with database/sql under the name "lightsql". |
|
internal
|
|
|
ast
Package ast defines lightsql's abstract syntax tree.
|
Package ast defines lightsql's abstract syntax tree. |
|
binder
Package binder resolves a parsed statement against the catalog, producing a plan.
|
Package binder resolves a parsed statement against the catalog, producing a plan. |
|
builtin
Package builtin holds lightsql's function library.
|
Package builtin holds lightsql's function library. |
|
catalog
Package catalog holds the schema metadata: which tables exist, what columns they have, and what constraints apply.
|
Package catalog holds the schema metadata: which tables exist, what columns they have, and what constraints apply. |
|
engine
Package engine ties the stages together: it owns a catalog and turns SQL text into results.
|
Package engine ties the stages together: it owns a catalog and turns SQL text into results. |
|
exec
Package exec runs a bound plan.
|
Package exec runs a bound plan. |
|
features
Package features is the single source of truth for lightsql's SQL compatibility matrix.
|
Package features is the single source of truth for lightsql's SQL compatibility matrix. |
|
parser
Package parser turns a token stream into a typed AST.
|
Package parser turns a token stream into a typed AST. |
|
pgerr
Package pgerr defines lightsql's structured error type and the SQLSTATE codes it reports.
|
Package pgerr defines lightsql's structured error type and the SQLSTATE codes it reports. |
|
plan
Package plan defines the bound representation of a statement: the form the binder produces and the executor consumes.
|
Package plan defines the bound representation of a statement: the form the binder produces and the executor consumes. |
|
scanner
Package scanner turns SQL text into a stream of tokens.
|
Package scanner turns SQL text into a stream of tokens. |
|
storage
Package storage holds the row heap and the transaction manager.
|
Package storage holds the row heap and the transaction manager. |
|
token
Package token defines the lexical tokens of the PostgreSQL dialect understood by lightsql, along with the source positions attached to them.
|
Package token defines the lexical tokens of the PostgreSQL dialect understood by lightsql, along with the source positions attached to them. |
|
types
Package types defines lightsql's SQL type system: the runtime representation of a single column value, its three-valued comparison semantics, and the conversions to and from Go types at the driver boundary.
|
Package types defines lightsql's SQL type system: the runtime representation of a single column value, its three-valued comparison semantics, and the conversions to and from Go types at the driver boundary. |
|
wal
Package wal is lightsql's write-ahead log: the on-disk record of everything a committed transaction changed, and the means of replaying it after a restart.
|
Package wal is lightsql's write-ahead log: the on-disk record of everything a committed transaction changed, and the means of replaying it after a restart. |