xref: /sqlite-3.40.0/test/fts4record.test (revision 572b0ddd)
1*572b0dddSdan# 2019 September 18
2*572b0dddSdan#
3*572b0dddSdan# The author disclaims copyright to this source code.  In place of
4*572b0dddSdan# a legal notice, here is a blessing:
5*572b0dddSdan#
6*572b0dddSdan#    May you do good and not evil.
7*572b0dddSdan#    May you find forgiveness for yourself and forgive others.
8*572b0dddSdan#    May you share freely, never taking more than you give.
9*572b0dddSdan#
10*572b0dddSdan#*************************************************************************
11*572b0dddSdan# This file implements regression tests for SQLite library.  The
12*572b0dddSdan# focus of this script is testing the FTS4 module.
13*572b0dddSdan#
14*572b0dddSdan#
15*572b0dddSdan
16*572b0dddSdanset testdir [file dirname $argv0]
17*572b0dddSdansource $testdir/tester.tcl
18*572b0dddSdansource $testdir/fts3_common.tcl
19*572b0dddSdanset testprefix fts4record
20*572b0dddSdan
21*572b0dddSdan# If SQLITE_ENABLE_FTS3 is defined, omit this file.
22*572b0dddSdanifcapable !fts3 {
23*572b0dddSdan  finish_test
24*572b0dddSdan  return
25*572b0dddSdan}
26*572b0dddSdan
27*572b0dddSdansqlite3_fts3_may_be_corrupt 1
28*572b0dddSdan
29*572b0dddSdando_execsql_test 1.0 {
30*572b0dddSdan  CREATE VIRTUAL TABLE t1 USING fts4(x);
31*572b0dddSdan  INSERT INTO t1 VALUES('terma terma terma termb');
32*572b0dddSdan}
33*572b0dddSdan
34*572b0dddSdando_execsql_test 1.1 {
35*572b0dddSdan  SELECT quote(root) FROM t1_segdir
36*572b0dddSdan} {
37*572b0dddSdan  X'00057465726D6105010203030004016203010500'
38*572b0dddSdan}
39*572b0dddSdan
40*572b0dddSdanproc make_record_wrapper {args} { make_fts3record $args }
41*572b0dddSdandb func record make_record_wrapper
42*572b0dddSdan
43*572b0dddSdando_execsql_test 1.2 {
44*572b0dddSdan  select quote(
45*572b0dddSdan    record(0,    5, 'terma', 5, 1, 2, 3, 3, 0,
46*572b0dddSdan              4, 1, 'b'    , 3, 1, 5, 0
47*572b0dddSdan  ) );
48*572b0dddSdan} {
49*572b0dddSdan  X'00057465726D6105010203030004016203010500'
50*572b0dddSdan}
51*572b0dddSdan
52*572b0dddSdando_execsql_test 1.3.1 {
53*572b0dddSdan  UPDATE t1_segdir SET root =
54*572b0dddSdan    record(0,    5, 'terma', 5, 1, 2, 3, 3, 0,
55*572b0dddSdan              4, 1, 'b'    , 3, 1, 5,
56*572b0dddSdan              1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
57*572b0dddSdan              1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
58*572b0dddSdan              1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
59*572b0dddSdan          );
60*572b0dddSdan}
61*572b0dddSdan
62*572b0dddSdando_catchsql_test 1.3.2 {
63*572b0dddSdan  SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
64*572b0dddSdan} {1 {database disk image is malformed}}
65*572b0dddSdan
66*572b0dddSdando_execsql_test 1.4.1 {
67*572b0dddSdan  UPDATE t1_segdir SET root =
68*572b0dddSdan    record(0,    5, 'terma', 5, 1, 2, 3, 3, 0,
69*572b0dddSdan              4, 1, 'b'    , 4, 1, 5,
70*572b0dddSdan              256, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
71*572b0dddSdan              1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
72*572b0dddSdan              1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
73*572b0dddSdan          );
74*572b0dddSdan}
75*572b0dddSdan
76*572b0dddSdando_catchsql_test 1.4.2 {
77*572b0dddSdan  SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
78*572b0dddSdan} {1 {database disk image is malformed}}
79*572b0dddSdan
80*572b0dddSdando_execsql_test 1.4.3 {
81*572b0dddSdan  SELECT quote(root) FROM t1_segdir
82*572b0dddSdan} {
83*572b0dddSdan  X'00057465726D610501020303000401620401058002010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100'
84*572b0dddSdan}
85*572b0dddSdan
86*572b0dddSdando_execsql_test 1.5.1 {
87*572b0dddSdan  UPDATE t1_segdir SET root =
88*572b0dddSdan    record(0,    5, 'terma', 5, 1, 2, 3, 3, 0,
89*572b0dddSdan              4, 1, 'b'    , 4, 1, 5,
90*572b0dddSdan              256, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
91*572b0dddSdan              1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
92*572b0dddSdan              1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
93*572b0dddSdan          );
94*572b0dddSdan}
95*572b0dddSdan
96*572b0dddSdando_catchsql_test 1.4.2 {
97*572b0dddSdan  SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
98*572b0dddSdan} {1 {database disk image is malformed}}
99*572b0dddSdan
100*572b0dddSdando_execsql_test 1.4.3 {
101*572b0dddSdan  SELECT quote(root) FROM t1_segdir
102*572b0dddSdan} {
103*572b0dddSdan  X'00057465726D610501020303000401620401058002010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100'
104*572b0dddSdan}
105*572b0dddSdan
106*572b0dddSdan
107*572b0dddSdando_execsql_test 1.5.1 {
108*572b0dddSdan  UPDATE t1_segdir SET root =
109*572b0dddSdan  X'00057465726D61050102030300040162040105FF00010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100'
110*572b0dddSdan}
111*572b0dddSdan
112*572b0dddSdando_catchsql_test 1.5.2 {
113*572b0dddSdan  SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'term*'
114*572b0dddSdan} {1 {database disk image is malformed}}
115*572b0dddSdan
116*572b0dddSdando_catchsql_test 1.5.3 {
117*572b0dddSdan  INSERT INTO t1(t1) VALUES('integrity-check');
118*572b0dddSdan} {1 {database disk image is malformed}}
119*572b0dddSdan
120*572b0dddSdanfinish_test
121