Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: third_party/sqlite/sqlite-src-3170000/ext/fts5/test/fts5fault3.test

Issue 2747283002: [sql] Import reference version of SQLite 3.17.. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # 2014 June 17
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 # This file is focused on OOM errors.
13 #
14
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 source $testdir/malloc_common.tcl
17 set testprefix fts5fault3
18
19 # If SQLITE_ENABLE_FTS3 is defined, omit this file.
20 ifcapable !fts5 {
21 finish_test
22 return
23 }
24
25 #-------------------------------------------------------------------------
26 # An OOM while resuming a partially completed segment merge.
27 #
28 db func rnddoc fts5_rnddoc
29 do_test 1.0 {
30 expr srand(0)
31 execsql {
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);
35 }
36 for {set i 0} {$i < 10} {incr i} {
37 execsql {
38 BEGIN;
39 INSERT INTO xx(x) VALUES(rnddoc(20));
40 INSERT INTO xx(x) VALUES(rnddoc(20));
41 INSERT INTO xx(x) VALUES(rnddoc(20));
42 COMMIT
43 }
44 }
45
46 execsql {
47 INSERT INTO xx(xx, rank) VALUES('automerge', 2);
48 INSERT INTO xx(xx, rank) VALUES('merge', 50);
49 }
50 } {}
51 faultsim_save_and_close
52
53 do_faultsim_test 1 -faults oom-* -prep {
54 faultsim_restore_and_reopen
55 } -body {
56 execsql { INSERT INTO xx(xx, rank) VALUES('merge', 1) }
57 } -test {
58 faultsim_test_result [list 0 {}]
59 }
60
61 #-------------------------------------------------------------------------
62 # An OOM while flushing an unusually large term to disk.
63 #
64 reset_db
65 do_execsql_test 2.0 {
66 CREATE VIRTUAL TABLE xx USING fts5(x);
67 INSERT INTO xx(xx, rank) VALUES('pgsz', 32);
68 }
69 faultsim_save_and_close
70
71 set doc "a long term abcdefghijklmnopqrstuvwxyz "
72 append doc "and then abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz "
73 append doc [string repeat "abcdefghijklmnopqrstuvwxyz" 10]
74
75 do_faultsim_test 2 -faults oom-* -prep {
76 faultsim_restore_and_reopen
77 } -body {
78 execsql { INSERT INTO xx(x) VALUES ($::doc) }
79 } -test {
80 faultsim_test_result [list 0 {}]
81 }
82
83 #-------------------------------------------------------------------------
84 # An OOM while flushing an unusually large term to disk.
85 #
86 reset_db
87 do_execsql_test 3.0 {
88 CREATE VIRTUAL TABLE xx USING fts5(x);
89 }
90 faultsim_save_and_close
91
92 set doc [fts5_rnddoc 1000]
93 do_faultsim_test 3.1 -faults oom-* -prep {
94 faultsim_restore_and_reopen
95 } -body {
96 execsql { INSERT INTO xx(x) VALUES ($::doc) }
97 } -test {
98 faultsim_test_result [list 0 {}]
99 }
100
101 set doc [string repeat "abc " 100]
102 do_faultsim_test 3.2 -faults oom-* -prep {
103 faultsim_restore_and_reopen
104 } -body {
105 execsql { INSERT INTO xx(x) VALUES ($::doc) }
106 } -test {
107 faultsim_test_result [list 0 {}]
108 }
109
110
111
112 finish_test
113
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698