1
0

walshared.test 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # 2010 August 2
  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 with shared-cache turned on.
  14. #
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. ifcapable !wal {finish_test ; return }
  18. db close
  19. set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
  20. sqlite3 db test.db
  21. sqlite3 db2 test.db
  22. do_test walshared-1.0 {
  23. execsql {
  24. PRAGMA cache_size = 10;
  25. PRAGMA journal_mode = WAL;
  26. CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
  27. INSERT INTO t1 VALUES(randomblob(100), randomblob(200));
  28. }
  29. } {wal}
  30. do_test walshared-1.1 {
  31. execsql {
  32. BEGIN;
  33. INSERT INTO t1 VALUES(randomblob(100), randomblob(200));
  34. INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
  35. INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
  36. INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
  37. }
  38. } {}
  39. do_test walshared-1.2 {
  40. catchsql { PRAGMA wal_checkpoint }
  41. } {1 {database table is locked}}
  42. do_test walshared-1.3 {
  43. catchsql { PRAGMA wal_checkpoint } db2
  44. } {1 {database table is locked}}
  45. do_test walshared-1.4 {
  46. execsql { COMMIT }
  47. execsql { PRAGMA integrity_check } db2
  48. } {ok}
  49. sqlite3_enable_shared_cache $::enable_shared_cache
  50. finish_test