journal1.test 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # 2005 March 15
  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 implements regression tests for SQLite library.
  12. #
  13. # This file implements tests to make sure that leftover journals from
  14. # prior databases do not try to rollback into new databases.
  15. #
  16. # $Id: journal1.test,v 1.2 2005/03/20 22:54:56 drh Exp $
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. # These tests will not work on windows because windows uses
  20. # manditory file locking which breaks the copy_file command.
  21. #
  22. if {$tcl_platform(platform)=="windows"} {
  23. finish_test
  24. return
  25. }
  26. # Create a smaple database
  27. #
  28. do_test journal1-1.1 {
  29. execsql {
  30. CREATE TABLE t1(a,b);
  31. INSERT INTO t1 VALUES(1,randstr(10,400));
  32. INSERT INTO t1 VALUES(2,randstr(10,400));
  33. INSERT INTO t1 SELECT a+2, a||b FROM t1;
  34. INSERT INTO t1 SELECT a+4, a||b FROM t1;
  35. SELECT count(*) FROM t1;
  36. }
  37. } 8
  38. # Make changes to the database and save the journal file.
  39. # Then delete the database. Replace the journal file
  40. # and try to create a new database with the same name. The
  41. # old journal should not attempt to rollback into the new
  42. # database.
  43. #
  44. do_test journal1-1.2 {
  45. execsql {
  46. BEGIN;
  47. DELETE FROM t1;
  48. }
  49. forcecopy test.db-journal test.db-journal-bu
  50. execsql {
  51. ROLLBACK;
  52. }
  53. db close
  54. delete_file test.db
  55. copy_file test.db-journal-bu test.db-journal
  56. sqlite3 db test.db
  57. catchsql {
  58. SELECT * FROM sqlite_master
  59. }
  60. } {0 {}}
  61. finish_test