fts5faultE.test 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 fts5faultE
  17. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  18. ifcapable !fts5 {
  19. finish_test
  20. return
  21. }
  22. faultsim_save_and_close
  23. do_faultsim_test 1 -prep {
  24. faultsim_restore_and_reopen
  25. } -body {
  26. execsql { CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram) }
  27. } -test {
  28. faultsim_test_result {0 {}} {1 {vtable constructor failed: t1}}
  29. }
  30. reset_db
  31. do_execsql_test 2.0 {
  32. CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram);
  33. }
  34. faultsim_save_and_close
  35. do_faultsim_test 2 -prep {
  36. faultsim_restore_and_reopen
  37. } -body {
  38. execsql {
  39. INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz', NULL);
  40. SELECT count(*) FROM t1 WHERE x LIKE '%mnop%' AND t1 MATCH 'jkl';
  41. }
  42. } -test {
  43. faultsim_test_result {0 1} {1 {vtable constructor failed: t1}}
  44. }
  45. reset_db
  46. do_execsql_test 3.0 {
  47. CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram, detail=none);
  48. INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz', NULL);
  49. }
  50. faultsim_save_and_close
  51. do_faultsim_test 3 -prep {
  52. faultsim_restore_and_reopen
  53. } -body {
  54. execsql {
  55. SELECT count(*) FROM t1 WHERE x LIKE '%mnopqrs%' AND t1 MATCH 'abc'
  56. }
  57. } -test {
  58. faultsim_test_result {0 1} {1 {vtable constructor failed: t1}}
  59. }
  60. finish_test