SQLite formatting and variadic calls


SQLite's formatting and configuration functions use the C variadic calling convention. The bindings ending in a terminal ellipsis describe calls with no anonymous arguments. For other call shapes, define a typed alias with every argument required by the format string or operation code:
LIBRARY: sqlite FUNCTION-ALIAS: sql-format char* sqlite3_mprintf ( c-string format, ... c-string name, int count, double value ) "%Q:%d:%.2f" "O'Brien" 42 1.25 sql-format

The result is an owned pointer. Decode it with alien>string and release it with sqlite3_free, including on exceptional exits. SQLite's %Q conversion quotes SQL string literals. The FFI does not infer argument types from format strings.

sqlite3_vmprintf, sqlite3_vsnprintf, and sqlite3_str_vappendf accept the canonical va_list type from alien.varargs. On ARM64, pass a cursor borrowed from a callback; forwarding preserves the Factor cursor's position by passing an independent native copy.

Compatibility: sqlite3_mprintf and sqlite3_str_finish now return raw owned char* pointers instead of copied Factor strings, so callers can release their allocations. sqlite3_snprintf now declares its writable buffer and result as char*; the returned pointer aliases the supplied buffer. Their stack arities are unchanged. sqlite3_str_value continues to copy SQLite's borrowed string.

sqlite3_config, sqlite3_db_config, sqlite3_vtab_config, sqlite3_test_control, and sqlite3_log also have terminal ellipses. Supply typed aliases for operations or formats that require arguments. The zero-tail bindings do not supply missing parameters. SQLite's threading, initialization, and operation-specific restrictions still apply.
sqlite3_mprintf ( format -- char* )

sqlite3_vmprintf ( format args -- char* )

sqlite3_snprintf ( size buffer format -- char* )

sqlite3_vsnprintf ( size buffer format args -- char* )

sqlite3_str_finish ( builder -- char* )

sqlite3_str_appendf ( builder format -- )

sqlite3_str_vappendf ( builder format args -- )