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

Side by Side Diff: third_party/sqlite/src/test/recover1.test

Issue 9125018: Skeleton of SQLite virtual-table module to recover data from corrupt databases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mask constants to macros, upread README.chromium, copyright disclaimer on recover.c. Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/src/test/recover0.test ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2012 January 4 {}
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.
12 #
13 # Use tables to test leaf-node reading, and also type checking.
14 #
15 # $Id$
16
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
19
20 # A really basic table with manifest typing and a row of each type.
21 db close
22 sqlite3 db test.db
23 db eval {
24 DROP TABLE IF EXISTS types;
25 CREATE TABLE types (rowtype TEXT, value);
26 INSERT INTO types VALUES ("NULL", NULL);
27 INSERT INTO types VALUES ("INTEGER", 17);
28 INSERT INTO types VALUES ("FLOAT", 3.1415927);
29 INSERT INTO types VALUES ("TEXT", "This is text");
30 INSERT INTO types VALUES ("BLOB", CAST("This is a blob" AS BLOB));
31
32 -- Same contents, with an alias for rowid. Testing separately
33 -- because it changes the structure of the data (the alias column is
34 -- serialized as NULL).
35 DROP TABLE IF EXISTS types2;
36 CREATE TABLE types2 (id INTEGER PRIMARY KEY, rowtype TEXT, value);
37 INSERT INTO types2 (id, rowtype, value)
38 SELECT rowid, rowtype, value FROM types;
39 }
40
41 # Baseline results.
42 do_test recover-types-0.0 {
43 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types}
44 } {1 NULL {} null 2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is te xt} text 5 BLOB {This is a blob} blob}
45
46 # With no restrictions, recover table shows identical results.
47 do_test recover-types-0.1 {
48 db eval {
49 DROP TABLE IF EXISTS temp.types_recover;
50 CREATE VIRTUAL TABLE temp.types_recover USING recover(
51 types,
52 rowtype TEXT,
53 value
54 );
55 }
56 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
57 } {1 NULL {} null 2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is te xt} text 5 BLOB {This is a blob} blob}
58
59 # Restrict by INTEGER
60 do_test recover-types-1.0 {
61 db eval {
62 DROP TABLE IF EXISTS temp.types_recover;
63 CREATE VIRTUAL TABLE temp.types_recover USING recover(
64 types,
65 rowtype TEXT,
66 value INTEGER
67 );
68 }
69 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
70 } {1 NULL {} null 2 INTEGER 17 integer}
71
72 # Restrict by INTEGER NOT NULL
73 do_test recover-types-1.1 {
74 db eval {
75 DROP TABLE IF EXISTS temp.types_recover;
76 CREATE VIRTUAL TABLE temp.types_recover USING recover(
77 types,
78 rowtype TEXT,
79 value INTEGER NOT NULL
80 );
81 }
82 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
83 } {2 INTEGER 17 integer}
84
85 # Restrict by FLOAT
86 do_test recover-types-2.0 {
87 db eval {
88 DROP TABLE IF EXISTS temp.types_recover;
89 CREATE VIRTUAL TABLE temp.types_recover USING recover(
90 types,
91 rowtype TEXT,
92 value FLOAT
93 );
94 }
95 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
96 } {1 NULL {} null 2 INTEGER 17.0 real 3 FLOAT 3.1415927 real}
97
98 # Restrict by FLOAT NOT NULL
99 do_test recover-types-2.1 {
100 db eval {
101 DROP TABLE IF EXISTS temp.types_recover;
102 CREATE VIRTUAL TABLE temp.types_recover USING recover(
103 types,
104 rowtype TEXT,
105 value FLOAT NOT NULL
106 );
107 }
108 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
109 } {2 INTEGER 17.0 real 3 FLOAT 3.1415927 real}
110
111 # Restrict by FLOAT STRICT
112 do_test recover-types-2.2 {
113 db eval {
114 DROP TABLE IF EXISTS temp.types_recover;
115 CREATE VIRTUAL TABLE temp.types_recover USING recover(
116 types,
117 rowtype TEXT,
118 value FLOAT STRICT
119 );
120 }
121 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
122 } {1 NULL {} null 3 FLOAT 3.1415927 real}
123
124 # Restrict by FLOAT STRICT NOT NULL
125 do_test recover-types-2.3 {
126 db eval {
127 DROP TABLE IF EXISTS temp.types_recover;
128 CREATE VIRTUAL TABLE temp.types_recover USING recover(
129 types,
130 rowtype TEXT,
131 value FLOAT STRICT NOT NULL
132 );
133 }
134 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
135 } {3 FLOAT 3.1415927 real}
136
137 # Restrict by TEXT
138 do_test recover-types-3.0 {
139 db eval {
140 DROP TABLE IF EXISTS temp.types_recover;
141 CREATE VIRTUAL TABLE temp.types_recover USING recover(
142 types,
143 rowtype TEXT,
144 value TEXT
145 );
146 }
147 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
148 } {1 NULL {} null 4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
149
150 # Restrict by TEXT NOT NULL
151 do_test recover-types-3.1 {
152 db eval {
153 DROP TABLE IF EXISTS temp.types_recover;
154 CREATE VIRTUAL TABLE temp.types_recover USING recover(
155 types,
156 rowtype TEXT,
157 value TEXT NOT NULL
158 );
159 }
160 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
161 } {4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
162
163 # Restrict by TEXT STRICT
164 do_test recover-types-3.2 {
165 db eval {
166 DROP TABLE IF EXISTS temp.types_recover;
167 CREATE VIRTUAL TABLE temp.types_recover USING recover(
168 types,
169 rowtype TEXT,
170 value TEXT STRICT
171 );
172 }
173 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
174 } {1 NULL {} null 4 TEXT {This is text} text}
175
176 # Restrict by TEXT STRICT NOT NULL
177 do_test recover-types-3.3 {
178 db eval {
179 DROP TABLE IF EXISTS temp.types_recover;
180 CREATE VIRTUAL TABLE temp.types_recover USING recover(
181 types,
182 rowtype TEXT,
183 value TEXT STRICT NOT NULL
184 );
185 }
186 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
187 } {4 TEXT {This is text} text}
188
189 # Restrict by BLOB
190 do_test recover-types-4.0 {
191 db eval {
192 DROP TABLE IF EXISTS temp.types_recover;
193 CREATE VIRTUAL TABLE temp.types_recover USING recover(
194 types,
195 rowtype TEXT,
196 value BLOB
197 );
198 }
199 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
200 } {1 NULL {} null 5 BLOB {This is a blob} blob}
201
202 # Restrict by BLOB NOT NULL
203 do_test recover-types-4.1 {
204 db eval {
205 DROP TABLE IF EXISTS temp.types_recover;
206 CREATE VIRTUAL TABLE temp.types_recover USING recover(
207 types,
208 rowtype TEXT,
209 value BLOB NOT NULL
210 );
211 }
212 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
213 } {5 BLOB {This is a blob} blob}
214
215 # Manifest typing.
216 do_test recover-types-5.0 {
217 db eval {
218 DROP TABLE IF EXISTS temp.types_recover;
219 CREATE VIRTUAL TABLE temp.types_recover USING recover(
220 types,
221 rowtype TEXT,
222 value
223 );
224 }
225 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
226 } {1 NULL {} null 2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is te xt} text 5 BLOB {This is a blob} blob}
227
228 # Should get same results specifying manifest typing explicitly.
229 do_test recover-types-5.1 {
230 db eval {
231 DROP TABLE IF EXISTS temp.types_recover;
232 CREATE VIRTUAL TABLE temp.types_recover USING recover(
233 types,
234 rowtype TEXT,
235 value ANY
236 );
237 }
238 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
239 } {1 NULL {} null 2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is te xt} text 5 BLOB {This is a blob} blob}
240
241 # Same results, skipping the NULL row.
242 do_test recover-types-5.2 {
243 db eval {
244 DROP TABLE IF EXISTS temp.types_recover;
245 CREATE VIRTUAL TABLE temp.types_recover USING recover(
246 types,
247 rowtype TEXT,
248 value ANY NOT NULL
249 );
250 }
251 execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
252 } {2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
253
254 # Test ROWID values.
255 do_test recover-types-6.0 {
256 db eval {
257 DROP TABLE IF EXISTS temp.types2_recover;
258 CREATE VIRTUAL TABLE temp.types2_recover USING recover(
259 types2,
260 id ROWID,
261 rowtype TEXT,
262 value
263 );
264 }
265 execsql {SELECT rowid, id, rowtype, value, TYPEOF(value) FROM types2_recover}
266 } {1 1 NULL {} null 2 2 INTEGER 17 integer 3 3 FLOAT 3.1415927 real 4 4 TEXT {Th is is text} text 5 5 BLOB {This is a blob} blob}
267
268 # ROWID NOT NULL is identical.
269 do_test recover-types-6.1 {
270 db eval {
271 DROP TABLE IF EXISTS temp.types2_recover;
272 CREATE VIRTUAL TABLE temp.types2_recover USING recover(
273 types2,
274 id ROWID NOT NULL,
275 rowtype TEXT,
276 value
277 );
278 }
279 execsql {SELECT rowid, id, rowtype, value, TYPEOF(value) FROM types2_recover}
280 } {1 1 NULL {} null 2 2 INTEGER 17 integer 3 3 FLOAT 3.1415927 real 4 4 TEXT {Th is is text} text 5 5 BLOB {This is a blob} blob}
281
282 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/recover0.test ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698