Debian Codegraph @

ext/fts5/test/fts5ubsan.test

raw
1 # 2022 August 9
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 test is focused on edge cases that cause ubsan errors.
13 #
14
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 set testprefix fts5ubsan
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 1.0 {
25 CREATE VIRTUAL TABLE x1 USING fts5(x);
26 }
27
28 set BIG 9000000000000000000
29 set SMALL -9000000000000000000
30
31 do_execsql_test 1.1 {
32 BEGIN;
33 INSERT INTO x1 (rowid, x) VALUES($BIG, 'aaa aba acc');
34 INSERT INTO x1 (rowid, x) VALUES($SMALL, 'aaa abc acb');
35 COMMIT;
36 }
37
38 do_execsql_test 1.2 {
39 SELECT rowid, x FROM x1('ab*');
40 } [list $SMALL {aaa abc acb} $BIG {aaa aba acc}]
41
42 do_execsql_test 1.3 {
43 SELECT rowid, x FROM x1('ac*');
44 } [list $SMALL {aaa abc acb} $BIG {aaa aba acc}]
45
46 reset_db
47 do_execsql_test 2.0 {
48 CREATE VIRTUAL TABLE x1 USING fts5(x);
49 }
50
51 do_execsql_test 2.1 {
52 INSERT INTO x1 (rowid, x) VALUES($BIG, 'aaa aba acc');
53 INSERT INTO x1 (rowid, x) VALUES($SMALL, 'aaa abc acb');
54 }
55
56 do_execsql_test 2.2 {
57 INSERT INTO x1 (x1) VALUES('optimize');
58 }
59
60 finish_test