1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
# 2026 Jan 15
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
source [file join [file dirname [info script]] fts5_common.tcl]
set testprefix fts5corrupt9
# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
ifcapable !fts5 {
finish_test
return
}
sqlite3_fts5_may_be_corrupt 1
sqlite3 db test.db
set nrows 50
set repeat 500
set text [string trim [string repeat "aaa " $repeat]]
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE t USING fts5(content);
INSERT INTO t(t, rank) VALUES('secure-delete', 1);
}
do_test 1.1 {
for {set i 0} {$i < $nrows} {incr i} {
db eval "INSERT INTO t(content) VALUES('$text')"
}
db eval "INSERT INTO t(t) VALUES('optimize')"
} {}
do_test 1.2 {
db eval { SELECT segid, pgno FROM t_idx } {}
set rowid [expr {($segid << 37) + ($pgno >> 1)}]
db eval {
UPDATE t_data
SET block = X'00000009043061616104ffffffff07'
WHERE rowid=$rowid
}
} {}
# At one point this would segfault due to OOB write.
#
do_catchsql_test 1.3 {
DELETE FROM t WHERE rowid=3
} {0 {}}
sqlite3_fts5_may_be_corrupt 0
finish_test
|