API reference › @evolu/sqlite-wasm › c-api › sqlite3_db_config

function sqlite3_db_config(
  deps: SqliteWasmDep,
): (db: SqliteDbPtr, ...args: SqliteDbConfigArgs) => SqliteResultCode;

Defined in: packages/sqlite-wasm/src/CApi.ts:3308

Changes or reads an option of a connection, returning SQLITE_OK or an error code.

  • SQLITE_DBCONFIG_MAINDBNAME renames the main schema to zName, which SQLite does not copy, so it must stay unchanged until the connection closes.
  • SQLITE_DBCONFIG_LOOKASIDE sets the connection's lookaside allocator to cnt slots of sz bytes in buf, which must be 8-byte aligned and hold sz times cnt bytes, or in memory SQLite allocates for a NULL buf. It fails with SQLITE_BUSY while lookaside memory is in use.
  • SQLITE_DBCONFIG_FP_DIGITS sets the significant digits of floating-point to text conversion to value when it is from 4 to 23, leaving the setting unchanged otherwise, and writes the resulting setting to the int at pResult unless it is NULL.
  • Every other option is a flag: a positive value sets it, 0 clears it and a negative value only reads it, and the resulting 0 or 1 is written to the int at pResult unless it is NULL. Changing a flag expires the connection's prepared statements.

The C function is variadic, so the binary does not export it. This calls the build's shim for the option's arguments and, as SQLite's JavaScript does, returns SQLITE_MISUSE for any other option without calling wasm.

Calls the build's shims, whose signatures come from Evolu's metadata because SQLite's table omits them:

  • sqlite3__wasm_db_config_s, wasm type i(iii), signature ["sqlite3__wasm_db_config_s", "int", "sqlite3*", "int", "string"].
  • sqlite3__wasm_db_config_pii, wasm type i(iiiii), signature ["sqlite3__wasm_db_config_pii", "int", "sqlite3*", "int", "*", "int", "int"].
  • sqlite3__wasm_db_config_ip, wasm type i(iiii), signature ["sqlite3__wasm_db_config_ip", "int", "sqlite3*", "int", "int", "int*"].

See https://sqlite.org/c3ref/db_config.html.