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

Side by Side Diff: third_party/sqlite/sqlite-src-3170000/ext/fts5/test/fts5fault2.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 fts5fault2
18
19 # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
20 ifcapable !fts5 {
21 finish_test
22 return
23 }
24
25 set doc [string trim [string repeat "x y z " 200]]
26 do_execsql_test 1.0 {
27 CREATE TABLE t1(a INTEGER PRIMARY KEY, x);
28 CREATE VIRTUAL TABLE x1 USING fts5(x, content='t1', content_rowid='a');
29 INSERT INTO x1(x1, rank) VALUES('pgsz', 32);
30 WITH input(a,b) AS (
31 SELECT 1, $doc UNION ALL
32 SELECT a+1, ($doc || CASE WHEN (a+1)%100 THEN '' ELSE ' xyz' END)
33 FROM input WHERE a < 1000
34 )
35 INSERT INTO t1 SELECT * FROM input;
36
37 INSERT INTO x1(x1) VALUES('rebuild');
38 }
39
40 do_faultsim_test 1.1 -faults oom-* -prep {
41 } -body {
42 execsql { SELECT rowid FROM x1 WHERE x1 MATCH 'z AND xyz' }
43 } -test {
44 faultsim_test_result {0 {100 200 300 400 500 600 700 800 900 1000}}
45 }
46
47 do_faultsim_test 1.2 -faults oom-* -prep {
48 } -body {
49 execsql { SELECT rowid FROM x1 WHERE x1 MATCH 'z + xyz' ORDER BY 1 DESC}
50 } -test {
51 faultsim_test_result {0 {1000 900 800 700 600 500 400 300 200 100}}
52 }
53
54 #-------------------------------------------------------------------------
55 # OOM within a query that accesses the in-memory hash table.
56 #
57 reset_db
58 do_execsql_test 2.0 {
59 CREATE VIRTUAL TABLE "a b c" USING fts5(a, b, c);
60 INSERT INTO "a b c" VALUES('one two', 'x x x', 'three four');
61 INSERT INTO "a b c" VALUES('nine ten', 'y y y', 'two two');
62 }
63
64 do_faultsim_test 2.1 -faults oom-trans* -prep {
65 execsql {
66 BEGIN;
67 INSERT INTO "a b c" VALUES('one one', 'z z z', 'nine ten');
68 }
69 } -body {
70 execsql { SELECT rowid FROM "a b c" WHERE "a b c" MATCH 'one' }
71 } -test {
72 faultsim_test_result {0 {1 3}}
73 catchsql { ROLLBACK }
74 }
75
76 #-------------------------------------------------------------------------
77 # OOM within an 'optimize' operation that writes multiple pages to disk.
78 #
79 reset_db
80 do_execsql_test 3.0 {
81 CREATE VIRTUAL TABLE zzz USING fts5(z);
82 INSERT INTO zzz(zzz, rank) VALUES('pgsz', 32);
83 INSERT INTO zzz VALUES('a b c d');
84 INSERT INTO zzz SELECT 'c d e f' FROM zzz;
85 INSERT INTO zzz SELECT 'e f g h' FROM zzz;
86 INSERT INTO zzz SELECT 'i j k l' FROM zzz;
87 INSERT INTO zzz SELECT 'l k m n' FROM zzz;
88 INSERT INTO zzz SELECT 'o p q r' FROM zzz;
89 }
90 faultsim_save_and_close
91
92 do_faultsim_test 3.1 -faults oom-trans* -prep {
93 faultsim_restore_and_reopen
94 execsql { SELECT rowid FROM zzz }
95 } -body {
96 execsql { INSERT INTO zzz(zzz) VALUES('optimize') }
97 } -test {
98 faultsim_test_result {0 {}}
99 }
100
101 #-------------------------------------------------------------------------
102 # OOM within an 'integrity-check' operation.
103 #
104 reset_db
105 db func rnddoc fts5_rnddoc
106 do_execsql_test 4.0 {
107 CREATE VIRTUAL TABLE zzz USING fts5(z);
108 INSERT INTO zzz(zzz, rank) VALUES('pgsz', 32);
109 WITH ii(i) AS (SELECT 1 UNION SELECT i+1 FROM ii WHERE i<10)
110 INSERT INTO zzz SELECT rnddoc(10) || ' xccc' FROM ii;
111 }
112
113 do_faultsim_test 4.1 -faults oom-trans* -prep {
114 } -body {
115 execsql { INSERT INTO zzz(zzz) VALUES('integrity-check') }
116 } -test {
117 faultsim_test_result {0 {}}
118 }
119
120 #-------------------------------------------------------------------------
121 # OOM while parsing a tokenize=option
122 #
123 reset_db
124 faultsim_save_and_close
125 do_faultsim_test 5.0 -faults oom-* -prep {
126 faultsim_restore_and_reopen
127 } -body {
128 execsql {
129 CREATE VIRTUAL TABLE uio USING fts5(a, b,
130 tokenize="porter 'ascii'",
131 content="another table",
132 content_rowid="somecolumn"
133 );
134 }
135 } -test {
136 faultsim_test_result {0 {}}
137 }
138
139 finish_test
140
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698