123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- # 2010 June 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]
- source $testdir/malloc_common.tcl
- set testprefix fts5faultI
- # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
- ifcapable !fts5 {
- finish_test
- return
- }
- set ::testprefix fts5faultI
- do_execsql_test 1.0 {
- PRAGMA encoding = utf16;
- CREATE VIRTUAL TABLE t1 USING fts5(x, locale=1);
- INSERT INTO t1 VALUES('origintext unicode61 ascii porter trigram');
- }
- faultsim_save_and_close
- faultsim_restore_and_reopen
- do_faultsim_test 1 -faults oom* -prep {
- } -body {
- execsql {
- SELECT rowid FROM t1(fts5_locale('en_US', 'origintext'));
- }
- } -test {
- faultsim_test_result {0 1}
- }
- do_faultsim_test 2 -faults oom* -prep {
- faultsim_restore_and_reopen
- execsql {
- SELECT * FROM t1('ascii');
- }
- } -body {
- execsql {
- UPDATE t1 SET rowid=rowid+1;
- }
- } -test {
- faultsim_test_result {0 {}}
- }
- fts5_aux_test_functions db
- do_faultsim_test 3 -faults oom* -prep {
- } -body {
- execsql {
- SELECT fts5_columnlocale(t1, 0) FROM t1('unicode*');
- }
- } -test {
- faultsim_test_result {0 {{}}} {1 SQLITE_NOMEM}
- }
- #-------------------------------------------------------------------------
- reset_db
- do_execsql_test 4.0 {
- CREATE VIRTUAL TABLE w1 USING fts5(a);
- }
- faultsim_save_and_close
- do_faultsim_test 4 -faults oom* -prep {
- faultsim_restore_and_reopen
- execsql {
- BEGIN;
- INSERT INTO w1 VALUES('token token token');
- }
- } -body {
- execsql {
- INSERT INTO w1(w1, rank) VALUES('rank', 'bm25()');
- }
- } -test {
- faultsim_test_result {0 {}}
- }
- do_faultsim_test 5 -faults oom* -prep {
- faultsim_restore_and_reopen
- execsql {
- BEGIN;
- INSERT INTO w1 VALUES('one');
- SAVEPOINT one;
- INSERT INTO w1 VALUES('two');
- ROLLBACK TO one;
- }
- } -body {
- execsql {
- INSERT INTO w1 VALUES('string');
- }
- } -test {
- faultsim_test_result {0 {}}
- }
- #-------------------------------------------------------------------------
- reset_db
- do_execsql_test 5.0 {
- CREATE VIRTUAL TABLE w1 USING fts5(a);
- INSERT INTO w1 VALUES('one two three');
- }
- fts5_aux_test_functions db
- do_faultsim_test 5 -faults oom* -prep {
- } -body {
- execsql {
- SELECT fts5_test_insttoken(w1, 0, 0) FROM w1('two');
- }
- } -test {
- faultsim_test_result {0 two} {1 SQLITE_NOMEM}
- }
- #-------------------------------------------------------------------------
- reset_db
- do_execsql_test 6.0 {
- CREATE VIRTUAL TABLE w1 USING fts5(a);
- INSERT INTO w1 VALUES('one two three');
- }
- fts5_aux_test_functions db
- faultsim_save_and_close
- do_faultsim_test 6 -faults oom* -prep {
- faultsim_restore_and_reopen
- db eval {
- BEGIN;
- INSERT INTO w1 VALUES('four five six');
- SAVEPOINT abc;
- INSERT INTO w1 VALUES('seven eight nine');
- SAVEPOINT def;
- INSERT INTO w1 VALUES('ten eleven twelve');
- }
- } -body {
- execsql {
- RELEASE abc;
- }
- } -test {
- faultsim_test_result {0 {}}
- }
- #-------------------------------------------------------------------------
- reset_db
- do_execsql_test 7.0 {
- CREATE VIRTUAL TABLE w1 USING fts5(a);
- INSERT INTO w1 VALUES('one two three');
- INSERT INTO w1 VALUES('three two one');
- DELETE FROM w1_content WHERE rowid=1;
- }
- faultsim_save_and_close
- do_faultsim_test 7 -faults oom* -prep {
- faultsim_restore_and_reopen
- db eval { SELECT * FROM w1 }
- } -body {
- execsql {
- PRAGMA integrity_check;
- }
- } -test {
- }
- #-------------------------------------------------------------------------
- reset_db
- fts5_tclnum_register db
- fts5_aux_test_functions db
- do_execsql_test 8.0 {
- CREATE VIRTUAL TABLE ft USING fts5(
- x, tokenize = "tclnum query", detail=columns
- );
- INSERT INTO ft VALUES('one two three i ii iii');
- INSERT INTO ft VALUES('four five six iv v vi');
- INSERT INTO ft VALUES('eight nine ten viii ix x');
- } {}
- do_faultsim_test 8.1 -faults oom* -prep {
- } -body {
- execsql {
- SELECT fts5_test_collist (ft) FROM ft('one two');
- }
- } -test {
- faultsim_test_result {0 {{0.0 1.0}}} {1 {SQL logic error}} {1 SQLITE_NOMEM}
- }
- do_faultsim_test 8.2 -faults oom* -prep {
- } -body {
- execsql {
- SELECT rowid FROM ft('one two') ORDER BY rank;
- }
- } -test {
- faultsim_test_result {0 1} {1 {SQL logic error}} {1 SQLITE_NOMEM}
- }
- #-------------------------------------------------------------------------
- reset_db
- do_execsql_test 9.0 {
- CREATE VIRTUAL TABLE ft USING fts5(x);
- INSERT INTO ft VALUES('one two three i ii iii');
- INSERT INTO ft VALUES('four five six iv v vi');
- INSERT INTO ft VALUES('eight nine ten viii ix x');
- } {}
- faultsim_save_and_close
- do_faultsim_test 9.1 -faults oom* -prep {
- faultsim_restore_and_reopen
- } -body {
- execsql {
- UPDATE ft SET rowid=4 WHERE rowid=1
- }
- } -test {
- faultsim_test_result {0 {}}
- }
- do_faultsim_test 9.2 -faults oom* -prep {
- faultsim_restore_and_reopen
- } -body {
- execsql {
- SELECT rowid FROM ft WHERE x MATCH 'one AND two AND three'
- }
- } -test {
- faultsim_test_result {0 1}
- }
- #-------------------------------------------------------------------------
- reset_db
- do_execsql_test 10.0 {
- CREATE VIRTUAL TABLE ft USING fts5(x, locale=1);
- INSERT INTO ft VALUES(fts5_locale('hello', 'one two three i ii iii'));
- INSERT INTO ft VALUES('four five six iv v vi');
- INSERT INTO ft VALUES('eight nine ten viii ix x');
- } {}
- do_execsql_test 10.1 {
- SELECT fts5_get_locale(ft, 0) FROM ft WHERE x MATCH 'one AND two AND three'
- } {hello}
- faultsim_save_and_close
- do_faultsim_test 10.1 -faults oom* -prep {
- faultsim_restore_and_reopen
- } -body {
- execsql {
- SELECT fts5_get_locale(ft, 0) FROM ft WHERE x MATCH 'one AND two AND three'
- }
- } -test {
- faultsim_test_result {0 hello}
- }
- breakpoint
- faultsim_save_and_close
- do_faultsim_test 10.2 -faults oom-t* -prep {
- faultsim_restore_and_reopen
- } -body {
- execsql {
- INSERT INTO ft VALUES(zeroblob(10000));
- }
- } -test {
- faultsim_test_result {0 {}}
- }
- #-------------------------------------------------------------------------
- reset_db
- do_execsql_test 11.0 {
- CREATE VIRTUAL TABLE f1 USING fts5(content);
- CREATE TABLE g1(id, content);
- INSERT INTO g1 VALUES(30000, 'a b c');
- INSERT INTO g1 VALUES(40000, 'd e f');
- }
- faultsim_save_and_close
- do_faultsim_test 11 -faults oom* -prep {
- faultsim_restore_and_reopen
- } -body {
- execsql {
- INSERT INTO f1(rowid, content) SELECT id, content FROM g1;
- }
- } -test {
- faultsim_test_result {0 {}}
- }
- finish_test
|