fts5faultD.test 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 fts5faultD
  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. if {"%DETAIL%"=="none"} continue
  24. do_execsql_test 1.0 {
  25. CREATE VIRTUAL TABLE o1 USING fts5(a, b, c, detail=%DETAIL%);
  26. INSERT INTO o1(o1, rank) VALUES('pgsz', 32);
  27. WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<60 )
  28. INSERT INTO o1 SELECT 'A', 'B', 'C' FROM s;
  29. WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<60 )
  30. INSERT INTO o1 SELECT 'C', 'A', 'B' FROM s;
  31. WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<60 )
  32. INSERT INTO o1 SELECT 'B', 'C', 'A' FROM s;
  33. }
  34. do_faultsim_test 1 -faults int* -prep {
  35. sqlite3 db test.db
  36. } -body {
  37. execsql { SELECT count(*) FROM o1('a') }
  38. } -test {
  39. faultsim_test_result {0 180} {1 {vtable constructor failed: o1}}
  40. }
  41. do_faultsim_test 2 -faults int* -prep {
  42. sqlite3 db test.db
  43. } -body {
  44. execsql { SELECT * FROM o1('a:a AND {b c}:b') ORDER BY rank }
  45. expr 1
  46. } -test {
  47. faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}
  48. }
  49. do_faultsim_test 3 -faults int* -prep {
  50. sqlite3 db test.db
  51. } -body {
  52. execsql { SELECT * FROM o1('{b c}:b NOT a:a') ORDER BY rank }
  53. expr 1
  54. } -test {
  55. faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}
  56. }
  57. do_faultsim_test 4 -faults int* -prep {
  58. sqlite3 db test.db
  59. } -body {
  60. execsql { SELECT * FROM o1('b:b OR a:a') }
  61. expr 1
  62. } -test {
  63. faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}
  64. }
  65. do_faultsim_test 5 -faults int* -prep {
  66. sqlite3 db test.db
  67. } -body {
  68. execsql { SELECT count(*) FROM o1('c:b') }
  69. expr 1
  70. } -test {
  71. faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}
  72. }
  73. }
  74. finish_test