serialize-transaction ( quot -- )


Vocabulary
db

Inputs
quota quotation


Outputs
None

Word description
Calls quot, which performs one unit of write work: either a complete transaction (from with-transaction) or a single autocommit write (from insert-tuple, update-tuple, or delete-tuples), holding db-write-lock for the duration of the call. When the backend has no write lock the quotation is called directly.

Notes
This word is inline, so the stack effect of quot passes through unchanged. Operations not routed through it automatically, such as DDL (Data Definition Language) or a bare sql-command, can be serialized by wrapping them in with-transaction or by calling this word directly.

Examples
On SQLite, route a one-off DDL statement (which is not serialized automatically) through the per-file write lock by calling this word directly. CREATE TABLE IF NOT EXISTS keeps the snippet repeatable:
USING: db db.sqlite ; "/tmp/example.db" <sqlite-db> [ [ "CREATE TABLE IF NOT EXISTS items (n INTEGER)" sql-command ] serialize-transaction ] with-db


Definition