tkt-bdc6bbbb38.test 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # 2012 May 11
  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.
  12. #
  13. # This file implements tests to verify that ticket [bdc6bbbb38] has been
  14. # fixed.
  15. #
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. set testprefix tkt-bdc6bbbb38
  19. # If SQLITE_ENABLE_FTS3 is defined, omit this file.
  20. ifcapable !fts3 { finish_test ; return }
  21. set sqlite_fts3_enable_parentheses 1
  22. foreach {tn idxdir} {1 ASC 2 DESC} {
  23. execsql { DROP TABLE IF EXISTS t2 }
  24. do_execsql_test $tn.1.1 "CREATE VIRTUAL TABLE t2 USING fts4(x, order=$idxdir)"
  25. do_execsql_test $tn.1.2 { INSERT INTO t2 VALUES('a b c') }
  26. do_execsql_test $tn.1.3 {
  27. SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC
  28. } {
  29. {0 0 0 1 0 2 2 1}
  30. }
  31. do_execsql_test $tn.1.4 {
  32. SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b'
  33. ORDER BY docid ASC
  34. } {
  35. {[a] [b] c}
  36. }
  37. do_execsql_test $tn.1.5 { INSERT INTO t2 VALUES('a c d') }
  38. do_execsql_test $tn.1.6 {
  39. SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC
  40. } {
  41. {0 0 0 1 0 2 2 1}
  42. {0 0 0 1 0 1 4 1}
  43. }
  44. do_execsql_test $tn.1.7 {
  45. SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b'
  46. ORDER BY docid ASC
  47. } {
  48. {[a] [b] c}
  49. {[a] c [d]}
  50. }
  51. execsql { DROP TABLE IF EXISTS t3 }
  52. do_execsql_test $tn.2.1 "CREATE VIRTUAL TABLE t3 USING fts4(x, order=$idxdir)"
  53. do_execsql_test $tn.2.2 { INSERT INTO t3 VALUES('a c d') }
  54. do_execsql_test $tn.2.3 {
  55. SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC
  56. } {
  57. {0 0 0 1 0 1 4 1}
  58. }
  59. do_execsql_test $tn.2.4 {
  60. SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b'
  61. ORDER BY docid DESC
  62. } {
  63. {[a] c [d]}
  64. }
  65. do_execsql_test $tn.2.5 {
  66. INSERT INTO t3 VALUES('a b c');
  67. }
  68. do_execsql_test $tn.2.6 {
  69. SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC
  70. } {
  71. {0 0 0 1 0 2 2 1}
  72. {0 0 0 1 0 1 4 1}
  73. }
  74. do_execsql_test $tn.2.7 {
  75. SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b'
  76. ORDER BY docid DESC
  77. } {
  78. {[a] [b] c}
  79. {[a] c [d]}
  80. }
  81. }
  82. set sqlite_fts3_enable_parentheses 0
  83. finish_test