1
0

fts3fault2.test 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # 2011 February 3
  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. set testdir [file dirname $argv0]
  13. source $testdir/tester.tcl
  14. set ::testprefix fts3fault2
  15. # If SQLITE_ENABLE_FTS3 is not defined, omit this file.
  16. ifcapable !fts3 { finish_test ; return }
  17. do_test 1.0 {
  18. execsql {
  19. CREATE VIRTUAL TABLE t1 USING fts4(x);
  20. INSERT INTO t1 VALUES('a b c');
  21. INSERT INTO t1 VALUES('c d e');
  22. CREATE VIRTUAL TABLE terms USING fts4aux(t1);
  23. }
  24. faultsim_save_and_close
  25. } {}
  26. do_faultsim_test 1.1 -prep {
  27. faultsim_restore_and_reopen
  28. db eval {SELECT * FROM sqlite_master}
  29. } -body {
  30. execsql "CREATE VIRTUAL TABLE terms2 USING fts4aux(t1)"
  31. } -test {
  32. faultsim_test_result {0 {}}
  33. }
  34. do_faultsim_test 1.2 -prep {
  35. faultsim_restore_and_reopen
  36. db eval {SELECT * FROM sqlite_master}
  37. } -body {
  38. execsql "SELECT * FROM terms"
  39. } -test {
  40. faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 2 2 c 0 2 2 d * 1 1 d 0 1 1 e * 1 1 e 0 1 1}}
  41. }
  42. do_faultsim_test 1.3 -prep {
  43. faultsim_restore_and_reopen
  44. db eval {SELECT * FROM sqlite_master}
  45. } -body {
  46. execsql "SELECT * FROM terms WHERE term>'a' AND TERM < 'd'"
  47. } -test {
  48. faultsim_test_result {0 {b * 1 1 b 0 1 1 c * 2 2 c 0 2 2}}
  49. }
  50. do_faultsim_test 1.4 -prep {
  51. faultsim_restore_and_reopen
  52. db eval {SELECT * FROM sqlite_master}
  53. } -body {
  54. execsql "SELECT * FROM terms WHERE term='c'"
  55. } -test {
  56. faultsim_test_result {0 {c * 2 2 c 0 2 2}}
  57. }
  58. do_test 2.0 {
  59. faultsim_delete_and_reopen
  60. execsql {
  61. CREATE VIRTUAL TABLE tx USING fts4(a, b);
  62. INSERT INTO tx VALUES('a b c', 'x y z');
  63. CREATE VIRTUAL TABLE terms2 USING fts4aux(tx);
  64. }
  65. faultsim_save_and_close
  66. } {}
  67. do_faultsim_test 2.1 -prep {
  68. faultsim_restore_and_reopen
  69. db eval {SELECT * FROM sqlite_master}
  70. } -body {
  71. execsql "SELECT * FROM terms2"
  72. } -test {
  73. faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 1 1 c 0 1 1 x * 1 1 x 1 1 1 y * 1 1 y 1 1 1 z * 1 1 z 1 1 1}}
  74. }
  75. do_faultsim_test 3.0 -faults oom* -prep {
  76. faultsim_delete_and_reopen
  77. db eval { CREATE TABLE 'xx yy'(a, b); }
  78. } -body {
  79. execsql {
  80. CREATE VIRTUAL TABLE tt USING fts4(content="xx yy");
  81. }
  82. } -test {
  83. faultsim_test_result {0 {}}
  84. }
  85. do_faultsim_test 3.1 -faults oom* -prep {
  86. faultsim_delete_and_reopen
  87. db func zip zip
  88. db func unzip unzip
  89. } -body {
  90. execsql {
  91. CREATE VIRTUAL TABLE tt USING fts4(compress=zip, uncompress=unzip);
  92. }
  93. } -test {
  94. faultsim_test_result {0 {}}
  95. }
  96. do_test 4.0 {
  97. faultsim_delete_and_reopen
  98. execsql {
  99. CREATE VIRTUAL TABLE ft USING fts4(a, b);
  100. INSERT INTO ft VALUES('U U T C O', 'F N D E S');
  101. INSERT INTO ft VALUES('P H X G B', 'I D M R U');
  102. INSERT INTO ft VALUES('P P X D M', 'Y V N T C');
  103. INSERT INTO ft VALUES('Z L Q O W', 'D F U N Q');
  104. INSERT INTO ft VALUES('A J D U P', 'C H M Q E');
  105. INSERT INTO ft VALUES('P S A O H', 'S Z C W D');
  106. INSERT INTO ft VALUES('T B N L W', 'C A K T I');
  107. INSERT INTO ft VALUES('K E Z L O', 'L L Y C E');
  108. INSERT INTO ft VALUES('C R E S V', 'Q V F W P');
  109. INSERT INTO ft VALUES('S K H G W', 'R W Q F G');
  110. }
  111. faultsim_save_and_close
  112. } {}
  113. do_faultsim_test 4.1 -prep {
  114. faultsim_restore_and_reopen
  115. db eval {SELECT * FROM sqlite_master}
  116. } -body {
  117. execsql { INSERT INTO ft(ft) VALUES('rebuild') }
  118. } -test {
  119. faultsim_test_result {0 {}}
  120. }
  121. ifcapable fts3_unicode {
  122. do_test 5.0 {
  123. faultsim_delete_and_reopen
  124. execsql {
  125. CREATE VIRTUAL TABLE ft USING fts4(a, tokenize=unicode61);
  126. }
  127. faultsim_save_and_close
  128. } {}
  129. do_faultsim_test 5.1 -faults oom* -prep {
  130. faultsim_restore_and_reopen
  131. db eval {SELECT * FROM sqlite_master}
  132. } -body {
  133. execsql { INSERT INTO ft VALUES('the quick brown fox'); }
  134. execsql { INSERT INTO ft VALUES(
  135. 'theunusuallylongtokenthatjustdragsonandonandonandthendragsonsomemoreeof'
  136. );
  137. }
  138. execsql { SELECT docid FROM ft WHERE ft MATCH 'th*' }
  139. } -test {
  140. faultsim_test_result {0 {1 2}}
  141. }
  142. }
  143. finish_test