Debian Codegraph @

ext/fts5/test/fts5integrity2.test

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