fts5integrity2.test 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # 2024 September 3
  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 contains tests focused on the integrity-check procedure.
  13. #
  14. source [file join [file dirname [info script]] fts5_common.tcl]
  15. set testprefix fts5integrity2
  16. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  17. ifcapable !fts5 {
  18. finish_test
  19. return
  20. }
  21. do_execsql_test 2.0 {
  22. CREATE VIRTUAL TABLE t2 USING fts5(a, detail='none');
  23. BEGIN;
  24. INSERT INTO t2(rowid, a) VALUES(-1, 'hello world');
  25. INSERT INTO t2(rowid, a) VALUES(9223372036854775807, 'hello world');
  26. COMMIT;
  27. }
  28. do_execsql_test 2.1 {
  29. SELECT rowid FROM t2('hello AND world');
  30. } {-1 9223372036854775807}
  31. #-------------------------------------------------------------------------
  32. do_execsql_test 2.0 {
  33. CREATE VIRTUAL TABLE t1 USING fts5(a, detail='none');
  34. CREATE TABLE r1(r);
  35. WITH c(x) AS (VALUES(1) UNION SELECT x<<1 FROM c)
  36. INSERT INTO r1(r) SELECT -1-x FROM c;
  37. INSERT INTO t1(rowid, a) SELECT r, 'abc' FROM r1;
  38. }
  39. do_execsql_test 2.1 {
  40. PRAGMA integrity_check;
  41. } {ok}
  42. do_execsql_test 2.2 {
  43. SELECT rowid FROM t1('abc') ORDER BY +rowid;
  44. } [db eval {SELECT r FROM r1 ORDER BY r}]
  45. finish_test