3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #*************************************************************************
12 # This file is focused on OOM errors.
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 source $testdir/malloc_common.tcl
17 set testprefix fts5fault3
19 # If SQLITE_ENABLE_FTS3 is defined, omit this file.
25 #-------------------------------------------------------------------------
26 # An OOM while resuming a partially completed segment merge.
28 db func rnddoc fts5_rnddoc
32 CREATE VIRTUAL TABLE xx USING fts5(x);
33 INSERT INTO xx(xx, rank) VALUES('pgsz', 32);
34 INSERT INTO xx(xx, rank) VALUES('automerge', 16);
36 for {set i 0} {$i < 10} {incr i} {
39 INSERT INTO xx(x) VALUES(rnddoc(20));
40 INSERT INTO xx(x) VALUES(rnddoc(20));
41 INSERT INTO xx(x) VALUES(rnddoc(20));
47 INSERT INTO xx(xx, rank) VALUES('automerge', 2);
48 INSERT INTO xx(xx, rank) VALUES('merge', 50);
51 faultsim_save_and_close
53 do_faultsim_test 1 -faults oom-* -prep {
54 faultsim_restore_and_reopen
56 execsql { INSERT INTO xx(xx, rank) VALUES('merge', 1) }
58 faultsim_test_result [list 0 {}]
61 #-------------------------------------------------------------------------
62 # An OOM while flushing an unusually large term to disk.
66 CREATE VIRTUAL TABLE xx USING fts5(x);
67 INSERT INTO xx(xx, rank) VALUES('pgsz', 32);
69 faultsim_save_and_close
71 set doc "a long term abcdefghijklmnopqrstuvwxyz "
72 append doc "and then abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz "
73 append doc [string repeat "abcdefghijklmnopqrstuvwxyz" 10]
75 do_faultsim_test 2 -faults oom-* -prep {
76 faultsim_restore_and_reopen
78 execsql { INSERT INTO xx(x) VALUES ($::doc) }
80 faultsim_test_result [list 0 {}]
83 #-------------------------------------------------------------------------
84 # An OOM while flushing an unusually large term to disk.
88 CREATE VIRTUAL TABLE xx USING fts5(x);
90 faultsim_save_and_close
92 set doc [fts5_rnddoc 1000]
93 do_faultsim_test 3.1 -faults oom-* -prep {
94 faultsim_restore_and_reopen
96 execsql { INSERT INTO xx(x) VALUES ($::doc) }
98 faultsim_test_result [list 0 {}]
101 set doc [string repeat "abc " 100]
102 do_faultsim_test 3.2 -faults oom-* -prep {
103 faultsim_restore_and_reopen
105 execsql { INSERT INTO xx(x) VALUES ($::doc) }
107 faultsim_test_result [list 0 {}]