wasm_sqlite_proto (wasm_sqlite v0.1.0)

View Source

Encodes requests to the SQLite guest and decodes its responses: the Erlang half of engines/sqlite/src/abi.c, described in docs/abi.md.

Values cross as: null; an integer (64-bit signed); a float; a binary (TEXT); {blob, Binary} (BLOB). {text, IoData} is accepted as a parameter too.

Summary

Functions

Decode the body of a successful response to Op (not step).

Decode N rows of NCols values. Returns the rows (lists) and what follows them. For step, the body is <<Done, N:32/little, Rows, State>>.

Decode the body of a step response, <<Done, N:32/little, Rows, State>>, for a statement of NCols columns.

Whether an error means the guest's state can no longer be trusted.

The decoded response of an exec or a query that changed nothing and left the connection free, as decode/2 would return it.

Encode statement parameters. Raises {badarg, {sqlite_value, V}} for a value SQLite cannot hold: call it in the caller's process, so that a bad argument fails there and not in the database process.

The atom of a SQLite result code, or of an ABI error.

Who needs the connection to themselves, from the state byte that ends a response: transaction while one is open, statement while a write statement is stepped part way (it holds back every other write's commit until it is reset or done), free otherwise.

The connection state a step response ends with (state/1).

Types

value()

-type value() :: null | integer() | float() | binary() | {blob, binary()}.

Functions

backup(Path)

bind(Stmt, Params)

close()

decode/2

Decode the body of a successful response to Op (not step).

decode_rows(Bin, NCols, N)

Decode N rows of NCols values. Returns the rows (lists) and what follows them. For step, the body is <<Done, N:32/little, Rows, State>>.

decode_step/2

-spec decode_step(binary(), non_neg_integer()) -> map().

Decode the body of a step response, <<Done, N:32/little, Rows, State>>, for a statement of NCols columns.

exec(Sql)

fatal(Reason)

Whether an error means the guest's state can no longer be trusted.

finalize(Stmt)

info()

no_effect/1

-spec no_effect(exec | query) -> map().

The decoded response of an exec or a query that changed nothing and left the connection free, as decode/2 would return it.

open(Path, ReadOnly)

params(Params)

Encode statement parameters. Raises {badarg, {sqlite_value, V}} for a value SQLite cannot hold: call it in the caller's process, so that a bad argument fails there and not in the database process.

prepare(Sql)

query(Sql, Params, Max)

reason/1

The atom of a SQLite result code, or of an ABI error.

reset(Stmt)

state()

state/1

-spec state(byte()) -> transaction | statement | free.

Who needs the connection to themselves, from the state byte that ends a response: transaction while one is open, statement while a write statement is stepped part way (it holds back every other write's commit until it is reset or done), free otherwise.

step(Stmt, Max)

step_state(Body)

-spec step_state(binary()) -> transaction | statement | free.

The connection state a step response ends with (state/1).