API reference › @evolu/sqlite-wasm › SqliteScratch

Defined in: packages/sqlite-wasm/src/Memory.ts:143

Reusable memory for output parameters and bind values, allocated once per database instead of once per call.

A callback inside a call, such as a collation-needed callback or a trace callback, can run another call on the same database, which reuses this memory. The outer call is unaffected, because SQLite copies a value bound with SQLITE_TRANSIENT at once and writes an output parameter after the callbacks of the call. What SQLite reads or writes before a callback and the caller uses after it needs memory of its own: SQL, which SQLite parses in place and copies only after the parse, and the size sqlite3_serialize writes before it finalizes its query.

Extends

Properties

out

readonly out: WasmPtr;

Defined in: packages/sqlite-wasm/src/Memory.ts:148

Sixteen bytes, 8-byte aligned, for output parameters such as ppDb, ppStmt and pzTail.


reserve

readonly reserve: (byteLength: number) => Result<WasmPtr, SqliteNoMemError>;

Defined in: packages/sqlite-wasm/src/Memory.ts:160

Returns memory of at least the given length, growing it when needed. The previous contents are not kept, and the address is valid until the next call. Growth doubles the capacity, so reallocations stay rare as values grow, or, when that much memory is not available, allocates the length alone. A failure leaves the scratch empty, so later calls are unaffected.

Binding text or a blob from here with SQLITE_TRANSIENT is faster than allocating per value: SQLite copies into a buffer it reuses.

Methods

[dispose]()

[dispose](): void;

Defined in: node_modules/@typescript/old/lib/lib.esnext.disposable.d.ts:34

Inherited from

Disposable.[dispose]