fts3ae.test 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # 2006 October 19
  2. #
  3. # The author disclaims copyright to this source code.
  4. #
  5. #*************************************************************************
  6. # This file implements regression tests for SQLite library. The
  7. # focus of this script is testing deletions in the FTS3 module.
  8. #
  9. # $Id: fts3ae.test,v 1.1 2007/08/20 17:38:42 shess Exp $
  10. #
  11. set testdir [file dirname $argv0]
  12. source $testdir/tester.tcl
  13. # If SQLITE_ENABLE_FTS3 is defined, omit this file.
  14. ifcapable !fts3 {
  15. finish_test
  16. return
  17. }
  18. # Construct a full-text search table containing keywords which are the
  19. # ordinal numbers of the bit positions set for a sequence of integers,
  20. # which are used for the rowid. There are a total of 30 INSERT and
  21. # DELETE statements, so that we'll test both the segmentMerge() merge
  22. # (over the first 16) and the termSelect() merge (over the level-1
  23. # segment and 14 level-0 segments).
  24. db eval {
  25. CREATE VIRTUAL TABLE t1 USING fts3(content);
  26. INSERT INTO t1 (rowid, content) VALUES(1, 'one');
  27. INSERT INTO t1 (rowid, content) VALUES(2, 'two');
  28. INSERT INTO t1 (rowid, content) VALUES(3, 'one two');
  29. INSERT INTO t1 (rowid, content) VALUES(4, 'three');
  30. DELETE FROM t1 WHERE rowid = 1;
  31. INSERT INTO t1 (rowid, content) VALUES(5, 'one three');
  32. INSERT INTO t1 (rowid, content) VALUES(6, 'two three');
  33. INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');
  34. DELETE FROM t1 WHERE rowid = 4;
  35. INSERT INTO t1 (rowid, content) VALUES(8, 'four');
  36. INSERT INTO t1 (rowid, content) VALUES(9, 'one four');
  37. INSERT INTO t1 (rowid, content) VALUES(10, 'two four');
  38. DELETE FROM t1 WHERE rowid = 7;
  39. INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');
  40. INSERT INTO t1 (rowid, content) VALUES(12, 'three four');
  41. INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');
  42. DELETE FROM t1 WHERE rowid = 10;
  43. INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');
  44. INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');
  45. INSERT INTO t1 (rowid, content) VALUES(16, 'five');
  46. DELETE FROM t1 WHERE rowid = 13;
  47. INSERT INTO t1 (rowid, content) VALUES(17, 'one five');
  48. INSERT INTO t1 (rowid, content) VALUES(18, 'two five');
  49. INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');
  50. DELETE FROM t1 WHERE rowid = 16;
  51. INSERT INTO t1 (rowid, content) VALUES(20, 'three five');
  52. INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');
  53. INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');
  54. DELETE FROM t1 WHERE rowid = 19;
  55. DELETE FROM t1 WHERE rowid = 22;
  56. }
  57. do_test fts3ae-1.1 {
  58. execsql {SELECT COUNT(*) FROM t1}
  59. } {14}
  60. do_test fts3ae-2.1 {
  61. execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}
  62. } {3 5 9 11 15 17 21}
  63. do_test fts3ae-2.2 {
  64. execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}
  65. } {2 3 6 11 14 15 18}
  66. do_test fts3ae-2.3 {
  67. execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}
  68. } {5 6 12 14 15 20 21}
  69. do_test fts3ae-2.4 {
  70. execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}
  71. } {8 9 11 12 14 15}
  72. do_test fts3ae-2.5 {
  73. execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}
  74. } {17 18 20 21}
  75. finish_test