interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / test / fts4record.test

120 lines · 3647 bytes Raw Blame History
1# 2019 September 18
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# This file implements regression tests for SQLite library. The
12# focus of this script is testing the FTS4 module.
13#
14#
15
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18source $testdir/fts3_common.tcl
19set testprefix fts4record
20
21# If SQLITE_ENABLE_FTS3 is defined, omit this file.
22ifcapable !fts3 {
23 finish_test
24 return
25}
26
27sqlite3_fts3_may_be_corrupt 1
28
29do_execsql_test 1.0 {
30 CREATE VIRTUAL TABLE t1 USING fts4(x);
31 INSERT INTO t1 VALUES('terma terma terma termb');
32}
33
34do_execsql_test 1.1 {
35 SELECT quote(root) FROM t1_segdir
36} {
37 X'00057465726D6105010203030004016203010500'
38}
39
40proc make_record_wrapper {args} { make_fts3record $args }
41db func record make_record_wrapper
42
43do_execsql_test 1.2 {
44 select quote(
45 record(0, 5, 'terma', 5, 1, 2, 3, 3, 0,
46 4, 1, 'b' , 3, 1, 5, 0
47 ) );
48} {
49 X'00057465726D6105010203030004016203010500'
50}
51
52do_execsql_test 1.3.1 {
53 UPDATE t1_segdir SET root =
54 record(0, 5, 'terma', 5, 1, 2, 3, 3, 0,
55 4, 1, 'b' , 3, 1, 5,
56 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
57 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
58 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
59 );
60}
61
62do_catchsql_test 1.3.2 {
63 SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
64} {1 {database disk image is malformed}}
65
66do_execsql_test 1.4.1 {
67 UPDATE t1_segdir SET root =
68 record(0, 5, 'terma', 5, 1, 2, 3, 3, 0,
69 4, 1, 'b' , 4, 1, 5,
70 256, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
71 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
72 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
73 );
74}
75
76do_catchsql_test 1.4.2 {
77 SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
78} {1 {database disk image is malformed}}
79
80do_execsql_test 1.4.3 {
81 SELECT quote(root) FROM t1_segdir
82} {
83 X'00057465726D610501020303000401620401058002010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100'
84}
85
86do_execsql_test 1.5.1 {
87 UPDATE t1_segdir SET root =
88 record(0, 5, 'terma', 5, 1, 2, 3, 3, 0,
89 4, 1, 'b' , 4, 1, 5,
90 256, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
91 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
92 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
93 );
94}
95
96do_catchsql_test 1.4.2 {
97 SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
98} {1 {database disk image is malformed}}
99
100do_execsql_test 1.4.3 {
101 SELECT quote(root) FROM t1_segdir
102} {
103 X'00057465726D610501020303000401620401058002010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100'
104}
105
106
107do_execsql_test 1.5.1 {
108 UPDATE t1_segdir SET root =
109 X'00057465726D61050102030300040162040105FF00010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100'
110}
111
112do_catchsql_test 1.5.2 {
113 SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
114} {1 {database disk image is malformed}}
115
116do_catchsql_test 1.5.3 {
117 INSERT INTO t1(t1) VALUES('integrity-check');
118} {1 {database disk image is malformed}}
119
120finish_test