Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
2.1 kB · 46 lines
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647//// What a SQLite connection reports about itself that sqlight does not//// expose, and a close that is complete when it returns. A//// `sqlight.Connection` is esqlite's connection, so the binding reads it//// directly.
import sqlight
/// Whether `connection` is outside every transaction and savepoint, SQLite's/// autocommit mode.@external(erlang, "esqlite3", "get_autocommit")pub fn autocommit(connection: sqlight.Connection) -> Bool
/// Closes `connection` before it returns. Call it from the process that ran/// the connection's queries, and use it instead of `sqlight.close`.////// esqlite finalizes a statement only when the garbage collector frees its/// term, and `sqlight.query` leaves every statement to it. `sqlight.close`/// calls `sqlite3_close_v2`, which keeps a connection with a statement not/// yet finalized open until that statement is. The connection's file/// handles and locks stay open meanwhile. If it is the database's last/// connection, its checkpoint and its removal of the `-shm` and then the/// `-wal` file run whenever a later collection or the process's exit frees/// the statement. A reader of the files at that moment can find a log that/// holds commits but has no index.////// A full collection of the calling process first frees each statement it/// no longer references, so the close happens here. A statement the caller/// still holds keeps the connection open, as before. sqlight never hands/// one out.pub fn close(connection: sqlight.Connection) -> Result(Nil, sqlight.Error) { let _ = garbage_collect() sqlight.close(connection)}
/// Finalizes the statements the calling process left on `connection`. A/// process that ran queries on a connection another process owns calls it/// before it hands the connection back: the owner's `close` collects only the/// owner's garbage, so a statement left in the borrower would keep the/// connection open after that close returns.pub fn release(_connection: sqlight.Connection) -> Nil { let _ = garbage_collect() Nil}
@external(erlang, "erlang", "garbage_collect")fn garbage_collect() -> Bool