You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Modeled C: no facade form for a callback-scope handle (sqlite3_context, sqlite3_value): an SQL function's body needs unsafe for sqlite3_result_*, sqlite3_value_* and sqlite3_user_data (ruling §44, §66) #1611
Found by the SQLite facade (D51 stage 12, ruling §66) — a finding, not a decision: the ruling and the facade language as built (stages 5–9) disagree here, and the item is left raw.
Ruling §44: "A callback parameter passed from C into With is borrowed for callback scope by default … The default callback origin is the callback invocation itself." §31 lists "callback scope where applicable" among the principal origins of borrowed foreign memory.
sqlite3_create_function_v2's xFunc receives sqlite3_context * and sqlite3_value **. Neither is a resource (nothing produces or destroys them; they exist for the callback's duration), and the facade language has no way to say so: resource requires a producer and a destroyer (§16.2b.3, never half-model); lend on sqlite3_result_int(sqlite3_context *, int) is refused because the operation "receives no modeled resource" — a raw pointer stays raw. So a function body that returns a result, reads an argument or reaches its application data must write
— unsafe in an application program, which user-programs-safe forbids and §64 rules out.
Missing mechanism (to be ruled): a callback-scope handle — a foreign representation that is borrowed for the callback's invocation, has no Drop, cannot escape the callback (§44), and whose operations are lends of it; and, for the application data, a typed sqlite3_user_data — the value consumed with destroyed_by on registration, returned as a borrow of the callback scope (returns borrow U from callback). A draft spelling for the brief:
handle Context wraps *mut sqlite3_context // callback-scope: no producer, no drop
handle Value wraps *mut sqlite3_value
fn sqlite3_result_int
lend
fn sqlite3_user_data
returns userdata of sqlite3_create_function_v2 from param 0
What the SQLite fixtures do meanwhile: the registered function sets no result (it yields SQL NULL, which exercises the nullable column text) and touches no argument; xDestroy and retention are fully modeled and tested (behav_sqlite_facade_end_to_end.w, da_sqlite_facade_destroy_once.w).
build/release_uat_fixtures/sqlite3_main.w does not register a function, so this gap does not touch the UAT rewrite; examples/c-interop will, if it registers one.
Activity
D71 facade rulings: ok lists, valid on failed, callback-scope handles…