Materialize preupdate-hook callbacks as data.
Inside the callback everything must be copied out immediately - sqlite3_value handles die when it returns - and nothing else may touch the connection (the C rules forbid it). So the callback does the minimum: read column count and the old/new row through preupdate accessors, convert values, hand one map per row to on-event, return. Column names are resolved later, off the writer, by the engine, because asking sqlite for them requires preparing a statement.
Event shape (positional, names pending):
{:op :insert|:update|:delete
:table "t" ; as sqlite reports it
:rowid-old n? :rowid-new n? ; nil-able; undefined for
; WITHOUT ROWID tables
:old [v*]? :new [v*]?} ; old absent for insert,
; new absent for delete
Materialize preupdate-hook callbacks as data.
Inside the callback everything must be copied out immediately -
sqlite3_value handles die when it returns - and nothing else may
touch the connection (the C rules forbid it). So the callback does
the minimum: read column count and the old/new row through
preupdate accessors, convert values, hand one map per row to
on-event, return. Column names are resolved later, off the writer,
by the engine, because asking sqlite for them requires preparing a
statement.
Event shape (positional, names pending):
{:op :insert|:update|:delete
:table "t" ; as sqlite reports it
:rowid-old n? :rowid-new n? ; nil-able; undefined for
; WITHOUT ROWID tables
:old [v*]? :new [v*]?} ; old absent for insert,
; new absent for delete(install! db on-event)Install a preupdate hook; on-event receives one event map per changed row, on the writing thread. Returns the callback (keep it: the JNI layer holds it, but an explicit reference documents ownership). Replace by installing again; remove with uninstall!.
Install a preupdate hook; on-event receives one event map per changed row, on the writing thread. Returns the callback (keep it: the JNI layer holds it, but an explicit reference documents ownership). Replace by installing again; remove with uninstall!.
(on-rollback! db f)Install a rollback hook; f runs with no arguments whenever the current transaction rolls back (including implicit ones). The engine uses it to discard pending events.
Install a rollback hook; f runs with no arguments whenever the current transaction rolls back (including implicit ones). The engine uses it to discard pending events.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |