OLD | NEW |
1 # 2004 Jan 14 | 1 # 2004 Jan 14 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 # Check that the INSERT transaction above really was rolled back. | 327 # Check that the INSERT transaction above really was rolled back. |
328 execsql { | 328 execsql { |
329 SELECT count(*) FROM t1; | 329 SELECT count(*) FROM t1; |
330 } | 330 } |
331 } {1} | 331 } {1} |
332 | 332 |
333 # | 333 # |
334 # End rollback-hook testing. | 334 # End rollback-hook testing. |
335 #---------------------------------------------------------------------------- | 335 #---------------------------------------------------------------------------- |
336 | 336 |
| 337 #---------------------------------------------------------------------------- |
| 338 # Test that if a commit-hook returns non-zero (causing a rollback), the |
| 339 # rollback-hook is invoked. |
| 340 # |
| 341 proc commit_hook {} { |
| 342 lappend ::hooks COMMIT |
| 343 return 1 |
| 344 } |
| 345 proc rollback_hook {} { |
| 346 lappend ::hooks ROLLBACK |
| 347 } |
| 348 do_test hook-6.1 { |
| 349 set ::hooks [list] |
| 350 db commit_hook commit_hook |
| 351 db rollback_hook rollback_hook |
| 352 catchsql { |
| 353 BEGIN; |
| 354 INSERT INTO t1 VALUES('two', 'II'); |
| 355 COMMIT; |
| 356 } |
| 357 execsql { SELECT * FROM t1 } |
| 358 } {one I} |
| 359 do_test hook-6.2 { |
| 360 set ::hooks |
| 361 } {COMMIT ROLLBACK} |
| 362 unset ::hooks |
| 363 |
337 finish_test | 364 finish_test |
OLD | NEW |