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 / fts3corrupt5.test

59 lines · 1474 bytes Raw Blame History
1# 2019 May 22
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#
13
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16source $testdir/fts3_common.tcl
17set testprefix fts3corrupt5
18
19# If SQLITE_ENABLE_FTS3 is defined, omit this file.
20ifcapable !fts3 {
21 finish_test
22 return
23}
24
25sqlite3_fts3_may_be_corrupt 1
26
27do_execsql_test 1.0 {
28 BEGIN;
29 CREATE VIRTUAL TABLE ft USING fts3(a, b, c);
30 INSERT INTO ft VALUES('one', 'one', 'one');
31 COMMIT;
32}
33
34do_execsql_test 1.1 {
35 SELECT * FROM ft WHERE ft MATCH 'b:one'
36} {one one one}
37
38do_execsql_test 1.2 {
39 SELECT quote(root) FROM ft_segdir;
40} {X'00036F6E6509010201010201020200'}
41
42breakpoint
43foreach {tn val q bCorrupt} {
44 1 X'00036F6E650901' 'b:one' 1
45 2 X'00036F6E6509010201010201FFFFFF' 'c:one' 1
46 3 X'00036F6E6501' 'b:one' 1
47 4 X'00036F6E650101' 'b:one' 1
48 5 X'00036F6E650100' 'b:one' 0
49} {
50 do_execsql_test 1.3.$tn.1 "UPDATE ft_segdir SET root = $val"
51
52 set res {0 {}}
53 if {$bCorrupt} { set res {1 {database disk image is malformed}}}
54 do_catchsql_test 1.3.$tn.2 {
55 SELECT * FROM ft WHERE ft MATCH $q
56 } $res
57}
58
59finish_test