wal8.test 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # 2012 February 28
  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. The
  12. # focus of this file is testing the operation of the library in
  13. # "PRAGMA journal_mode=WAL" mode.
  14. #
  15. # Specifically, it tests the case where a connection opens an empty
  16. # file. Then, another connection opens the same file and initializes
  17. # the connection as a WAL database. Following this, the first connection
  18. # executes a "PRAGMA page_size = XXX" command to set its expected page
  19. # size, and then queries the database.
  20. #
  21. # This is an unusual case, as normally SQLite is able to glean the page
  22. # size from the database file as soon as it is opened (even before the
  23. # first read transaction is executed), and the "PRAGMA page_size = XXX"
  24. # is a no-op.
  25. #
  26. set testdir [file dirname $argv0]
  27. source $testdir/tester.tcl
  28. set ::testprefix wal8
  29. ifcapable !wal {finish_test ; return }
  30. db close
  31. forcedelete test.db test.db-wal
  32. sqlite3 db test.db
  33. sqlite3 db2 test.db
  34. do_test 1.0 {
  35. execsql {
  36. PRAGMA journal_mode = wal;
  37. CREATE TABLE t1(a, b);
  38. INSERT INTO t1 VALUES(1, 2);
  39. } db2
  40. } {wal}
  41. do_catchsql_test 1.1 {
  42. PRAGMA page_size = 4096;
  43. VACUUM;
  44. } {0 {}}
  45. db close
  46. db2 close
  47. forcedelete test.db test.db-wal
  48. sqlite3 db test.db
  49. sqlite3 db2 test.db
  50. do_test 2.0 {
  51. execsql {
  52. CREATE TABLE t1(a, b);
  53. INSERT INTO t1 VALUES(1, 2);
  54. PRAGMA journal_mode = wal;
  55. } db2
  56. } {wal}
  57. do_catchsql_test 2.1 {
  58. PRAGMA page_size = 4096;
  59. VACUUM;
  60. } {0 {}}
  61. db close
  62. db2 close
  63. forcedelete test.db test.db-wal
  64. sqlite3 db test.db
  65. sqlite3 db2 test.db
  66. do_test 3.0 {
  67. execsql {
  68. PRAGMA journal_mode = wal;
  69. CREATE TABLE t1(a, b);
  70. INSERT INTO t1 VALUES(1, 2);
  71. } db2
  72. } {wal}
  73. do_execsql_test 3.1 {
  74. PRAGMA page_size = 4096;
  75. SELECT name FROM sqlite_master;
  76. } {t1}
  77. finish_test