1
0

bigfile2.test 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # 2011 December 20
  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.
  14. #
  15. if {[file exists skip-big-file]} return
  16. if {$tcl_platform(os)=="Darwin"} return
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. set testprefix bigfile2
  20. # Create a small database.
  21. #
  22. do_execsql_test 1.1 {
  23. CREATE TABLE t1(a, b);
  24. INSERT INTO t1 VALUES(1, 2);
  25. }
  26. # Pad the file out to 4GB in size. Then clear the file-size field in the
  27. # db header. This will cause SQLite to assume that the first 4GB of pages
  28. # are actually in use and new pages will be appended to the file.
  29. #
  30. db close
  31. if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {
  32. puts "**** Unable to create a file larger than 4096 MB. *****"
  33. finish_test
  34. return
  35. }
  36. hexio_write test.db 28 00000000
  37. do_test 1.2 {
  38. file size test.db
  39. } [expr 14 + 4096 * (1<<20)]
  40. # Now insert a large row. The overflow pages will be located past the 4GB
  41. # boundary. Then, after opening and closing the database, test that the row
  42. # can be read back in.
  43. #
  44. set str [string repeat k 30000]
  45. do_test 1.3 {
  46. sqlite3 db test.db
  47. execsql { INSERT INTO t1 VALUES(3, $str) }
  48. db close
  49. sqlite3 db test.db
  50. db one { SELECT b FROM t1 WHERE a = 3 }
  51. } $str
  52. db close
  53. delete_file test.db
  54. finish_test