lock7.test 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # 2009 August 17
  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. #
  12. # Check that reading the database schema from within an active transaction
  13. # does not establish a SHARED lock on the database file if one is not
  14. # already held (or, more accurately, that the SHARED lock is released after
  15. # reading the database schema).
  16. #
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. do_test lock7-1.1 {
  20. execsql { CREATE TABLE t1(a, b) }
  21. db close
  22. sqlite3 db1 test.db
  23. sqlite3 db2 test.db
  24. db1 eval {BEGIN}
  25. db2 eval {BEGIN}
  26. } {}
  27. do_test lock7-1.2 {
  28. execsql { PRAGMA lock_status } db1
  29. } {main unlocked temp closed}
  30. do_test lock7-1.3 {
  31. execsql { PRAGMA lock_status } db2
  32. } {main unlocked temp closed}
  33. do_test lock7-1.4 {
  34. catchsql { INSERT INTO t1 VALUES(1, 1) } db1
  35. } {0 {}}
  36. do_test lock7-1.5 {
  37. catchsql { INSERT INTO t1 VALUES(2, 2) } db2
  38. } {1 {database is locked}}
  39. do_test lock7-1.6 {
  40. execsql { PRAGMA lock_status } db1
  41. } {main reserved temp closed}
  42. do_test lock7-1.7 {
  43. execsql { PRAGMA lock_status } db2
  44. } {main unlocked temp closed}
  45. do_test lock7-1.8 {
  46. execsql { COMMIT } db1
  47. } {}
  48. db1 close
  49. db2 close
  50. finish_test