fts5faultH.test 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. # 2010 June 15
  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. source [file join [file dirname [info script]] fts5_common.tcl]
  13. source $testdir/malloc_common.tcl
  14. set testprefix fts5faultG
  15. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  16. ifcapable !fts5 {
  17. finish_test
  18. return
  19. }
  20. set ::testprefix fts5faultH
  21. sqlite3_fts5_register_origintext db
  22. do_execsql_test 1.0 {
  23. CREATE VIRTUAL TABLE t1 USING fts5(
  24. x, tokenize="origintext unicode61", tokendata=1
  25. );
  26. BEGIN;
  27. INSERT INTO t1 VALUES('oNe tWo thRee');
  28. INSERT INTO t1 VALUES('One Two Three');
  29. INSERT INTO t1 VALUES('onE twO threE');
  30. COMMIT;
  31. BEGIN;
  32. INSERT INTO t1 VALUES('one two three');
  33. INSERT INTO t1 VALUES('one two three');
  34. INSERT INTO t1 VALUES('one two three');
  35. COMMIT;
  36. }
  37. do_faultsim_test 1 -faults oom* -prep {
  38. } -body {
  39. execsql {
  40. SELECT rowid FROM t1('three');
  41. }
  42. } -test {
  43. faultsim_integrity_check
  44. faultsim_test_result {0 {1 2 3 4 5 6}}
  45. }
  46. reset_db
  47. sqlite3_fts5_register_origintext db
  48. do_execsql_test 2.0 {
  49. CREATE VIRTUAL TABLE t1 USING fts5(
  50. x, tokenize="origintext unicode61", tokendata=1
  51. );
  52. INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
  53. BEGIN;
  54. INSERT INTO t1(rowid, x) VALUES(10, 'aaa bbb BBB');
  55. INSERT INTO t1(rowid, x) VALUES(12, 'bbb bbb bbb');
  56. INSERT INTO t1(rowid, x) VALUES(13, 'bbb bbb bbb');
  57. INSERT INTO t1(rowid, x) VALUES(14, 'bbb BBB bbb');
  58. INSERT INTO t1(rowid, x) VALUES(15, 'bbb bbb bbb');
  59. INSERT INTO t1(rowid, x) VALUES(16, 'bbb bbb bbb');
  60. INSERT INTO t1(rowid, x) VALUES(17, 'bbb bbb bbb');
  61. INSERT INTO t1(rowid, x) VALUES(18, 'bbb bbb bbb');
  62. INSERT INTO t1(rowid, x) VALUES(19, 'bbb bbb bbb');
  63. INSERT INTO t1(rowid, x) VALUES(20, 'bbb bbb bbb');
  64. INSERT INTO t1(rowid, x) VALUES(21, 'bbb bbb bbb');
  65. INSERT INTO t1(rowid, x) VALUES(22, 'bbb bbb bbb');
  66. INSERT INTO t1(rowid, x) VALUES(23, 'bbb bbb bbb');
  67. INSERT INTO t1(rowid, x) VALUES(24, 'aaa bbb BBB');
  68. COMMIT;
  69. }
  70. do_faultsim_test 2 -faults oom* -prep {
  71. } -body {
  72. execsql {
  73. SELECT rowid FROM t1('BBB AND AAA');
  74. }
  75. } -test {
  76. faultsim_integrity_check
  77. faultsim_test_result {0 {10 24}}
  78. }
  79. reset_db
  80. sqlite3_fts5_register_origintext db
  81. do_execsql_test 3.0 {
  82. CREATE VIRTUAL TABLE t1 USING fts5(
  83. x, tokenize="origintext unicode61", tokendata=1
  84. );
  85. INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
  86. INSERT INTO t1(rowid, x) VALUES(9, 'bbb Bbb BBB');
  87. BEGIN;
  88. INSERT INTO t1(rowid, x) VALUES(10, 'aaa bbb BBB');
  89. INSERT INTO t1(rowid, x) VALUES(11, 'bbb Bbb BBB');
  90. INSERT INTO t1(rowid, x) VALUES(12, 'bbb Bbb BBB');
  91. INSERT INTO t1(rowid, x) VALUES(13, 'bbb Bbb BBB');
  92. INSERT INTO t1(rowid, x) VALUES(14, 'bbb Bbb BBB');
  93. INSERT INTO t1(rowid, x) VALUES(15, 'bbb Bbb BBB');
  94. INSERT INTO t1(rowid, x) VALUES(16, 'bbb Bbb BBB');
  95. INSERT INTO t1(rowid, x) VALUES(17, 'bbb Bbb BBB');
  96. INSERT INTO t1(rowid, x) VALUES(18, 'bbb Bbb BBB');
  97. INSERT INTO t1(rowid, x) VALUES(19, 'bbb Bbb BBB');
  98. INSERT INTO t1(rowid, x) VALUES(20, 'bbb Bbb BBB');
  99. INSERT INTO t1(rowid, x) VALUES(21, 'bbb Bbb BBB');
  100. INSERT INTO t1(rowid, x) VALUES(22, 'bbb Bbb BBB');
  101. INSERT INTO t1(rowid, x) VALUES(23, 'bbb Bbb BBB');
  102. INSERT INTO t1(rowid, x) VALUES(24, 'bbb Bbb BBB');
  103. INSERT INTO t1(rowid, x) VALUES(25, 'bbb Bbb BBB');
  104. INSERT INTO t1(rowid, x) VALUES(26, 'bbb Bbb BBB');
  105. INSERT INTO t1(rowid, x) VALUES(27, 'bbb Bbb BBB');
  106. INSERT INTO t1(rowid, x) VALUES(28, 'bbb Bbb BBB');
  107. INSERT INTO t1(rowid, x) VALUES(29, 'bbb Bbb BBB');
  108. INSERT INTO t1(rowid, x) VALUES(30, 'bbb Bbb BBB');
  109. INSERT INTO t1(rowid, x) VALUES(31, 'bbb Bbb BBB');
  110. INSERT INTO t1(rowid, x) VALUES(32, 'bbb Bbb BBB');
  111. INSERT INTO t1(rowid, x) VALUES(33, 'bbb Bbb BBB');
  112. INSERT INTO t1(rowid, x) VALUES(34, 'bbb Bbb BBB');
  113. INSERT INTO t1(rowid, x) VALUES(35, 'aaa bbb BBB');
  114. COMMIT;
  115. }
  116. do_faultsim_test 3.1 -faults oom* -prep {
  117. } -body {
  118. execsql {
  119. SELECT rowid FROM t1('BBB AND AAA');
  120. }
  121. } -test {
  122. faultsim_integrity_check
  123. faultsim_test_result {0 {10 35}}
  124. }
  125. do_faultsim_test 3.2 -faults oom* -prep {
  126. } -body {
  127. execsql {
  128. SELECT count(*) FROM t1('BBB');
  129. }
  130. } -test {
  131. faultsim_integrity_check
  132. faultsim_test_result {0 27}
  133. }
  134. finish_test