/ Check-in [5dfc4fe9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add new test file fts5corrupt4.test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5dfc4fe98a4821cbdbfd7dfddf221b00251b2a26bf58767a3956b64e9a4e92da
User & Date: dan 2019-05-16 16:44:47
Context
2019-05-16
20:13
Fix an assert() in the OP_Delete opcode that could fail with a corrupt database. check-in: 915388ab user: dan tags: trunk
16:44
Add new test file fts5corrupt4.test. check-in: 5dfc4fe9 user: dan tags: trunk
11:47
Fix a harmless use-of-initialized-value fault in the assert() logic added by check-in [d612fb7873cf59d] check-in: 3dac9072 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added ext/fts5/test/fts5corrupt4.test.

            1  +# 2019 May 16
            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  +
           14  +source [file join [file dirname [info script]] fts5_common.tcl]
           15  +set testprefix fts5corrupt4
           16  +
           17  +# If SQLITE_ENABLE_FTS5 is defined, omit this file.
           18  +ifcapable !fts5 {
           19  +  finish_test
           20  +  return
           21  +}
           22  +sqlite3_fts5_may_be_corrupt 1
           23  +
           24  +do_execsql_test 1.0 {
           25  +  CREATE VIRTUAL TABLE ttt USING fts5(a, b); 
           26  +  INSERT INTO ttt 
           27  +     VALUES('e ee eee e ee eee e ee eee', 'eee ee e e e ee eee ee ee');
           28  +  INSERT INTO ttt SELECT a||a, b||b FROM ttt;   
           29  +  INSERT INTO ttt SELECT a||a, b||b FROM ttt;   
           30  +}
           31  +
           32  +proc mutate {blob i} {
           33  +  set o [expr {$i % [string length $blob]}]
           34  +  set a [string range $blob 0 $o-1]
           35  +  set b [string range $blob $o+1 end]
           36  +  set v [expr int(rand()*255) - 127]
           37  +  return "$a[binary format c $v]$b"
           38  +}
           39  +db func mutate mutate
           40  +
           41  +for {set j 1000} {$j <= 5000} {incr j 1000} {
           42  +  do_test 1.$j {
           43  +    for {set i 0} {$i < 1000} {incr i} {
           44  +      execsql {
           45  +        BEGIN;
           46  +          UPDATE ttt_data SET block = mutate(block, $i) WHERE id>10;
           47  +      }
           48  +      foreach sql {
           49  +        {SELECT snippet(ttt, -1, '.', '..', '[', ']'), * FROM ttt('e*')}
           50  +        {SELECT snippet(ttt, -1, '.', '..', '[', ']'), * FROM ttt('e* NOT ee*')}
           51  +      } {
           52  +        catch { execsql $sql }
           53  +      }
           54  +      execsql ROLLBACK
           55  +    }
           56  +  } {}
           57  +}
           58  +
           59  +sqlite3_fts5_may_be_corrupt 0
           60  +finish_test
           61  +