bigfile.test 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. # 2002 November 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. # 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. # $Id: bigfile.test,v 1.12 2009/03/05 04:27:08 shane Exp $
  16. #
  17. if {[file exists skip-big-file]} return
  18. if {$tcl_platform(os)=="Darwin"} return
  19. set testdir [file dirname $argv0]
  20. source $testdir/tester.tcl
  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. # These tests only work for Tcl version 8.4 and later. Prior to 8.4,
  31. # Tcl was unable to handle large files.
  32. #
  33. scan $::tcl_version %f vx
  34. if {$vx<8.4} return
  35. # Mac OS X does not handle large files efficiently. So skip this test
  36. # on that platform.
  37. if {$tcl_platform(os)=="Darwin"} return
  38. # This is the md5 checksum of all the data in table t1 as created
  39. # by the first test. We will use this number to make sure that data
  40. # never changes.
  41. #
  42. set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}
  43. do_test bigfile-1.1 {
  44. execsql {
  45. BEGIN;
  46. CREATE TABLE t1(x);
  47. INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');
  48. INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
  49. INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
  50. INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
  51. INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
  52. INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
  53. INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
  54. INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
  55. COMMIT;
  56. }
  57. execsql {
  58. SELECT md5sum(x) FROM t1;
  59. }
  60. } $::MAGIC_SUM
  61. # Try to create a large file - a file that is larger than 2^32 bytes.
  62. # If this fails, it means that the system being tested does not support
  63. # large files. So skip all of the remaining tests in this file.
  64. #
  65. db close
  66. if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {
  67. puts "**** Unable to create a file larger than 4096 MB. *****"
  68. finish_test
  69. return
  70. }
  71. hexio_write test.db 28 00000000
  72. do_test bigfile-1.2 {
  73. sqlite3 db test.db
  74. execsql {
  75. SELECT md5sum(x) FROM t1;
  76. }
  77. } $::MAGIC_SUM
  78. # The previous test may fail on some systems because they are unable
  79. # to handle large files. If that is so, then skip all of the following
  80. # tests. We will know the above test failed because the "db" command
  81. # does not exist.
  82. #
  83. if {[llength [info command db]]<=0} {
  84. puts "**** Large file support appears to be broken. *****"
  85. finish_test
  86. return
  87. }
  88. do_test bigfile-1.3 {
  89. execsql {
  90. CREATE TABLE t2 AS SELECT * FROM t1;
  91. SELECT md5sum(x) FROM t2;
  92. }
  93. } $::MAGIC_SUM
  94. do_test bigfile-1.4 {
  95. db close
  96. sqlite3 db test.db
  97. execsql {
  98. SELECT md5sum(x) FROM t1;
  99. }
  100. } $::MAGIC_SUM
  101. db close
  102. if {[catch {fake_big_file 8192 [get_pwd]/test.db}]} {
  103. puts "**** Unable to create a file larger than 8192 MB. *****"
  104. finish_test
  105. return
  106. }
  107. hexio_write test.db 28 00000000
  108. do_test bigfile-1.5 {
  109. sqlite3 db test.db
  110. execsql {
  111. SELECT md5sum(x) FROM t1;
  112. }
  113. } $::MAGIC_SUM
  114. do_test bigfile-1.6 {
  115. sqlite3 db test.db
  116. execsql {
  117. SELECT md5sum(x) FROM t2;
  118. }
  119. } $::MAGIC_SUM
  120. do_test bigfile-1.7 {
  121. execsql {
  122. CREATE TABLE t3 AS SELECT * FROM t1;
  123. SELECT md5sum(x) FROM t3;
  124. }
  125. } $::MAGIC_SUM
  126. do_test bigfile-1.8 {
  127. db close
  128. sqlite3 db test.db
  129. execsql {
  130. SELECT md5sum(x) FROM t1;
  131. }
  132. } $::MAGIC_SUM
  133. do_test bigfile-1.9 {
  134. execsql {
  135. SELECT md5sum(x) FROM t2;
  136. }
  137. } $::MAGIC_SUM
  138. db close
  139. if {[catch {fake_big_file 16384 [get_pwd]/test.db}]} {
  140. puts "**** Unable to create a file larger than 16384 MB. *****"
  141. finish_test
  142. return
  143. }
  144. hexio_write test.db 28 00000000
  145. do_test bigfile-1.10 {
  146. sqlite3 db test.db
  147. execsql {
  148. SELECT md5sum(x) FROM t1;
  149. }
  150. } $::MAGIC_SUM
  151. do_test bigfile-1.11 {
  152. sqlite3 db test.db
  153. execsql {
  154. SELECT md5sum(x) FROM t2;
  155. }
  156. } $::MAGIC_SUM
  157. do_test bigfile-1.12 {
  158. sqlite3 db test.db
  159. execsql {
  160. SELECT md5sum(x) FROM t3;
  161. }
  162. } $::MAGIC_SUM
  163. do_test bigfile-1.13 {
  164. execsql {
  165. CREATE TABLE t4 AS SELECT * FROM t1;
  166. SELECT md5sum(x) FROM t4;
  167. }
  168. } $::MAGIC_SUM
  169. do_test bigfile-1.14 {
  170. db close
  171. sqlite3 db test.db
  172. execsql {
  173. SELECT md5sum(x) FROM t1;
  174. }
  175. } $::MAGIC_SUM
  176. do_test bigfile-1.15 {
  177. execsql {
  178. SELECT md5sum(x) FROM t2;
  179. }
  180. } $::MAGIC_SUM
  181. do_test bigfile-1.16 {
  182. execsql {
  183. SELECT md5sum(x) FROM t3;
  184. }
  185. } $::MAGIC_SUM
  186. finish_test