Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/fts3corrupt6.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / fts3corrupt6.test` 116 lines ยท 5617 bytes Raw Blame History 1 # 2020 June 8 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 # This file implements regression tests for SQLite library. The 12 # focus of this script is testing the FTS3 module. 13 # 14 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 source $testdir/fts3_common.tcl 18 set testprefix fts3corrupt6 19 20 # If SQLITE_ENABLE_FTS3 is defined, omit this file. 21 ifcapable !fts3 { 22 finish_test 23 return 24 } 25 26 set ::saved_sqlite_fts3_enable_parentheses $::sqlite_fts3_enable_parentheses 27 set sqlite_fts3_enable_parentheses 1 28 sqlite3_fts3_may_be_corrupt 1 29 database_may_be_corrupt 30 31 do_execsql_test 1.0 { 32 BEGIN TRANSACTION; 33 CREATE TABLE t_content(col0 INTEGER); 34 PRAGMA writable_schema=ON; 35 CREATE VIRTUAL TABLE t0 USING fts3(col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY); 36 INSERT INTO t0_content VALUES(0,NULL,NULL,NULL,NULL); 37 INSERT INTO t0_segdir VALUES(0,0,0,0,'0 42',X'`000131030102000103323334050101010200000461616161050101020200000462626262050101030200`'); 38 COMMIT; 39 } 40 41 do_execsql_test 1.1 { 42 SELECT 0+matchinfo(t0,'yxyyxy') FROM t0 WHERE t0 MATCH CAST( x'`2b0a312b0a312a312a2a0b5d0a0b0b0a312a0a0b0b0a312a0b310a392a0b0a27312a2a0b5d0a312a0b310a31315d0b310a312a316d2a0b313b15bceaa50a312a0b0a27312a2a0b5d0a312a0b310a312b0b2a310a312a0b2a0b2a0b2e5d0a0bff313336e34a2a312a0b0a3c310b0a0b4b4b0b4b2a4bec40322b2a0b310a0a312a0a0a0a0a0a0a0a0a0b310a312a2a2a0b5d0a0b0b0a312a0b310a312a0b0a4e4541530b310a5df5ced70a0a0a0a0a4f520a0a0a0a0a0a0a312a0b0a4e4541520b310a5d616161610a0a0a0a4f520a0a0a0a0a0a312b0a312a312a0a0a0a0a0a0a004a0b0a310b220a0b0a310a4a22310a0b0a7e6fe0e0e030e0e0e0e0e01176e02000e0e0e0e0e01131320226310a0b0a310a4a22310a0b0a310a766f8b8b4ee0e0300ae0090909090909090909090909090909090909090909090909090909090909090947aaaa540b09090909090909090909090909090909090909090909090909090909090909fae0e0f2f22164e0e0f273e07fefefef7d6dfafafafa6d6d6d6d`' AS TEXT); 43 } {0} 44 45 do_execsql_test 1.2 { 46 CREATE VIRTUAL TABLE t1 USING fts3(col0 INTEGER PRIMARY KEY,col1 VARCHAR(8),col2 BINARY,col3 BINARY); 47 INSERT INTO t1_content VALUES(0,NULL,NULL,NULL,NULL); 48 INSERT INTO t1_segdir VALUES(0,0,0,0,'0 42',X'`000131030102000103323334050101010200000461616161050101020200000462626262050101030200`'); 49 } 50 51 do_execsql_test 1.3 { 52 SELECT 42+matchinfo(t1,'yxyyxy') FROM t1 WHERE t1 MATCH x'`2b0a312b0a312a312a2a0b5d0a0b0b0a312a0a0b0b0a312a0b310a392a0b0a27312a2a0b5d0a312a0b310a31315d0b310a312a316d2a0b313b15bceaa50a312a0b0a27312a2a0b5d0a312a0b310a312b0b2a310a312a0b2a0b2a0b2e5d0a0bff313336e34a2a312a0b0a3c310b0a0b4b4b0b4b2a4bec40322b2a0b310a0a312a0a0a0a0a0a0a0a0a0b310a312a2a2a0b5d0a0b0b0a312a0b310a312a0b0a4e4541530b310a5df5ced70a0a0a0a0a4f520a0a0a0a0a0a0a312a0b0a4e4541520b310a5d616161610a0a0a0a4f520a0a0a0a0a0a312b0a312a312a0a0a0a0a0a0a004a0b0a310b220a0b0a310a4a22310a0b0a7e6fe0e0e030e0e0e0e0e01176e02000e0e0e0e0e01131320226310a0b0a310a4a22310a0b0a310a766f8b8b4ee0e0300ae0090909090909090909090909090909090909090909090909090909090909090947aaaa540b09090909090909090909090909090909090909090909090909090909090909fae0e0f2f22164e0e0f273e07fefefef7d6dfafafafa6d6d6d6d`'; 53 } {42} 54 55 #------------------------------------------------------------------------- 56 reset_db 57 do_execsql_test 2.0 { 58 CREATE VIRTUAL TABLE t0 USING fts3(a); 59 INSERT INTO t0_segdir VALUES(0,0,0,0,'0 42',X'`000131030782000103323334050100fff200010461616161050101020200000462626262050101030200`'); 60 } 61 do_execsql_test 2.1 { 62 SELECT count(*) FROM t0 WHERE t0 MATCH '(1 NEAR 1) AND (aaaa OR 1)'; 63 } 1 64 65 #------------------------------------------------------------------------- 66 reset_db 67 do_catchsql_test 3.0 { 68 CREATE VIRTUAL TABLE main.Table0 USING fts3(); 69 INSERT INTO Table0 VALUES (1), (printf('%8.1280000X') ), (1), (printf('%8.1280000X') ), (1) ; 70 INSERT INTO Table0 VALUES (0), (printf('%8.1280000X%8.1280000X') ), (1), (printf('%`1280000`.1280000X%#`1280000`.1280000E%8.1280000X') ), (1) ; 71 INSERT INTO Table0 VALUES (1) ; 72 UPDATE Table0_segdir SET start_block = 1; 73 INSERT INTO Table0 VALUES (1) ; 74 INSERT INTO Table0(Table0) VALUES('merge=6,8'); 75 } {1 {database disk image is malformed}} 76 77 #------------------------------------------------------------------------- 78 reset_db 79 do_execsql_test 4.0 { 80 CREATE VIRTUAL TABLE t USING fts4(c); 81 INSERT INTO t(t) VALUES('nodesize=200'); 82 INSERT INTO t VALUES('alpha bravo charlie delta echo foxtrot golf hotel india juliet kilo lima mike november'); 83 INSERT INTO t VALUES('oscar papa quebec romeo sierra tango uniform victor whiskey xray yankee zulu alpha bravo'); 84 INSERT INTO t(t) VALUES('merge=16,4'); 85 UPDATE t_segdir SET end_block = start_block + `2147483647` WHERE level=0; 86 INSERT OR REPLACE INTO t_segments(blockid,block) 87 SELECT start_block+`2147483647`, NULL FROM t_segdir WHERE level=0; 88 } 89 90 do_execsql_test 4.1 { 91 PRAGMA integrity_check 92 } {ok} 93 94 do_execsql_test 4.2 { 95 INSERT INTO t VALUES( 96 'mike november oscar papa quebec romeo 97 sierra tango uniform victor whiskey xray yankee' 98 ); 99 INSERT INTO t VALUES( 100 'charlie delta echo foxtrot golf hotel india 101 juliet kilo lima mike november oscar papa' 102 ); 103 INSERT INTO t(t) VALUES('merge=16,4'); 104 SELECT blockid FROM t_segments ORDER BY blockid; 105 } { 106 `2147483647` `2147483648` `2147483649` `2147483775` 107 } 108 109 do_execsql_test 4.3 { 110 PRAGMA integrity_check 111 } {ok} 112 113 114 set sqlite_fts3_enable_parentheses $saved_sqlite_fts3_enable_parentheses 115 finish_test 116