Index: third_party/sqlite/src/test/hook.test |
diff --git a/third_party/sqlite/src/test/hook.test b/third_party/sqlite/src/test/hook.test |
index b526708e0d49028d2b50926db58f94989753910f..6496d41e137bbaf909967c7d5fc2876657411bb2 100644 |
--- a/third_party/sqlite/src/test/hook.test |
+++ b/third_party/sqlite/src/test/hook.test |
@@ -334,4 +334,31 @@ do_test hook-5.2.2 { |
# End rollback-hook testing. |
#---------------------------------------------------------------------------- |
+#---------------------------------------------------------------------------- |
+# Test that if a commit-hook returns non-zero (causing a rollback), the |
+# rollback-hook is invoked. |
+# |
+proc commit_hook {} { |
+ lappend ::hooks COMMIT |
+ return 1 |
+} |
+proc rollback_hook {} { |
+ lappend ::hooks ROLLBACK |
+} |
+do_test hook-6.1 { |
+ set ::hooks [list] |
+ db commit_hook commit_hook |
+ db rollback_hook rollback_hook |
+ catchsql { |
+ BEGIN; |
+ INSERT INTO t1 VALUES('two', 'II'); |
+ COMMIT; |
+ } |
+ execsql { SELECT * FROM t1 } |
+} {one I} |
+do_test hook-6.2 { |
+ set ::hooks |
+} {COMMIT ROLLBACK} |
+unset ::hooks |
+ |
finish_test |