busy.test 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # 2005 july 8
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #***********************************************************************
  11. # This file test the busy handler
  12. #
  13. # $Id: busy.test,v 1.3 2008/03/15 02:09:22 drh Exp $
  14. set testdir [file dirname $argv0]
  15. source $testdir/tester.tcl
  16. do_test busy-1.1 {
  17. sqlite3 db2 test.db
  18. execsql {
  19. CREATE TABLE t1(x);
  20. INSERT INTO t1 VALUES(1);
  21. SELECT * FROM t1
  22. }
  23. } 1
  24. proc busy x {
  25. lappend ::busyargs $x
  26. if {$x>2} {return 1}
  27. return 0
  28. }
  29. set busyargs {}
  30. do_test busy-1.2 {
  31. db busy busy
  32. db2 eval {BEGIN EXCLUSIVE}
  33. catchsql {BEGIN IMMEDIATE}
  34. } {1 {database is locked}}
  35. do_test busy-1.3 {
  36. set busyargs
  37. } {0 1 2 3}
  38. do_test busy-1.4 {
  39. set busyargs {}
  40. catchsql {BEGIN IMMEDIATE}
  41. set busyargs
  42. } {0 1 2 3}
  43. do_test busy-2.1 {
  44. db2 eval {COMMIT}
  45. db eval {BEGIN; INSERT INTO t1 VALUES(5)}
  46. db2 eval {BEGIN; SELECT * FROM t1}
  47. set busyargs {}
  48. catchsql COMMIT
  49. } {1 {database is locked}}
  50. do_test busy-2.2 {
  51. set busyargs
  52. } {0 1 2 3}
  53. db2 close
  54. finish_test