1
0

shared7.test 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # 2009 April 30
  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. # Make sure that attaching the same database multiple times in
  13. # shared cache mode fails.
  14. #
  15. # $Id: shared7.test,v 1.1 2009/04/30 13:30:33 drh Exp $
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. ifcapable !shared_cache { finish_test ; return }
  19. do_test shared7-1.1 {
  20. set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
  21. sqlite3_enable_shared_cache
  22. } {1}
  23. # EVIDENCE-OF: R-05098-06501 In shared cache mode, attempting to attach
  24. # the same database file more than once results in an error.
  25. #
  26. do_test shared7-1.2 {
  27. db close
  28. sqlite3 db test.db
  29. db eval {
  30. CREATE TABLE t1(x);
  31. }
  32. catchsql {
  33. ATTACH 'test.db' AS err1;
  34. }
  35. } {1 {database is already attached}}
  36. do_test shared7-1.3 {
  37. forcedelete test2.db test2.db-journal
  38. db eval {
  39. ATTACH 'test2.db' AS test2;
  40. CREATE TABLE test2.t2(y);
  41. }
  42. catchsql {
  43. ATTACH 'test2.db' AS err2;
  44. }
  45. } {1 {database is already attached}}
  46. do_test shared7-1.4 {
  47. catchsql {
  48. ATTACH 'test.db' AS err1;
  49. }
  50. } {1 {database is already attached}}
  51. sqlite3_enable_shared_cache $::enable_shared_cache
  52. finish_test