@@ -414,6 +414,8 @@ final class FfiDatabase extends RawSqliteDatabase {
414414 final BindingsWithLibrary bindings;
415415 final Pointer <sqlite3> db;
416416 NativeCallable <_UpdateHook >? _installedUpdateHook;
417+ NativeCallable <_CommitHook >? _installedCommitHook;
418+ NativeCallable <_RollbackHook >? _installedRollbackHook;
417419
418420 FfiDatabase (this .bindings, this .db);
419421
@@ -566,6 +568,37 @@ final class FfiDatabase extends RawSqliteDatabase {
566568 previous? .close ();
567569 }
568570
571+ @override
572+ void sqlite3_commit_hook (RawCommitHook ? hook) {
573+ final previous = _installedCommitHook;
574+
575+ if (hook == null ) {
576+ _installedCommitHook = null ;
577+ bindings.bindings.sqlite3_commit_hook (db, nullPtr (), nullPtr ());
578+ } else {
579+ final native = _installedCommitHook = hook.toNative ();
580+ bindings.bindings
581+ .sqlite3_commit_hook (db, native .nativeFunction, nullPtr ());
582+ }
583+
584+ previous? .close ();
585+ }
586+
587+ @override
588+ void sqlite3_rollback_hook (RawRollbackHook ? hook) {
589+ final previous = _installedRollbackHook;
590+
591+ if (hook == null ) {
592+ bindings.bindings.sqlite3_rollback_hook (db, nullPtr (), nullPtr ());
593+ } else {
594+ final native = _installedRollbackHook = hook.toNative ();
595+ bindings.bindings
596+ .sqlite3_rollback_hook (db, native .nativeFunction, nullPtr ());
597+ }
598+
599+ previous? .close ();
600+ }
601+
569602 @override
570603 int sqlite3_db_config (int op, int value) {
571604 final result = bindings.bindings.sqlite3_db_config (
@@ -976,6 +1009,8 @@ typedef _XCompare = Int Function(
9761009 Pointer <Void >, Int , Pointer <Void >, Int , Pointer <Void >);
9771010typedef _UpdateHook = Void Function (
9781011 Pointer <Void >, Int , Pointer <sqlite3_char>, Pointer <sqlite3_char>, Int64 );
1012+ typedef _CommitHook = Int Function (Pointer <Void >);
1013+ typedef _RollbackHook = Void Function (Pointer <Void >);
9791014
9801015extension on RawXFunc {
9811016 NativeCallable <_XFunc > toNative (Bindings bindings) {
@@ -1029,3 +1064,24 @@ extension on RawUpdateHook {
10291064 )..keepIsolateAlive = false ;
10301065 }
10311066}
1067+
1068+ extension on RawCommitHook {
1069+ NativeCallable <_CommitHook > toNative () {
1070+ return NativeCallable .isolateLocal (
1071+ (Pointer <Void > _) {
1072+ return this ();
1073+ },
1074+ exceptionalReturn: 1 ,
1075+ )..keepIsolateAlive = false ;
1076+ }
1077+ }
1078+
1079+ extension on RawRollbackHook {
1080+ NativeCallable <_RollbackHook > toNative () {
1081+ return NativeCallable .isolateLocal (
1082+ (Pointer <Void > _) {
1083+ this ();
1084+ },
1085+ )..keepIsolateAlive = false ;
1086+ }
1087+ }
0 commit comments