walbig.test 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # 2010 July 07
  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 script testing the ability of SQLite to handle database
  13. # files larger than 4GB in WAL mode.
  14. #
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. ifcapable !wal {
  18. finish_test
  19. return
  20. }
  21. # Do not use a codec for this file, as the database is manipulated using
  22. # external methods (the [fake_big_file] and [hexio_write] commands).
  23. #
  24. do_not_use_codec
  25. # If SQLITE_DISABLE_LFS is defined, omit this file.
  26. ifcapable !lfs {
  27. finish_test
  28. return
  29. }
  30. set a_string_counter 1
  31. proc a_string {n} {
  32. incr ::a_string_counter
  33. string range [string repeat "${::a_string_counter}." $n] 1 $n
  34. }
  35. db func a_string a_string
  36. do_test walbig-1.0 {
  37. execsql {
  38. PRAGMA journal_mode = WAL;
  39. CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
  40. INSERT INTO t1 VALUES(a_string(300), a_string(500));
  41. INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
  42. INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
  43. INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
  44. }
  45. } {wal}
  46. db close
  47. if {[catch {fake_big_file 5000 [get_pwd]/test.db}]} {
  48. puts "**** Unable to create a file larger than 5000 MB. *****"
  49. finish_test
  50. return
  51. }
  52. hexio_write test.db 28 00000000
  53. sqlite3 db test.db
  54. db func a_string a_string
  55. do_test walbig-1.1 {
  56. execsql { INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1 }
  57. } {}
  58. db close
  59. sqlite3 db test.db
  60. do_test walbig-1.2 {
  61. execsql { SELECT a FROM t1 ORDER BY a }
  62. } [lsort [execsql { SELECT a FROM t1 ORDER BY rowid }]]
  63. do_test walbig-1.3 {
  64. execsql { SELECT b FROM t1 ORDER BY b }
  65. } [lsort [execsql { SELECT b FROM t1 ORDER BY rowid }]]
  66. finish_test