aboutsummaryrefslogtreecommitdiff
path: root/callback.go
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2017-07-07 09:26:25 +0900
committerGitHub <noreply@github.com>2017-07-07 09:26:25 +0900
commit9cbb0970444f7ee9ccc65376394a504150b25de1 (patch)
tree491303da78f95a9a48126527f9f873ff4600134b /callback.go
parentSQLITE_THREADSAFE=1 (diff)
parentMerge pull request #2 from mattn/master (diff)
downloadgolite-9cbb0970444f7ee9ccc65376394a504150b25de1.tar.gz
golite-9cbb0970444f7ee9ccc65376394a504150b25de1.tar.xz
Merge pull request #434 from toba/master
Add functions to register update, commit, and rollback hooks (re-opened)
Diffstat (limited to 'callback.go')
-rw-r--r--callback.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/callback.go b/callback.go
index 48fc63a..6a55964 100644
--- a/callback.go
+++ b/callback.go
@@ -53,6 +53,24 @@ func doneTrampoline(ctx *C.sqlite3_context) {
ai.Done(ctx)
}
+//export commitHookTrampoline
+func commitHookTrampoline(handle uintptr) int {
+ callback := lookupHandle(handle).(func() int)
+ return callback()
+}
+
+//export rollbackHookTrampoline
+func rollbackHookTrampoline(handle uintptr) {
+ callback := lookupHandle(handle).(func())
+ callback()
+}
+
+//export updateHookTrampoline
+func updateHookTrampoline(handle uintptr, op int, db *C.char, table *C.char, rowid int64) {
+ callback := lookupHandle(handle).(func(int, string, string, int64))
+ callback(op, C.GoString(db), C.GoString(table), rowid)
+}
+
// Use handles to avoid passing Go pointers to C.
type handleVal struct {