XServer-context caveats
The demo opens in FULLMUTEX mode (an open_v2 flag), so a single handle can serve callbacks from multiple workers — but cross-thread reuse of statement objects should still be avoided (keep prepare-through-finalize on one thread where possible).
The demo uses sqlite3_open_v2(path, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); paths are relative to the application directory (the db/ directory is shared across generations, ch. 05).
The default variant has none of these symbols — a script referencing sqlite3_* fails to compile (this behavior was verified experimentally in the ch. 02 exercise).
Connections & execution family
sqlite3_open_v2 / close / close_v2 connection
Open (flags control read-write / create / threading mode) and close. The demo's mode: READWRITE | CREATE + FULLMUTEX.
sqlite3_exec execution
One-step execution of result-free SQL (DDL, PRAGMA, simple writes) — the demo's table-creation path.
sqlite3_errmsg / sqlite3_errcode diagnostics
Error text and code — the first stop of troubleshooting (the demo prints them when opening fails).
The statement five-step (the parameterized-query backbone)
sqlite3_stmt* pStmt = NULL;
/* 1. prepare: SQL text -> statement object (? placeholders, no injection) */
sqlite3_prepare_v2(G_DB, sSQL, -1, &pStmt, NULL);
/* 2. bind: bind parameters by index (text via SQLITE_TRANSIENT copy) */
sqlite3_bind_text(pStmt, 1, sName, -1, SQLITE_TRANSIENT);
sqlite3_bind_int64(pStmt, 2, iId);
/* 3. step: advance one row (SELECT) or execute (writes) */
while ( sqlite3_step(pStmt) == SQLITE_ROW ) {
/* 4. column: read values by column */
int64 iId = sqlite3_column_int64(pStmt, 0);
const unsigned char* sName = sqlite3_column_text(pStmt, 1);
}
/* 5. finalize: release the statement - every prepare needs a finalize */
sqlite3_finalize(pStmt);
Family members: sqlite3_prepare_v2, sqlite3_bind_text/int64/int/double/null/blob, sqlite3_step, sqlite3_column_*, sqlite3_reset (statement reuse), sqlite3_finalize. Binding indices start at 1; column indices start at 0 — that off-by-one is the most common slip.
Transactions & batching family
BEGIN / COMMIT / ROLLBACKrun via exec or a statement; batch writes must be grouped (the demo's bench-write bulk insert is wrapped in a transaction)sqlite3_last_insert_rowid: retrieving an autoincrement primary keysqlite3_changes: affected row count- The backup/restore family (sqlite3_backup_*) is inside the export surface — hot-backup scripts can use it directly
Utilities family overview
The 272 exported symbols cover: the core v3 interface, blob IO, blob and text utilities, errors and status, memory statistics (sqlite3_memory_used etc.), runtime control (sqlite3_limit / busy_timeout), the disabled extension-loading domain, and more. The full list is in /xs/sqlite3.h inside the VFS (present only in the sqlite variant); for per-function semantics, consult the official SQLite documentation.