rbuA.test 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # 2014 August 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. # This file contains tests for the RBU module. More specifically, it
  13. # contains tests to ensure that it is an error to attempt to update
  14. # a wal mode database via RBU.
  15. #
  16. source [file join [file dirname [info script]] rbu_common.tcl]
  17. if_no_rbu_support { finish_test ; return }
  18. set ::testprefix rbuA
  19. set db_sql {
  20. CREATE TABLE t1(a PRIMARY KEY, b, c);
  21. }
  22. set rbu_sql {
  23. CREATE TABLE data_t1(a, b, c, rbu_control);
  24. INSERT INTO data_t1 VALUES(1, 2, 3, 0);
  25. INSERT INTO data_t1 VALUES(4, 5, 6, 0);
  26. INSERT INTO data_t1 VALUES(7, 8, 9, 0);
  27. }
  28. do_test 1.0 {
  29. db close
  30. forcedelete test.db rbu.db
  31. sqlite3 db test.db
  32. db eval $db_sql
  33. db eval { PRAGMA journal_mode = wal }
  34. db close
  35. sqlite3 db rbu.db
  36. db eval $rbu_sql
  37. db close
  38. sqlite3rbu rbu test.db rbu.db
  39. rbu step
  40. } {SQLITE_ERROR}
  41. do_test 1.1 {
  42. list [catch { rbu close } msg] $msg
  43. } {1 {SQLITE_ERROR - cannot update wal mode database}}
  44. do_test 2.0 {
  45. forcedelete test.db rbu.db
  46. sqlite3 db test.db
  47. db eval $db_sql
  48. db close
  49. sqlite3 db rbu.db
  50. db eval $rbu_sql
  51. db close
  52. sqlite3rbu rbu test.db rbu.db
  53. rbu step
  54. rbu close
  55. } {SQLITE_OK}
  56. do_test 2.1 {
  57. sqlite3 db test.db
  58. db eval {PRAGMA journal_mode = wal}
  59. db close
  60. sqlite3rbu rbu test.db rbu.db
  61. rbu step
  62. } {SQLITE_ERROR}
  63. do_test 2.2 {
  64. list [catch { rbu close } msg] $msg
  65. } {1 {SQLITE_ERROR - cannot update wal mode database}}
  66. finish_test