Skip to content

Modeled C: no clause marks an operation valid on the failure-state resource; sqlite3_errmsg on a failed open (FailedDatabase) stays raw (ruling §18; spec §16.2b.4) #1612

Closed

Description

@ehartford

Found by the SQLite facade (D51 stage 12, ruling §66) — a finding, not a decision; the item is left raw.

Spec §16.2b.4: "A resource owned by an error admits raw access only, unless the facade marks an operation as valid on the failure state; it is carried as a distinct type (FailedDatabase) that has no presented methods." Ruling §18: "A facade-specific error type may itself temporarily own the failure-state resource where required."

The facade language (stages 5–9) has the error type and the distinct failed-state type (D59), and no clause that marks an operation valid on it. SQLite's documented use of the failed handle is exactly one such operation: "if an error occurs … an error code is returned … Otherwise an error code is returned. The sqlite3_errmsg() or sqlite3_errmsg16() routines can be used to obtain an English language description of the error following a failure of any of the sqlite3_open() routines." So a program that wants the message of a failed open writes unsafe { sqlite3_errmsg(failed.repr) } on the FailedDatabase the error carries — raw access, unsafe in an application program.

Missing mechanism (to be ruled): a clause on the fn item, e.g.

    fn sqlite3_errmsg
        returns borrow CStr from param 0
        valid on failed                // presented on FailedDatabase as well

rendering the same lend/text-view method on the failed-state type (a view of it, invalidated by nothing else since nothing else is callable on it).

The SQLite fixtures match DatabaseError.FailedWithResource(status, failed) and report the status (SQLITE_CANTOPEN); the handle is closed when the error is dropped, which the debug-alloc fixture covers.

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