tkt-f3e5abed55.test 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # 2010 July 29
  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. set testdir [file dirname $argv0]
  13. source $testdir/tester.tcl
  14. source $testdir/malloc_common.tcl
  15. foreach f [glob -nocomplain test.db*mj*] { forcedelete $f }
  16. forcedelete test.db2
  17. do_test tkt-f3e5abed55-1.1 {
  18. execsql {
  19. ATTACH 'test.db2' AS aux;
  20. CREATE TABLE main.t1(a, b);
  21. CREATE TABLE aux.t2(c, d);
  22. }
  23. } {}
  24. do_test tkt-f3e5abed55-1.2 {
  25. glob -nocomplain test.db*mj*
  26. } {}
  27. do_test tkt-f3e5abed55-1.3 {
  28. sqlite3 db2 test.db
  29. execsql { BEGIN; SELECT * FROM t1 } db2
  30. } {}
  31. do_test tkt-f3e5abed55-1.4 {
  32. execsql {
  33. BEGIN;
  34. INSERT INTO t1 VALUES(1, 2);
  35. INSERT INTO t2 VALUES(1, 2);
  36. }
  37. catchsql COMMIT
  38. } {1 {database is locked}}
  39. do_test tkt-f3e5abed55-1.5 {
  40. execsql COMMIT db2
  41. execsql COMMIT
  42. } {}
  43. do_test tkt-f3e5abed55-1.6 {
  44. glob -nocomplain test.db*mj*
  45. } {}
  46. foreach f [glob -nocomplain test.db*mj*] { forcedelete $f }
  47. db close
  48. db2 close
  49. # Set up a testvfs so that the next time SQLite tries to delete the
  50. # file "test.db-journal", a snapshot of the current file-system contents
  51. # is taken.
  52. #
  53. # This test will not work with an in-memory journal.
  54. #
  55. if {[permutation]!="inmemory_journal"} {
  56. testvfs tvfs -default 1
  57. tvfs script xDelete
  58. tvfs filter xDelete
  59. proc xDelete {method file args} {
  60. if {[file tail $file] == "test.db-journal"} {
  61. faultsim_save
  62. tvfs filter {}
  63. }
  64. return "SQLITE_OK"
  65. }
  66. sqlite3 db test.db
  67. sqlite3 db2 test.db
  68. do_test tkt-f3e5abed55-2.1 {
  69. execsql {
  70. ATTACH 'test.db2' AS aux;
  71. BEGIN;
  72. INSERT INTO t1 VALUES(3, 4);
  73. INSERT INTO t2 VALUES(3, 4);
  74. }
  75. } {}
  76. do_test tkt-f3e5abed55-2.2 {
  77. execsql { BEGIN; SELECT * FROM t1 } db2
  78. } {1 2}
  79. do_test tkt-f3e5abed55-2.3 {
  80. catchsql COMMIT
  81. } {1 {database is locked}}
  82. do_test tkt-f3e5abed55-2.4 {
  83. execsql COMMIT db2
  84. execsql {
  85. COMMIT;
  86. SELECT * FROM t1;
  87. SELECT * FROM t2;
  88. }
  89. } {1 2 3 4 1 2 3 4}
  90. do_test tkt-f3e5abed55-2.5 {
  91. db close
  92. db2 close
  93. faultsim_restore_and_reopen
  94. execsql {
  95. ATTACH 'test.db2' AS aux;
  96. SELECT * FROM t1;
  97. SELECT * FROM t2;
  98. }
  99. } {1 2 3 4 1 2 3 4}
  100. }
  101. finish_test