fts5faultA.test 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # 2016 February 2
  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. # This file is focused on OOM errors.
  13. #
  14. source [file join [file dirname [info script]] fts5_common.tcl]
  15. source $testdir/malloc_common.tcl
  16. set testprefix fts5faultA
  17. # If SQLITE_ENABLE_FTS3 is defined, omit this file.
  18. ifcapable !fts5 {
  19. finish_test
  20. return
  21. }
  22. foreach_detail_mode $testprefix {
  23. do_execsql_test 1.0 {
  24. CREATE VIRTUAL TABLE o1 USING fts5(a, detail=%DETAIL%);
  25. INSERT INTO o1(o1, rank) VALUES('pgsz', 32);
  26. WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 )
  27. INSERT INTO o1 SELECT 'A B C' FROM s;
  28. INSERT INTO o1 VALUES('A X C');
  29. WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 )
  30. INSERT INTO o1 SELECT 'A B C' FROM s;
  31. }
  32. do_faultsim_test 1 -faults oom* -prep {
  33. sqlite3 db test.db
  34. } -body {
  35. execsql { SELECT rowid FROM o1('a NOT b') }
  36. } -test {
  37. faultsim_test_result {0 301}
  38. }
  39. }
  40. do_execsql_test 2.0 {
  41. CREATE VIRTUAL TABLE o2 USING fts5(a);
  42. INSERT INTO o2 VALUES('A B C');
  43. WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 )
  44. INSERT INTO o2 SELECT group_concat('A B C ') FROM s;
  45. }
  46. do_faultsim_test 2 -faults oom* -prep {
  47. sqlite3 db test.db
  48. } -body {
  49. execsql { SELECT rowid FROM o2('a+b+c NOT xyz') }
  50. } -test {
  51. faultsim_test_result {0 {1 2}}
  52. }
  53. finish_test