8_3_names.test 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. # 2011 May 17
  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. #
  12. # Test cases for the SQLITE_ENABLE_8_3_NAMES feature that forces all
  13. # filename extensions to be limited to 3 characters. Some embedded
  14. # systems need this to work around microsoft FAT patents, but this
  15. # feature should be disabled on most deployments.
  16. #
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. ifcapable !8_3_names {
  20. finish_test
  21. return
  22. }
  23. db close
  24. sqlite3_shutdown
  25. sqlite3_config_uri 1
  26. do_test 8_3_names-1.0 {
  27. forcedelete test.db test.nal test.db-journal
  28. sqlite3 db test.db
  29. db eval {
  30. PRAGMA cache_size=10;
  31. CREATE TABLE t1(x);
  32. INSERT INTO t1 VALUES(randomblob(20000));
  33. BEGIN;
  34. DELETE FROM t1;
  35. INSERT INTO t1 VALUES(randomblob(15000));
  36. }
  37. file exists test.db-journal
  38. } 1
  39. do_test 8_3_names-1.1 {
  40. file exists test.nal
  41. } 0
  42. do_test 8_3_names-1.2 {
  43. db eval {
  44. ROLLBACK;
  45. SELECT length(x) FROM t1
  46. }
  47. } 20000
  48. db close
  49. do_test 8_3_names-2.0 {
  50. forcedelete test.db test.nal test.db-journal
  51. sqlite3 db file:./test.db?8_3_names=1
  52. db eval {
  53. PRAGMA cache_size=10;
  54. CREATE TABLE t1(x);
  55. INSERT INTO t1 VALUES(randomblob(20000));
  56. BEGIN;
  57. DELETE FROM t1;
  58. INSERT INTO t1 VALUES(randomblob(15000));
  59. }
  60. file exists test.db-journal
  61. } 0
  62. do_test 8_3_names-2.1 {
  63. file exists test.nal
  64. } 1
  65. forcedelete test2.db test2.nal test2.db-journal
  66. copy_file test.db test2.db
  67. copy_file test.nal test2.nal
  68. do_test 8_3_names-2.2 {
  69. db eval {
  70. COMMIT;
  71. SELECT length(x) FROM t1
  72. }
  73. } 15000
  74. do_test 8_3_names-2.3 {
  75. sqlite3 db2 file:./test2.db?8_3_names=1
  76. db2 eval {
  77. PRAGMA integrity_check;
  78. SELECT length(x) FROM t1;
  79. }
  80. } {ok 20000}
  81. db close
  82. do_test 8_3_names-3.0 {
  83. forcedelete test.db test.nal test.db-journal
  84. sqlite3 db file:./test.db?8_3_names=0
  85. db eval {
  86. PRAGMA cache_size=10;
  87. CREATE TABLE t1(x);
  88. INSERT INTO t1 VALUES(randomblob(20000));
  89. BEGIN;
  90. DELETE FROM t1;
  91. INSERT INTO t1 VALUES(randomblob(15000));
  92. }
  93. file exists test.db-journal
  94. } 1
  95. do_test 8_3_names-3.1 {
  96. file exists test.nal
  97. } 0
  98. forcedelete test2.db test2.nal test2.db-journal
  99. copy_file test.db test2.db
  100. copy_file test.db-journal test2.db-journal
  101. do_test 8_3_names-3.2 {
  102. db eval {
  103. COMMIT;
  104. SELECT length(x) FROM t1
  105. }
  106. } 15000
  107. do_test 8_3_names-3.3 {
  108. sqlite3 db2 file:./test2.db?8_3_names=0
  109. db2 eval {
  110. PRAGMA integrity_check;
  111. SELECT length(x) FROM t1;
  112. }
  113. } {ok 20000}
  114. ##########################################################################
  115. # Master journals.
  116. #
  117. db close
  118. forcedelete test.db test2.db
  119. do_test 8_3_names-4.0 {
  120. sqlite3 db file:./test.db?8_3_names=1
  121. db eval {
  122. CREATE TABLE t1(x);
  123. INSERT INTO t1 VALUES(1);
  124. ATTACH 'file:./test2.db?8_3_names=1' AS db2;
  125. CREATE TABLE db2.t2(y);
  126. INSERT INTO t2 VALUES(2);
  127. BEGIN;
  128. INSERT INTO t1 VALUES(3);
  129. INSERT INTO t2 VALUES(4);
  130. COMMIT;
  131. SELECT * FROM t1, t2 ORDER BY x, y
  132. }
  133. } {1 2 1 4 3 2 3 4}
  134. ##########################################################################
  135. # WAL mode.
  136. #
  137. ifcapable !wal {
  138. finish_test
  139. return
  140. }
  141. db close
  142. forcedelete test.db
  143. do_test 8_3_names-5.0 {
  144. sqlite3 db file:./test.db?8_3_names=1
  145. load_static_extension db wholenumber
  146. db eval {
  147. PRAGMA journal_mode=WAL;
  148. CREATE TABLE t1(x);
  149. CREATE VIRTUAL TABLE nums USING wholenumber;
  150. INSERT INTO t1 SELECT value FROM nums WHERE value BETWEEN 1 AND 1000;
  151. BEGIN;
  152. UPDATE t1 SET x=x*2;
  153. }
  154. sqlite3 db2 file:./test.db?8_3_names=1
  155. load_static_extension db2 wholenumber
  156. db2 eval {
  157. BEGIN;
  158. SELECT sum(x) FROM t1;
  159. }
  160. } {500500}
  161. do_test 8_3_names-5.1 {
  162. file exists test.db-wal
  163. } 0
  164. do_test 8_3_names-5.2 {
  165. file exists test.wal
  166. } 1
  167. do_test 8_3_names-5.3 {
  168. file exists test.db-shm
  169. } 0
  170. do_test 8_3_names-5.4 {
  171. file exists test.shm
  172. } 1
  173. do_test 8_3_names-5.5 {
  174. db eval {
  175. COMMIT;
  176. SELECT sum(x) FROM t1;
  177. }
  178. } {1001000}
  179. do_test 8_3_names-5.6 {
  180. db2 eval {
  181. SELECT sum(x) FROM t1;
  182. }
  183. } {500500}
  184. finish_test