PageRenderTime 50ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/src/sqlite/test/bigfile.test

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