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 / ext / fts5 / test / fts5corrupt6.test

54 lines · 1469 bytes Raw Blame History
1# 2015 Apr 24
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 tests that FTS5 handles corrupt databases (i.e. internal
13# inconsistencies in the backing tables) correctly. In this case
14# "correctly" means without crashing.
15#
16
17source [file join [file dirname [info script]] fts5_common.tcl]
18set testprefix fts5corrupt6
19
20# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
21ifcapable !fts5 {
22 finish_test
23 return
24}
25sqlite3_fts5_may_be_corrupt 1
26database_may_be_corrupt
27
28proc editblock {block} {
29 binary format Sa* 20000 [string range $block 2 end]
30}
31db func editblock editblock
32
33do_execsql_test 1.0 {
34 CREATE VIRTUAL TABLE ft USING fts5(abc, def);
35 WITH a(i) AS (
36 SELECT 1 UNION ALL SELECT i+1 FROM a WHERE i<1000
37 )
38 INSERT INTO ft SELECT
39 'abc abc abc abc abc abc abc abc abc abc',
40 'def def def def def def def def def def'
41 FROM a;
42 UPDATE ft_data SET block = editblock(block) WHERE id=(
43 SELECT id FROM ft_data ORDER BY id LIMIT 1 OFFSET 5
44 );
45}
46
47do_catchsql_test 1.1 {
48 SELECT rowid FROM ft('def') ORDER BY rowid DESC LIMIT 1 OFFSET 9999;
49} {1 {database disk image is malformed}}
50
51
52sqlite3_fts5_may_be_corrupt 0
53finish_test
54