Skip to content

Modeled C: a callback contract cannot mark the callback optional; sqlite3_exec with no callback ("If the callback is NULL, no callback is invoked") needs a no-op fn (ruling §44) #1618

Closed

Description

@ehartford

Found by the SQLite facade (D51 stage 12, ruling §66) — a gap in the facade language, left as is.

fn sqlite3_exec / callback param 2 userdata param 3 renders exec[U](sql: &str, callback: extern "C" fn(&U, c_int, *mut *mut i8, *mut *mut i8) -> c_int, ud: &U, errmsg: *mut *mut i8). SQLite documents the callback as optional: "If the callback function of the 3rd argument to sqlite3_exec() is NULL, then no callback is ever invoked." The release UAT (build/release_uat_fixtures/sqlite3_main.w) runs DDL/DML through sqlite3_exec(db, sql, null, null, null); under the facade it must pass a no-op fn and a unit userdata — ceremony for something the C API already allows. The header does not state nullability (§43: unknown nullability is nullable), so a nullable callback would be Option[extern "C" fn(…)], None skipping the userdata slot.

Proposed: the pairing clause admits callback param 2 nullable (or reads machine-readable nullability when present), rendering Option[extern "C" fn(&U, …)]; with None the userdata is passed as null. Until then: db.exec(sql, (c, n, v, k) => 0, (), null).

Activity

  1. ehartford commented on Sep 27, 2026

    @ehartford
    ContributorAuthor

    Already implemented on main: a callback contract's callback may be marked nullable (nullable param N, ruling §43, spec §16.2b.8; SemaFacade.verify_facade_nullable_items), rendering Option[extern "C" fn(&U, …)]. Pinned by test/behavior/behav_sqlite_facade_exec_no_callback.w (None for callback and userdata, landed in 67f9449) and behav_sqlite_facade_end_to_end.w (Some(on_row), Some(Ctx { .. })), both green in the 2026-09-27 stack battery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions